From: Helge Deller <deller@kernel.org>
To: qemu-devel@nongnu.org
Cc: Helge Deller <deller@gmx.de>, Laurent Vivier <laurent@vivier.eu>,
Pierrick Bouvier <pierrick.bouvier@oss.qualcomm.com>
Subject: [PULL 1/1] linux-user: do not emulate PI futexes given endianness mismatch
Date: Sun, 22 Nov 2026 17:13:00 +0100 [thread overview]
Message-ID: <20261122161300.6165-2-deller@kernel.org> (raw)
In-Reply-To: <20261122161300.6165-1-deller@kernel.org>
From: Barnabás Pőcze <pobrn@protonmail.com>
For PI futexes, the futex word is expected to contain the thread id in native
byte order. And failing to emulate that leads to issues as e.g. glibc does
not expect `ESRCH` to be returned from a `FUTEX_LOCK_PI` operation.
If the mutex is set to be "robust", then this is detected as unrecoverable
failure and glibc aborts (since a robust mutex should've been unlocked by
the kernel when the owner dies):
Fatal glibc error: pthread_mutex_lock.c:450 (__pthread_mutex_lock_full): assertion failed: e != ESRCH || !robust
qemu: uncaught target signal 6 (Aborted) - core dumped
Aborted (core dumped)
Since `FUTEX_LOCK_PI{,2}` cannot be easily emulated when the host and target
endianness differs, do not handle them, and return `ENOSYS`. This allows
e.g. glibc to detect that they do not work and handle things accordingly.
Link: https://gitlab.com/qemu-project/qemu/-/work_items/4911
Cc: qemu-stable@nongnu.org
Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com>
Reviewed-by: Helge Deller <deller@gmx.de>
Tested-by: Helge Deller <deller@gmx.de> # on 32-bit parisc big endian guest
Signed-off-by: Helge Deller <deller@gmx.de>
---
linux-user/syscall.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 350e69e2d0..d2a6cfb454 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8243,6 +8243,7 @@ static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr,
case FUTEX_WAIT_BITSET:
val = tswap32(val);
break;
+#if HOST_BIG_ENDIAN == TARGET_BIG_ENDIAN
case FUTEX_WAIT_REQUEUE_PI:
val = tswap32(val);
haddr2 = g2h(cpu, uaddr2);
@@ -8250,10 +8251,11 @@ static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr,
case FUTEX_LOCK_PI:
case FUTEX_LOCK_PI2:
break;
- case FUTEX_WAKE:
- case FUTEX_WAKE_BITSET:
case FUTEX_TRYLOCK_PI:
case FUTEX_UNLOCK_PI:
+#endif
+ case FUTEX_WAKE:
+ case FUTEX_WAKE_BITSET:
timeout = 0;
break;
case FUTEX_FD:
@@ -8261,7 +8263,9 @@ static int do_futex(CPUState *cpu, bool time64, target_ulong uaddr,
timeout = 0;
break;
case FUTEX_CMP_REQUEUE:
+#if HOST_BIG_ENDIAN == TARGET_BIG_ENDIAN
case FUTEX_CMP_REQUEUE_PI:
+#endif
val3 = tswap32(val3);
/* fall through */
case FUTEX_REQUEUE:
--
2.54.0
next prev parent reply other threads:[~2026-11-22 16:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-22 16:12 [PULL 0/1] Linux user next patches Helge Deller
2026-11-22 16:13 ` Helge Deller [this message]
2026-11-23 16:52 ` Richard Henderson
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=20261122161300.6165-2-deller@kernel.org \
--to=deller@kernel.org \
--cc=deller@gmx.de \
--cc=laurent@vivier.eu \
--cc=pierrick.bouvier@oss.qualcomm.com \
--cc=qemu-devel@nongnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.