public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Stan Shebs <shebs@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: Fri, 24 Jan 2020 16:19:00 -0000	[thread overview]
Message-ID: <20200124161957.96254.qmail@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=973a510a9408ec58d5c3216ce411757ba6c6e489

commit 973a510a9408ec58d5c3216ce411757ba6c6e489
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 b69eeda..2279026 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;


             reply	other threads:[~2020-01-24 16:19 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24 16:19 Stan Shebs [this message]
2021-08-28  0:37 Fangrui Song

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=20200124161957.96254.qmail@sourceware.org \
    --to=shebs@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: link
Be 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).