public inbox for linux-riscv@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] riscv: uapi: Lie about having futex()
@ 2023-01-19 19:39 Palmer Dabbelt
  2023-01-19 20:16 ` Andreas Schwab
  2023-01-20  8:44 ` Arnd Bergmann
  0 siblings, 2 replies; 3+ messages in thread
From: Palmer Dabbelt @ 2023-01-19 19:39 UTC (permalink / raw)
  To: Arnd Bergmann, Alistair Francis; +Cc: linux-riscv, Palmer Dabbelt

Without this libstdc++ correctly detects the lack of a futex() syscall
on rv32 and uses a fallback that doesn't work because it depends on
64-bit atomics.

Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>

---
I'm not exactly sure why this is triggering now, as it seems like all
the conditions have been there for a while, but I had to swizzle around
the toolchain tuples recently due to some glibc build system
improvements and I suspect it's related.

It looks viable to update libstdc++ to understand futex_time64, but
given how common SYS_futex is these days I'm guessing some other bits of
userspace will end up broken as well.   This certainly feels dirty, but
it's easy.
---
 arch/riscv/include/asm/unistd.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/arch/riscv/include/asm/unistd.h b/arch/riscv/include/asm/unistd.h
index 221630bdbd07..26116686690a 100644
--- a/arch/riscv/include/asm/unistd.h
+++ b/arch/riscv/include/asm/unistd.h
@@ -24,3 +24,11 @@
 #include <uapi/asm/unistd.h>
 
 #define NR_syscalls (__NR_syscalls)
+
+/*
+ * Userspace (at least libstdc++) has come to expect SYS_futex, but we only
+ * have SYS_futex_time64 on rv32.  So just lie.
+ */
+#ifndef __LP64__
+#define __NR_futex __NR_futex_time64
+#endif
-- 
2.39.0


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-20  8:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-19 19:39 [PATCH] riscv: uapi: Lie about having futex() Palmer Dabbelt
2023-01-19 20:16 ` Andreas Schwab
2023-01-20  8:44 ` Arnd Bergmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox