public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
* [glibc/google/grte/v5-2.27/master] Add workaround for infinite looping in ppc vsyscall for sched_getcpu.
@ 2021-08-28 0:37 Fangrui Song
0 siblings, 0 replies; 2+ messages in thread
From: Fangrui Song @ 2021-08-28 0:37 UTC (permalink / raw)
To: glibc-cvs
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;
^ permalink raw reply [flat|nested] 2+ messages in thread
* [glibc/google/grte/v5-2.27/master] Add workaround for infinite looping in ppc vsyscall for sched_getcpu.
@ 2020-01-24 16:19 Stan Shebs
0 siblings, 0 replies; 2+ messages in thread
From: Stan Shebs @ 2020-01-24 16:19 UTC (permalink / raw)
To: glibc-cvs
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;
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-08-28 0:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-28 0:37 [glibc/google/grte/v5-2.27/master] Add workaround for infinite looping in ppc vsyscall for sched_getcpu Fangrui Song
-- strict thread matches above, loose matches on Subject: below --
2020-01-24 16:19 Stan Shebs
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).