public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Fangrui Song <maskray@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc/google/grte/v5-2.27/master] Add workaround for infinite looping in ppc vsyscall for sched_getcpu. Date: Sat, 28 Aug 2021 00:37:12 +0000 (GMT) [thread overview] Message-ID: <20210828003712.C20663858038@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=144448d56646f119c227f171473372855dd17e95 commit 144448d56646f119c227f171473372855dd17e95 Author: Stan Shebs <stanshebs@google.com> Date: Fri Jan 24 08:17:38 2020 -0800 Add workaround for infinite looping in ppc vsyscall for sched_getcpu. Diff: --- sysdeps/unix/sysv/linux/sched_getcpu.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/sysdeps/unix/sysv/linux/sched_getcpu.c b/sysdeps/unix/sysv/linux/sched_getcpu.c index b69eeda15c..2279026bec 100644 --- a/sysdeps/unix/sysv/linux/sched_getcpu.c +++ b/sysdeps/unix/sysv/linux/sched_getcpu.c @@ -24,11 +24,28 @@ #endif #include <sysdep-vdso.h> +#if defined __clang__ && defined __powerpc64__ +/* On ppc, sched_getcpu's body eventually expands into asm code + that does a bctrl, but clang does not recognize the need to save + the link register, so calls loop infinitely instead of returning. + As workaround, make a dummy function call that forces a link + register save. */ +volatile int sched_getcpu_dummy_glob; + +void __attribute__((noinline)) sched_getcpu_dummy () +{ + sched_getcpu_dummy_glob = 45; +} +#endif + int sched_getcpu (void) { #ifdef __NR_getcpu unsigned int cpu; +#if defined __clang__ && defined __powerpc64__ + sched_getcpu_dummy (); +#endif int r = INLINE_VSYSCALL (getcpu, 3, &cpu, NULL, NULL); return r == -1 ? r : cpu;
next reply other threads:[~2021-08-28 0:37 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-08-28 0:37 Fangrui Song [this message] -- strict thread matches above, loose matches on Subject: below -- 2020-01-24 16:19 Stan Shebs
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20210828003712.C20663858038@sourceware.org \ --to=maskray@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).