From nobody Mon Nov 23 04:28:00 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=quarantine dis=none) header.from=protonmail.com ARC-Seal: i=1; a=rsa-sha256; t=1795119025; cv=none; d=zohomail.com; s=zohoarc; b=D3hpdn5+SDJ6LbNi6SwbJI0gFUszBE3T6eMEyOdSRfnSRud8F2seOp3v91geJIGqNPtJMoRRn9yb76lVz/1qbc2pLaAgd0PEjM+gBy8CkoBE8KpvoLmZ7sgIsb+/qrNGx4nLWgd1NjmFozsw+JHNEoCEDLGkJzV0lcrlii6eoKs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1795119025; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RmGXA9QjuDRHR47UR9iZSi2k5lxcbolX27KxaFTUShw=; b=lmO1dTKlOViyE4Sq5SyJJSp+ifP94wppEsPZa1koheOgHYYVGAonjv2s/4eixlOpQsvuHWBzYyJoIlx3hb34/VIr465Kj3WaBGDF1kO8E2KokWHpADTowsnvB7FhJDGOpqAwP5uDbI8NuRB8CZSJhmu3uLU3CJJ72mSBieu2n2M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1795119025972592.457452786567; Thu, 19 Nov 2026 12:10:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1xU8SI-0001im-3C; Thu, 19 Nov 2026 15:10:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xU7ZJ-0001Ig-PJ for qemu-devel@nongnu.org; Thu, 19 Nov 2026 14:13:13 -0500 Received: from mail-08.mail-europe.com ([57.129.93.249]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1xU7ZI-0000v7-2k for qemu-devel@nongnu.org; Thu, 19 Nov 2026 14:13:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1795115577; x=1795374777; bh=RmGXA9QjuDRHR47UR9iZSi2k5lxcbolX27KxaFTUShw=; h=Date:To:From:Cc:Subject:Message-ID:Feedback-ID:From:To:Cc:Date: Subject:Reply-To:Feedback-ID:Message-ID:BIMI-Selector; b=dIG9qH6mBa5YMzENJ7A24ag0Tg4GGHjniaMTlnrljZVPSe/xGi/Y/gEbNWpXXzCBz tAuNy76/nScPzz6wGmT0WD+ahu1MgoY1K17piQOmyayeCjn4Wqz2tALKdVfOb3EIu9 oIkZ/8tQF5mzxnrp00aa4WrFwiTKsySPDalog+BKR5xhKPtMPaaKAVywCBi9SG8pRv tibFZgj8rPfef2tJrotWSfj3VIB1mUYfIGRqTxozsOgz1JClocq4LYM2k17X9PuPx4 Fs0QfqQzYRnAkMFFKFdRpORsDPF3yMGW75Hmk/IAmpo7q/Q9dPTNFvm/1zETUnxgNt HBQYVAPEf++bQ== Date: Thu, 19 Nov 2026 19:12:53 +0000 To: Laurent Vivier , Helge Deller , Pierrick Bouvier , qemu-devel@nongnu.org From: =?utf-8?Q?Barnab=C3=A1s_P=C5=91cze?= Cc: qemu-stable@nongnu.org Subject: [RFC PATCH v1] linux-user: do not emulate PI futexes given endianness mismatch Message-ID: <20261119191247.391446-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton X-Pm-Message-ID: 88e942f7f8f7e6e7ca0a2963c2040c7c8317b72c MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=57.129.93.249; envelope-from=pobrn@protonmail.com; helo=mail-08.mail-europe.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 19 Nov 2026 15:09:58 -0500 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @protonmail.com) X-ZM-MESSAGEID: 1795119028166158500 Content-Type: text/plain; charset="utf-8" For PI futexes, the futex word is expected to contain the thread id in nati= ve 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 !=3D 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=C3=A1s P=C5=91cze Reviewed-by: Helge Deller Tested-by: Helge Deller # on big-endian hppa guest --- 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 2fc61b3eab..c5fbd30e28 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -8243,6 +8243,7 @@ static int do_futex(CPUState *cpu, bool time64, targe= t_ulong uaddr, case FUTEX_WAIT_BITSET: val =3D tswap32(val); break; +#if HOST_BIG_ENDIAN =3D=3D TARGET_BIG_ENDIAN case FUTEX_WAIT_REQUEUE_PI: val =3D tswap32(val); haddr2 =3D g2h(cpu, uaddr2); @@ -8250,10 +8251,11 @@ static int do_futex(CPUState *cpu, bool time64, tar= get_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 =3D 0; break; case FUTEX_FD: @@ -8261,7 +8263,9 @@ static int do_futex(CPUState *cpu, bool time64, targe= t_ulong uaddr, timeout =3D 0; break; case FUTEX_CMP_REQUEUE: +#if HOST_BIG_ENDIAN =3D=3D TARGET_BIG_ENDIAN case FUTEX_CMP_REQUEUE_PI: +#endif val3 =3D tswap32(val3); /* fall through */ case FUTEX_REQUEUE: --=20 2.56.1