From nobody Sat May 30 17:43:39 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1779825897; cv=none; d=zohomail.com; s=zohoarc; b=ZYuokVswDTWeU9f3MTnwXys3iSUFs3oNi+aElg6TMBUUyVjZwMLXu1+5tlHJ/Xw458Pz9yIzruaQa6k1CfnoFmbBfSuBI/ZaIUVX4qoUjiW/RxcOnTcmG6B4wfhBBH5wwIXKDsyjFrDS2Us0b2Aejc70GIyWyo/IQSaty9gcQLc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779825897; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=nvntSM18afV4ztUV6noHKCwxuAwGyr+1Agibouoa9Q8=; b=kxOCX5eP5xmbC+XpGi2qBC2VBSAoWCnjQ+Ot7LqaeCZNUzFGl93R/A2q08sp40OsI428KDzURMPMJaxa0wgWxa+Lr2e+YiKWEDJpWxYutc0GY+4b1VJ+lf4S5TOZQO4y03xgIxK6vReobSfudIFvfVoqhaLwyWlU4+SrdKqT98M= 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 1779825897017856.5032756723373; Tue, 26 May 2026 13:04:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRxzI-0004cG-1a; Tue, 26 May 2026 16:02:52 -0400 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 1wRxyl-0004XF-PN; Tue, 26 May 2026 16:02:20 -0400 Received: from sea.source.kernel.org ([172.234.252.31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wRxyk-0002Yz-AH; Tue, 26 May 2026 16:02:19 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 9BD324452A; Tue, 26 May 2026 20:02:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 356DA1F00A3A; Tue, 26 May 2026 20:02:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779825736; bh=nvntSM18afV4ztUV6noHKCwxuAwGyr+1Agibouoa9Q8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=MXWi3ENtwE4S78rOREkkWd8tHE88vi5wd5kJ3qyxz/eCpy6fHQ9jqxCiEZXu5PPKa ciPA2fy9vzz5ra59mfxkwiMh+8hPEgZdTKPz9CHN4b1HYzIeoDArmZvkvLkTBIvjMr Br1xOxV7Gcwd2snF90Op+VcH71CXuvU7a6E8sJjYJDUH2p6M6fAkEz5RrzSa6t7DUq 2YrZ7X8GEe268pfTwVU/lK/hzcvk74kndTj0NT/K4ZVc10+yA75661bDiSgRRje9jD RqpOzcqwzz4e181Ah4MdqvFEYvvhkhU1jATN43i2+cXbadYWVlqgpSkcH5XUkAN8L2 62E1ib7J+7iMw== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , qemu-s390x@nongnu.org, Richard Henderson , Eric Farman , Matthew Rosato , Helge Deller , Aleksandar Rikalo , David Hildenbrand , Laurent Vivier , Cornelia Huck , Jiaxun Yang , Yoshinori Sato , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Aurelien Jarno Subject: [PULL 01/12] linux-user/ppc: restore fp_status from FPSCR on sigreturn Date: Tue, 26 May 2026 22:01:56 +0200 Message-ID: <20260526200207.79738-2-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526200207.79738-1-deller@kernel.org> References: <20260526200207.79738-1-deller@kernel.org> 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=172.234.252.31; envelope-from=deller@kernel.org; helo=sea.source.kernel.org X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @kernel.org) X-ZM-MESSAGEID: 1779825897212158500 Content-Type: text/plain; charset="utf-8" From: Matt Turner restore_user_regs() restores the PPC FPSCR with a direct assignment: env->fpscr =3D (uint32_t) fpscr; ppc_store_fpscr() exists precisely to write FPSCR and keep the derived env->fp_status in sync: it calls fpscr_set_rounding_mode() to update the softfloat rounding mode, and set_float_rebias_overflow/underflow() to reflect the FP_OE/FP_UE enable bits. The direct assignment bypasses all of this. On sigreturn, interrupted code resumes with whatever rounding mode and overflow/underflow-rebias state the signal handler last installed in fp_status, rather than the state that was saved at signal delivery. Replace the direct assign with ppc_store_fpscr(). The FPSCR_MTFS_MASK applied inside ppc_store_fpscr() only excludes the computed FP_FEX and FP_VX bits, which it re-derives correctly from the exception and enable bits in the restored value. Fixes: bcd4933a23 ("linux-user: ppc signal handling") Cc: qemu-stable@nongnu.org Reviewed-by: Richard Henderson Signed-off-by: Matt Turner Signed-off-by: Helge Deller --- linux-user/ppc/signal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/ppc/signal.c b/linux-user/ppc/signal.c index a9c10e0987..ab1afea30a 100644 --- a/linux-user/ppc/signal.c +++ b/linux-user/ppc/signal.c @@ -420,7 +420,7 @@ static void restore_user_regs(CPUPPCState *env, __get_user(*fpr, &frame->mc_fregs[i]); } __get_user(fpscr, &frame->mc_fregs[32]); - env->fpscr =3D (uint32_t) fpscr; + ppc_store_fpscr(env, (uint32_t) fpscr); } =20 #if !defined(TARGET_PPC64) --=20 2.54.0 From nobody Sat May 30 17:43:39 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1779825897; cv=none; d=zohomail.com; s=zohoarc; b=jnb5qW72m33Dq8HVKlKaB5BgeeXcYzwe5kLVthL1R/KX/JPlQKLagefWU1q/z4pm/zzcOGxX3CYDc7TPfCgX/5CVBR/oR4ub34SG5D3+IVttSxi73OnncZyCt5oEDknH9vdc6fPQzRpm5E1azScWDNQ6icql+jaXmr//vl7wQ34= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779825897; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RL/zGi1pDp8yTNmI8IAlrRDAo9DD/BZhQK5MCrsVinw=; b=OvTzBw5N9X5NbvWhJ5FnnfiFrkoaxcUUWrVojJydO+i2gqxVm0BBmHAXayeTVpPcUyg3edRCR6u3bGsCnfcbTF8o4eAgZ65NHZYSiFV6VO5WINOJYK1/a4AdWIWcKqU0BmiYkLkZbt+Qk5R8mUX3HOMShVI3yG1NAeD+uDA3LG0= 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 1779825897792363.8684687883724; Tue, 26 May 2026 13:04:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRxzJ-0004co-M9; Tue, 26 May 2026 16:02:53 -0400 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 1wRxys-0004Xy-5v; Tue, 26 May 2026 16:02:35 -0400 Received: from tor.source.kernel.org ([172.105.4.254]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wRxyp-0002Zr-8I; Tue, 26 May 2026 16:02:24 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 960F2600AB; Tue, 26 May 2026 20:02:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F2F751F000E9; Tue, 26 May 2026 20:02:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779825740; bh=RL/zGi1pDp8yTNmI8IAlrRDAo9DD/BZhQK5MCrsVinw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AnwbEPGT1SyeWPFdDZ/mcGieMdi/r+ZztWBDVE0/06S+bl/FFpp0EisIyBJ6kBCY6 7LNLX0TVeF1VehRNdjDQUD3iwQuF6SPmXDnt1vUerPCohEzko1nMKqtBU5w77TCC01 oZdf4yG71f67b4FY977r1gdditZfmu25Jfp6CYvzR9Xjk6rDTHOw5p5MXTUttO3iN+ a+2o5XzWUH+dA9k2mBZLrOGakRE5Rce5RLARDjqt6x85jQNvnZTMAdrW7kU53XFF94 g1+p5QKMaYO/DLww6mklE2D7aAy6jRE6oaKlHIhzRV7Og9z7g8ITfNmqIREZ0idtyH m7U9YanjoWcsw== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , qemu-s390x@nongnu.org, Richard Henderson , Eric Farman , Matthew Rosato , Helge Deller , Aleksandar Rikalo , David Hildenbrand , Laurent Vivier , Cornelia Huck , Jiaxun Yang , Yoshinori Sato , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Aurelien Jarno Subject: [PULL 02/12] linux-user/mips: save/restore FCSR across signal delivery Date: Tue, 26 May 2026 22:01:57 +0200 Message-ID: <20260526200207.79738-3-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526200207.79738-1-deller@kernel.org> References: <20260526200207.79738-1-deller@kernel.org> 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=172.105.4.254; envelope-from=deller@kernel.org; helo=tor.source.kernel.org X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @kernel.org) X-ZM-MESSAGEID: 1779825899505154100 Content-Type: text/plain; charset="utf-8" From: Matt Turner QEMU keeps the MIPS FPU control/status register (FCSR, fcr31) in env->active_fpu.fcr31. The rounding mode, flush-to-zero (FS), and NaN-2008 mode bits in fcr31 are reflected into the derived env->active_fpu.fp_status via set_float_rounding_mode() and friends; every architectural write to FCSR goes through helper_ctc1() which calls restore_fp_status() to keep the two in sync. Both target_sigcontext variants (O32 and N32/N64) have an sc_fpc_csr field that holds FCSR, but setup_sigcontext() never wrote it and restore_sigcontext() never read it. As a result: - The signal frame always delivered sc_fpc_csr =3D=3D 0 to the handler, so sigaction(SA_SIGINFO) handlers that inspect the interrupted context see the wrong FCSR. - On sigreturn, active_fpu.fcr31 retained whatever value the signal handler last installed (if any), and active_fpu.fp_status was never resynced. Interrupted code resumed with the wrong rounding mode, FS flag, and NaN-2008 semantics. Fix setup_sigcontext() to save fcr31 into sc_fpc_csr. Fix restore_sigcontext() to read it back (masked to fcr31_rw_bitmask as the kernel does) and call cpu_mips_restore_fp_status() to resync fp_status from the restored fcr31. Add cpu_mips_restore_fp_status() in target/mips/fpu.c (which already defines ieee_rm and includes fpu_helper.h), and declare it in cpu.h. Fixes: 084d0497a0 ("mips-linux-user: Save and restore fpu and dsp from sigc= ontext") Cc: qemu-stable@nongnu.org Signed-off-by: Matt Turner Signed-off-by: Helge Deller --- linux-user/mips/signal.c | 7 +++++++ target/mips/cpu.h | 3 +++ target/mips/fpu.c | 5 +++++ 3 files changed, 15 insertions(+) diff --git a/linux-user/mips/signal.c b/linux-user/mips/signal.c index d69a5d73dd..1b10012726 100644 --- a/linux-user/mips/signal.c +++ b/linux-user/mips/signal.c @@ -134,6 +134,7 @@ static inline void setup_sigcontext(CPUMIPSState *regs, for (i =3D 0; i < 32; ++i) { __put_user(regs->active_fpu.fpr[i].d, &sc->sc_fpregs[i]); } + __put_user(regs->active_fpu.fcr31, &sc->sc_fpc_csr); } =20 static inline void @@ -165,6 +166,12 @@ restore_sigcontext(CPUMIPSState *regs, struct target_s= igcontext *sc) for (i =3D 0; i < 32; ++i) { __get_user(regs->active_fpu.fpr[i].d, &sc->sc_fpregs[i]); } + { + uint32_t fcr31; + __get_user(fcr31, &sc->sc_fpc_csr); + regs->active_fpu.fcr31 =3D fcr31 & regs->active_fpu.fcr31_rw_bitma= sk; + cpu_mips_restore_fp_status(regs); + } } =20 /* diff --git a/target/mips/cpu.h b/target/mips/cpu.h index 346713705a..392406aff8 100644 --- a/target/mips/cpu.h +++ b/target/mips/cpu.h @@ -1384,6 +1384,9 @@ void cpu_mips_clock_init(MIPSCPU *cpu); /* helper.c */ target_ulong exception_resume_pc(CPUMIPSState *env); =20 +/* fpu.c */ +void cpu_mips_restore_fp_status(CPUMIPSState *env); + /** * mips_cpu_create_with_clock: * @typename: a MIPS CPU type. diff --git a/target/mips/fpu.c b/target/mips/fpu.c index c7c487c1f9..8b661865ca 100644 --- a/target/mips/fpu.c +++ b/target/mips/fpu.c @@ -17,6 +17,11 @@ const FloatRoundMode ieee_rm[4] =3D { float_round_down }; =20 +void cpu_mips_restore_fp_status(CPUMIPSState *env) +{ + restore_fp_status(env); +} + const char fregnames[32][4] =3D { "f0", "f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", --=20 2.54.0 From nobody Sat May 30 17:43:39 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1779825881; cv=none; d=zohomail.com; s=zohoarc; b=iAi/PbkXBXPOFXdwCGCykKmGlHYeLQP3yBKSZFA16PSXaFyFU+5OU/XoemOL2u2tN9UaLchZ3gATSD4n8dhBMMurQoY3ZEdv0rLdlkgsHY0bej5t0Ojpcc19RHUJPUvy+pavsFGbPxUAL5DKpqsHiiI0q8r+74F+WxYyScBK/Dg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779825881; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=czHWASgcVRX6WqaAi+3O59ynkEQ7PMLnAzM69Hv53hg=; b=WhPXnBTHkoq2B3mEn/Fzd59iMjWqA8JtaRa6jyOdkqj7FqmMuql8Zpk+p5Qxetqb/2mCn0cqfVxF0dAxc9eUnixxDFCxdgwNL+VIvMF7L5dIomPX/Q9ezwREXDkdr06USTSWsgmHtPOH5462xO+IRe9ILEbczPym9BVqpszUqrw= 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 1779825881380866.6640172633272; Tue, 26 May 2026 13:04:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRxzJ-0004cl-CR; Tue, 26 May 2026 16:02:53 -0400 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 1wRxyw-0004YH-75; Tue, 26 May 2026 16:02:41 -0400 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wRxys-0002fr-K3; Tue, 26 May 2026 16:02:28 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id DC3EE600B0; Tue, 26 May 2026 20:02:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBAC71F00A3C; Tue, 26 May 2026 20:02:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779825744; bh=czHWASgcVRX6WqaAi+3O59ynkEQ7PMLnAzM69Hv53hg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=EhgzpY33DSE27IaxYA1xVnQurI7m7QeqRbMKOzzykJd0SgG40qBz8uXMho1oZptDr q7ZLvgx7swK3YHQ5wfW9JMKW9omn0AeAzp9xL9LokkgyXFVCzSU6V2POIZkvN7dyrV GVTt1ln2arHailUxuD0EJHHnG25i2AOQE3oMdZhmxd2XD1NJ1NXsYsVMhYROGFd8Hy aq8nvvbDAf0vjq3E9Qaql08Kqs1I/wYosro+KGnN+qAHa4FODfl90NaKnR1xneSqOC Wh6qSp37SCA0vlZPABOlBeULZ6fP38IeI8QCoAn09/Y5zT7Ro+kSekenUTRKYW3N51 3F8ehQa4F3V9w== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , qemu-s390x@nongnu.org, Richard Henderson , Eric Farman , Matthew Rosato , Helge Deller , Aleksandar Rikalo , David Hildenbrand , Laurent Vivier , Cornelia Huck , Jiaxun Yang , Yoshinori Sato , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Aurelien Jarno Subject: [PULL 03/12] linux-user/alpha: add coredump support Date: Tue, 26 May 2026 22:01:58 +0200 Message-ID: <20260526200207.79738-4-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526200207.79738-1-deller@kernel.org> References: <20260526200207.79738-1-deller@kernel.org> 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=2600:3c04:e001:324:0:1991:8:25; envelope-from=deller@kernel.org; helo=tor.source.kernel.org X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @kernel.org) X-ZM-MESSAGEID: 1779825883426154100 Content-Type: text/plain; charset="utf-8" From: Matt Turner Define HAVE_ELF_CORE_DUMP and target_elf_gregset_t in target_elf.h, mirroring the kernel's elf_gregset_t (ELF_NGREG =3D 66): r0-r31 [0..31], f0-f31 [32..63], pc [64], ps [65]. Implement elf_core_copy_regs() in elfload.c to populate the gregset from CPUAlphaState. Without this, bprm->core_dump is NULL for Alpha targets. When a guest signal goes unhandled, dump_core_and_abort() skips the core write and falls through to die_with_signal(), which re-raises the signal to the host. The host kernel then writes an x86-64 core file for the qemu-alpha process instead of an Alpha guest core. Signed-off-by: Matt Turner Signed-off-by: Helge Deller --- linux-user/alpha/elfload.c | 12 ++++++++++++ linux-user/alpha/target_elf.h | 13 +++++++++++++ 2 files changed, 25 insertions(+) diff --git a/linux-user/alpha/elfload.c b/linux-user/alpha/elfload.c index 1e44475c47..c86f9cf2bb 100644 --- a/linux-user/alpha/elfload.c +++ b/linux-user/alpha/elfload.c @@ -3,8 +3,20 @@ #include "qemu/osdep.h" #include "qemu.h" #include "loader.h" +#include "target_elf.h" =20 =20 +void elf_core_copy_regs(target_elf_gregset_t *r, const CPUAlphaState *env) +{ + int i; + + for (i =3D 0; i < 31; i++) { + r->regs[i] =3D tswap64(env->ir[i]); + } + r->pc =3D tswap64(env->pc); + r->ps =3D 0; +} + const char *get_elf_cpu_model(uint32_t eflags) { return "ev67"; diff --git a/linux-user/alpha/target_elf.h b/linux-user/alpha/target_elf.h index 864dc6e2e6..bf3bd21b09 100644 --- a/linux-user/alpha/target_elf.h +++ b/linux-user/alpha/target_elf.h @@ -11,4 +11,17 @@ #define ELF_CLASS ELFCLASS64 #define ELF_MACHINE EM_ALPHA =20 +#define HAVE_ELF_CORE_DUMP 1 + +/* + * Matches the kernel's elf_gregset_t (ELF_NGREG =3D 33): + * r0-r30 at indices 0-30, pc at 31, ps at 32. + * r31 (hardwired zero) is not stored; pc occupies index 31. + */ +typedef struct target_elf_gregset_t { + abi_ulong regs[31]; /* integer registers r0-r30 [0..30] */ + abi_ulong pc; /* program counter [31] */ + abi_ulong ps; /* processor status [32] */ +} target_elf_gregset_t; + #endif --=20 2.54.0 From nobody Sat May 30 17:43:39 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1779825881; cv=none; d=zohomail.com; s=zohoarc; b=RsUsKhmukkpAUMahzg7aukLHrWLh65xBkLLXe9H5rXrglLi4RzfN/lwMpou47pJin7vpIbTgRUPIGwR/IOVX8YxjrA5l7hAfWP9tT6/iOyn58DRp0l/9x0bLRcqbDh8W5eCLh6pkCOH6KLvMvU5dyO75eWyS3vNsKGy0tDMoEBE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779825881; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=2NUQ5FfWOGem1CUHXmWxzCYzWNN2B5soNsg/vFqDPfI=; b=WlP+yF6lAai3Nj/sG2XhzQXzTIgNU9pMnHYK76YE75C+kuuFEojthCYYYwgwEFZhIVMQC8DmPDJ/uZ80vy8L97s1dTdMHfsd3IBgAN5GyqJF5a3PVaaryniO5S5mXvYeNHQjKPlUf+ls9D6JozlksSRXBzTj/wZ90SvVhlgO2Cc= 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 1779825881344805.2021448485486; Tue, 26 May 2026 13:04:41 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRxzL-0004dr-6R; Tue, 26 May 2026 16:02:55 -0400 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 1wRxyy-0004YU-34; Tue, 26 May 2026 16:02:41 -0400 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wRxyw-0002mH-8t; Tue, 26 May 2026 16:02:31 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 2348A60018; Tue, 26 May 2026 20:02:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85CA21F00A3A; Tue, 26 May 2026 20:02:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779825747; bh=2NUQ5FfWOGem1CUHXmWxzCYzWNN2B5soNsg/vFqDPfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=NcUaMTyPy68y41jsBH5iKuOgQUF+Xi8A614rHx7DHU5ItiY6E9wbPmg+NAPRvkPYj L4iES0P/zEatUyPHUCArBpJTj5qeb3AaIAvqmwh1Uw7ArLm3I67pNZZLqRGlu4keCU +ZC1PoZ0oFO6wReu8NRkGtfI01+dWgiSIsxTicPP6+j3pVcCPWasuzoHlAPg3cMt+v eV7E/p/6ij5tvyggeBRMJcqSpO2X/M7SJKtoXluopboAj5moA7ksC9lgcoSxmRG9wo BmaqllEN3QYytqZZfWMogQiUVYYfvZAZ019Cbsg78u6YB6wncANU6/40YDg8cSGAvH ZOBi358xa7RNA== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , qemu-s390x@nongnu.org, Richard Henderson , Eric Farman , Matthew Rosato , Helge Deller , Aleksandar Rikalo , David Hildenbrand , Laurent Vivier , Cornelia Huck , Jiaxun Yang , Yoshinori Sato , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Aurelien Jarno Subject: [PULL 04/12] linux-user/sh4: preserve T/M/Q bits across signal delivery Date: Tue, 26 May 2026 22:01:59 +0200 Message-ID: <20260526200207.79738-5-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526200207.79738-1-deller@kernel.org> References: <20260526200207.79738-1-deller@kernel.org> 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=2600:3c04:e001:324:0:1991:8:25; envelope-from=deller@kernel.org; helo=tor.source.kernel.org X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @kernel.org) X-ZM-MESSAGEID: 1779825883449154100 Content-Type: text/plain; charset="utf-8" From: Matt Turner QEMU keeps the SH4 T, M and Q status-register bits outside env->sr, in the dedicated env->sr_t, env->sr_m and env->sr_q fields; cpu_read_sr() folds them back into the architectural SR value and cpu_write_sr() splits them back out. setup_sigcontext() saved the bare env->sr (so the T/M/Q bits were always zero in the signal frame) and restore_sigcontext() wrote the value straight back into env->sr without updating sr_t/sr_m/sr_q. As a result the T bit was never preserved across signal delivery: on sigreturn the interrupted code resumed with whatever T value the signal handler last left behind. Any conditional branch (or addc/subc/rotcl/div1, etc.) immediately following the interrupted instruction could then take the wrong path. This is the cause of the long-standing intermittent failures of the tests/tcg/multiarch/signals.c test on sh4, which was marked BROKEN. With a SIGRTMIN timer firing every millisecond across many threads, the race was hit a few percent of the time and corrupted the guest heap, surfacing as a SIGSEGV in memset, a malloc assertion, or an rseq registration abort. Traced on a deterministic rr recording: a cmp/hi set T=3D0, the timer signal interrupted the very next instruction (a bf), the handler left T=3D1, and the resumed bf took glibc calloc's MORECORE_CLEARS branch, using the old top-chunk size as the clear length for a freshly split small chunk and running memset off the end of the heap. Fix setup_sigcontext()/restore_sigcontext() to use cpu_read_sr() and cpu_write_sr() so the T, M and Q bits round-trip correctly, and drop the BROKEN annotation on the sh4 signals test. Fixes: c3b5bc8ab3 ("SH4: Signal handling for the user space emulator, by Ma= gnus Damm.") Cc: qemu-stable@nongnu.org Reviewed-by: Yoshinori Sato Reviewed-by: Richard Henderson Signed-off-by: Matt Turner Signed-off-by: Helge Deller --- linux-user/sh4/signal.c | 12 ++++++++++-- tests/tcg/sh4/Makefile.target | 7 ------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/linux-user/sh4/signal.c b/linux-user/sh4/signal.c index d70be24c38..cc36425c49 100644 --- a/linux-user/sh4/signal.c +++ b/linux-user/sh4/signal.c @@ -131,8 +131,10 @@ static void setup_sigcontext(struct target_sigcontext = *sc, COPY(gregs[14]); COPY(gregs[15]); COPY(gbr); COPY(mach); COPY(macl); COPY(pr); - COPY(sr); COPY(pc); + COPY(pc); #undef COPY + /* The T, M and Q bits live outside env->sr; fold them back in. */ + __put_user(cpu_read_sr(regs), &sc->sc_sr); =20 for (i=3D0; i<16; i++) { __put_user(regs->fregs[i], &sc->sc_fpregs[i]); @@ -159,8 +161,14 @@ static void restore_sigcontext(CPUSH4State *regs, stru= ct target_sigcontext *sc) COPY(gregs[14]); COPY(gregs[15]); COPY(gbr); COPY(mach); COPY(macl); COPY(pr); - COPY(sr); COPY(pc); + COPY(pc); #undef COPY + /* The T, M and Q bits live outside env->sr; unfold them. */ + { + uint32_t sr; + __get_user(sr, &sc->sc_sr); + cpu_write_sr(regs, sr); + } =20 for (i=3D0; i<16; i++) { __get_user(regs->fregs[i], &sc->sc_fpregs[i]); diff --git a/tests/tcg/sh4/Makefile.target b/tests/tcg/sh4/Makefile.target index 7852fa62d8..b7a8737be0 100644 --- a/tests/tcg/sh4/Makefile.target +++ b/tests/tcg/sh4/Makefile.target @@ -3,13 +3,6 @@ # SuperH specific tweaks # =20 -# This triggers failures for sh4-linux about 10% of the time. -# Random SIGSEGV at unpredictable guest address, cause unknown. -run-signals: signals - $(call skip-test, $<, "BROKEN") -run-plugin-signals-with-%: - $(call skip-test, $<, "BROKEN") - VPATH +=3D $(SRC_PATH)/tests/tcg/sh4 =20 test-macl: CFLAGS +=3D -O -g --=20 2.54.0 From nobody Sat May 30 17:43:39 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1779825903; cv=none; d=zohomail.com; s=zohoarc; b=ak/Typxtsl0yOwW4ZZ2kl8aWybK2ZqjL1XCR6koOtJWTRSt38e5yqD1/5fGzYwtVKjAVjpEMWNNW47ZXotD8Bgg2zxRnCF4OaK2AOs0BvqNOwUm+WpBWGQ4HpDusiV/0We+sTRRwegmOemYcaS4tHroSriummtPLJvcuXRi/w6w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779825903; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=0dQnwUFE5S5dYS/jm+p+iJZyIvrikm45NzygrKgjVW0=; b=bgGJ0X+amgZ75SV+GLqhdqzzYmOZpuj3liwH/Gl+ozSvLufWk8jpNdvY2iNGNcHNTxtSYG2UBEP0Hev38EuLK1QI7CtcJp8tNmQc1AtWdu2i6NfgG/FIzcw7btFgHYV5LxuHXC1tBJIUCK/CxGbURqyRw3GZcyTcg7wlbG26+Ps= 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 1779825903029148.6625391527591; Tue, 26 May 2026 13:05:03 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRxzL-0004ef-OD; Tue, 26 May 2026 16:02:55 -0400 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 1wRxz1-0004Yg-HC; Tue, 26 May 2026 16:02:41 -0400 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wRxz0-0002t8-0E; Tue, 26 May 2026 16:02:35 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id E02B7600B0; Tue, 26 May 2026 20:02:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E0981F000E9; Tue, 26 May 2026 20:02:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779825751; bh=0dQnwUFE5S5dYS/jm+p+iJZyIvrikm45NzygrKgjVW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ERCiVfbvI/qGlTPvlt+9d+O6Aemwm3gC+XsHiGboOjY8BsaaQ+tOEytgClcyau+W4 VBZeWPS2OTweU2MLBGZpRWapbPPv2Mx7DoE6dZuZdiOY1/ISSpWTHbgJWaOycu2Foj PLfFwGoje2rGWN3VFjIkOdHEk+gwbHgeOfjTnZJihLxfuuPgNR7gquQ3Ado4iKmS5i reLML05mlM8eoL7S9LsDegxBUu3J8/3oKi40W6cBEmElNlExgwLTXqcw7f4aOWjahd PspeVAe3yhGvYAfZiYmX1pa0v31BybuAKmuou8PlHSgItxIuPtvnNwu0IUpvsta+in 3dbWJxpZjaWsg== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , qemu-s390x@nongnu.org, Richard Henderson , Eric Farman , Matthew Rosato , Helge Deller , Aleksandar Rikalo , David Hildenbrand , Laurent Vivier , Cornelia Huck , Jiaxun Yang , Yoshinori Sato , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Aurelien Jarno Subject: [PULL 05/12] linux-user/sh4: restore FP rounding mode on sigreturn Date: Tue, 26 May 2026 22:02:00 +0200 Message-ID: <20260526200207.79738-6-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526200207.79738-1-deller@kernel.org> References: <20260526200207.79738-1-deller@kernel.org> 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=2600:3c04:e001:324:0:1991:8:25; envelope-from=deller@kernel.org; helo=tor.source.kernel.org X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @kernel.org) X-ZM-MESSAGEID: 1779825903307158500 Content-Type: text/plain; charset="utf-8" From: Matt Turner The SH4 FPSCR rounding-mode (RM) and denormal (DN) bits are not held only in env->fpscr: they are also reflected into the derived env->fp_status via set_float_rounding_mode()/set_flush_to_zero(). The guest keeps the two in sync by routing every write to FPSCR through helper_ld_fpscr(). restore_sigcontext() wrote the saved value straight into env->fpscr and never touched env->fp_status, so on sigreturn the interrupted code resumed with whatever FP rounding mode and flush-to-zero setting the signal handler last installed. (regs->flags =3D 0 forces the FR/SZ/PR TB flags to be recomputed, but fp_status is runtime float state, not a TB flag, so it was left stale.) This is the FP analogue of the T/M/Q bit problem just fixed for the integer status register. Factor the FPSCR -> fp_status synchronisation out of helper_ld_fpscr() into cpu_load_fpscr() and use it from restore_sigcontext() so the rounding mode round-trips correctly across signal delivery. Fixes: c3b5bc8ab3 ("SH4: Signal handling for the user space emulator, by Ma= gnus Damm.") Cc: qemu-stable@nongnu.org Reviewed-by: Yoshinori Sato Reviewed-by: Richard Henderson Signed-off-by: Matt Turner Signed-off-by: Helge Deller --- linux-user/sh4/signal.c | 7 ++++++- target/sh4/cpu.h | 3 +++ target/sh4/op_helper.c | 7 ++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/linux-user/sh4/signal.c b/linux-user/sh4/signal.c index cc36425c49..00290d6e40 100644 --- a/linux-user/sh4/signal.c +++ b/linux-user/sh4/signal.c @@ -173,7 +173,12 @@ static void restore_sigcontext(CPUSH4State *regs, stru= ct target_sigcontext *sc) for (i=3D0; i<16; i++) { __get_user(regs->fregs[i], &sc->sc_fpregs[i]); } - __get_user(regs->fpscr, &sc->sc_fpscr); + /* Resync the derived float_status state, not just env->fpscr. */ + { + uint32_t fpscr; + __get_user(fpscr, &sc->sc_fpscr); + cpu_load_fpscr(regs, fpscr); + } __get_user(regs->fpul, &sc->sc_fpul); =20 regs->tra =3D -1; /* disable syscall checks */ diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h index 4b0f3f6d97..3302702376 100644 --- a/target/sh4/cpu.h +++ b/target/sh4/cpu.h @@ -379,4 +379,7 @@ static inline void cpu_write_sr(CPUSH4State *env, uint3= 2_t sr) env->sr =3D sr & ~((1u << SR_M) | (1u << SR_Q) | (1u << SR_T)); } =20 +/* Set FPSCR and the derived float_status rounding/flush-to-zero state. */ +void cpu_load_fpscr(CPUSH4State *env, uint32_t val); + #endif /* SH4_CPU_H */ diff --git a/target/sh4/op_helper.c b/target/sh4/op_helper.c index 669bc84cb6..cf0f80e4a5 100644 --- a/target/sh4/op_helper.c +++ b/target/sh4/op_helper.c @@ -204,7 +204,7 @@ void helper_macw(CPUSH4State *env, int32_t arg0, int32_= t arg1) } } =20 -void helper_ld_fpscr(CPUSH4State *env, uint32_t val) +void cpu_load_fpscr(CPUSH4State *env, uint32_t val) { env->fpscr =3D val & FPSCR_MASK; if ((val & FPSCR_RM_MASK) =3D=3D FPSCR_RM_ZERO) { @@ -215,6 +215,11 @@ void helper_ld_fpscr(CPUSH4State *env, uint32_t val) set_flush_to_zero((val & FPSCR_DN) !=3D 0, &env->fp_status); } =20 +void helper_ld_fpscr(CPUSH4State *env, uint32_t val) +{ + cpu_load_fpscr(env, val); +} + static void update_fpscr(CPUSH4State *env, uintptr_t retaddr) { int xcpt, cause, enable; --=20 2.54.0 From nobody Sat May 30 17:43:39 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1779825865; cv=none; d=zohomail.com; s=zohoarc; b=V8SVnxpetyyUx/+4BWnNiZv7uFa5kVKenU9Dqil6+PYodXa9LHxFYuiSSigHGr4+hbn3+sfp9aXYP6zpKh7Oq2mtO2Nz1H3IGQGZtdvk9lDd/+qcVgJprhP4zZIqxrM7ygitBE2v9nZriZaPssgw0SH3n2ofL8p044OtfrTLk2Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779825865; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=/5CGgZ/X7uMiJB5eErY0sF7KyvBhWLSMYSs2M1AmyjE=; b=E7zj8Z+F9zyk+yRuRRB/6JtgPLbOenIX6lZdnJFLYfiCtRG0pj42eeb9wiEUDdHWjlLzlPr6JvTBhrQTmL0hN9qIfAP8+iovP5HVNbXwXDST9SVA98T5Nyycw5LMFZlxT631GqNrg3sbgP8qOmIVFkrtgWrvmMsT0cUQEy/hoWE= 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 1779825865155782.8060168781489; Tue, 26 May 2026 13:04:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRxzJ-0004cn-Lv; Tue, 26 May 2026 16:02:53 -0400 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 1wRxz5-0004Yr-AS; Tue, 26 May 2026 16:02:42 -0400 Received: from tor.source.kernel.org ([172.105.4.254]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wRxz2-0002tb-Va; Tue, 26 May 2026 16:02:39 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id A95E260018; Tue, 26 May 2026 20:02:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 16C541F000E9; Tue, 26 May 2026 20:02:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779825755; bh=/5CGgZ/X7uMiJB5eErY0sF7KyvBhWLSMYSs2M1AmyjE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=k05PsMWPPh62P0iB2EFPjw4LbPghg9/m/xDMQFhs90AJoZ0N7ajGuun/sAxpFB6// IFm//WiagQWielC99Sf0hLNCbUucDOummX/oyvFLh7JnBySO6we47J+9K1wTfB82BD Wmfz/NGPYWUXN9log3lVtwyqp12EYWsXS446kUGM6UNaYuQluCHUCB4OUFYqovHdJk oKf5rSOxRc0/6jShkOgEYOuNmR3vCqumE13VQDt9uZAfRa88j7GApD1Jl0OHvwC/nP S1dIvWhU17mAujQhTIJoLbNff6qB/6fJ8LcLxPINxFDDY/tpI3TpLJ5MDijGc771hQ FIhMDAoSaR00w== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , qemu-s390x@nongnu.org, Richard Henderson , Eric Farman , Matthew Rosato , Helge Deller , Aleksandar Rikalo , David Hildenbrand , Laurent Vivier , Cornelia Huck , Jiaxun Yang , Yoshinori Sato , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Aurelien Jarno Subject: [PULL 06/12] target/sh4: sync fp_status when gdb writes FPSCR Date: Tue, 26 May 2026 22:02:01 +0200 Message-ID: <20260526200207.79738-7-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526200207.79738-1-deller@kernel.org> References: <20260526200207.79738-1-deller@kernel.org> 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=172.105.4.254; envelope-from=deller@kernel.org; helo=tor.source.kernel.org X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @kernel.org) X-ZM-MESSAGEID: 1779825866979158500 Content-Type: text/plain; charset="utf-8" From: Matt Turner sh4_cpu_gdb_write_register() wrote the incoming FPSCR value straight into env->fpscr, leaving the derived env->fp_status (rounding mode and flush-to-zero) stale, so a gdb-initiated FPSCR change did not take effect for subsequent FP operations. Use cpu_load_fpscr() instead, the same way the adjacent case already uses cpu_write_sr() for SR. Cc: qemu-stable@nongnu.org Reviewed-by: Yoshinori Sato Reviewed-by: Richard Henderson Signed-off-by: Matt Turner Signed-off-by: Helge Deller --- target/sh4/gdbstub.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/sh4/gdbstub.c b/target/sh4/gdbstub.c index 4f36e800d2..bdc8c1d164 100644 --- a/target/sh4/gdbstub.c +++ b/target/sh4/gdbstub.c @@ -113,7 +113,7 @@ int superh_cpu_gdb_write_register(CPUState *cs, uint8_t= *mem_buf, int n) env->fpul =3D ldl_p(mem_buf); break; case 24: - env->fpscr =3D ldl_p(mem_buf); + cpu_load_fpscr(env, ldl_p(mem_buf)); break; case 25 ... 40: if (env->fpscr & FPSCR_FR) { --=20 2.54.0 From nobody Sat May 30 17:43:39 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1779825852; cv=none; d=zohomail.com; s=zohoarc; b=ehPDe5yMGz6shoD+DXF/5BPfgjk+sVaze2ysNq7mqQztl3ZkVipDtOBTGRKymWLCX23lsc+1Cby8pTEg480V2NkDO/Y31ZNi/xsqWlnK0fuGn8QnZn/zp9DYiytB3nFul/xqAeCn+Y0PZt0a5e9TB45u4hHb4YTaPB5SfzEAuvo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779825852; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=pGlSoLvSkWLWM09alJZgROZ3NJFIPwvSs1E7yFYC654=; b=WtnNRTxERqGmFiZzOWn60ZbdphKV4RXIwFaYc7C4I2Ss7wqIqREDT7ZAurasr9F8hTPTTc20CxGDCAqZZdIqdTw8sZNZ/3ETUxRwfxrzYr1KgilbTrUP7RRFhCcQbu2ES8yJLI2RFXVHmPvPcFV5M/1hGbSNl6tJl/J2m9S3gOk= 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 1779825852895207.90394937115354; Tue, 26 May 2026 13:04:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRxzN-0004fL-11; Tue, 26 May 2026 16:02:57 -0400 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 1wRxz9-0004ZY-RE; Tue, 26 May 2026 16:02:46 -0400 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wRxz8-0002u5-27; Tue, 26 May 2026 16:02:43 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 47A3F43515; Tue, 26 May 2026 20:02:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D49201F000E9; Tue, 26 May 2026 20:02:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779825759; bh=pGlSoLvSkWLWM09alJZgROZ3NJFIPwvSs1E7yFYC654=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=di+Fdfz4XoQ/QPnbPMlxcSA/NStguprg2514Elzv+645tTbBgaqssnsRigRHM2H7a 3RA8IvTnafVY8gi8gWLqyB6aPUQPs+fX+Vqa3EssWaUfUkvJbR3GKpoU8R6EoBSHn1 XlrLYD2AdibArCyU8pfXds+YwqSKz6mumPhqoxDNlBg4PKAwe8JaYnERAi0mvg78nm ChAY7/ZSYAx7fuEG9nLD+FhiSYWfh3g+/Ez/hYhekyW3L0XfsU8azPGcBfUo2Wu2pl Jh9o9Xrq2OJpFcSaRrC0u5KoCU6gNBwNLVN0w4G504MSDy8sxRRoX1AF381mMEAygS CeaG3kvku/Zaw== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , qemu-s390x@nongnu.org, Richard Henderson , Eric Farman , Matthew Rosato , Helge Deller , Aleksandar Rikalo , David Hildenbrand , Laurent Vivier , Cornelia Huck , Jiaxun Yang , Yoshinori Sato , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Aurelien Jarno Subject: [PULL 07/12] linux-user/s390x: restore fpu_status rounding mode from FPC on sigreturn Date: Tue, 26 May 2026 22:02:02 +0200 Message-ID: <20260526200207.79738-8-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526200207.79738-1-deller@kernel.org> References: <20260526200207.79738-1-deller@kernel.org> 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=2600:3c0a:e001:78e:0:1991:8:25; envelope-from=deller@kernel.org; helo=sea.source.kernel.org X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @kernel.org) X-ZM-MESSAGEID: 1779825855260154100 Content-Type: text/plain; charset="utf-8" From: Matt Turner QEMU keeps the s390x floating-point control register (FPC) in env->fpc. The rounding mode bits [2:0] of FPC are reflected into the derived env->fpu_status via set_float_rounding_mode(); every architectural write to FPC goes through HELPER(sfpc) which keeps the two in sync. restore_sigregs() restored FPC with a direct assignment: __get_user(env->fpc, &sc->fpregs.fpc); This wrote env->fpc correctly but never updated env->fpu_status, so on sigreturn the interrupted code resumed with whatever rounding mode the signal handler last installed in fpu_status. Factor the two-step "write fpc + sync fpu_status" logic out of HELPER(sfpc) into cpu_s390x_load_fpc(), declare it in cpu.h, and call it from restore_sigregs() in place of the direct assignment. cpu_s390x_load_fpc() partially reuses the sanity check from HELPER(sfpc): if the FPC value has an invalid rounding mode or reserved bits set, it falls back to 0, matching the kernel's fpu_lfpc_safe() behavior where a corrupt signal frame value causes a specification exception and 0 is used instead. HELPER(sfpc) now calls cpu_s390x_load_fpc() after its full specification-exception check, including the FEAT_FLOATING_POINT_EXT test that is not needed for the signal restore path. Fixes: 2941e0fa05 ("linux-user/s390x: Save/restore fpc when handling a sign= al") Cc: qemu-stable@nongnu.org Signed-off-by: Matt Turner Signed-off-by: Helge Deller --- linux-user/s390x/signal.c | 6 +++++- target/s390x/cpu.h | 1 + target/s390x/tcg/fpu_helper.c | 20 ++++++++++++++------ 3 files changed, 20 insertions(+), 7 deletions(-) diff --git a/linux-user/s390x/signal.c b/linux-user/s390x/signal.c index 96d1c8d11c..28ad80bde4 100644 --- a/linux-user/s390x/signal.c +++ b/linux-user/s390x/signal.c @@ -332,7 +332,11 @@ static void restore_sigregs(CPUS390XState *env, target= _sigregs *sc) for (i =3D 0; i < 16; i++) { __get_user(env->aregs[i], &sc->regs.acrs[i]); } - __get_user(env->fpc, &sc->fpregs.fpc); + { + uint32_t fpc; + __get_user(fpc, &sc->fpregs.fpc); + cpu_s390x_load_fpc(env, fpc); + } for (i =3D 0; i < 16; i++) { __get_user(*get_freg(env, i), &sc->fpregs.fprs[i]); } diff --git a/target/s390x/cpu.h b/target/s390x/cpu.h index 3acbe83f0f..f55b79ef8a 100644 --- a/target/s390x/cpu.h +++ b/target/s390x/cpu.h @@ -895,6 +895,7 @@ void s390_init_sigp(void); /* helper.c */ void s390_cpu_set_psw(CPUS390XState *env, uint64_t mask, uint64_t addr); uint64_t s390_cpu_get_psw_mask(CPUS390XState *env); +void cpu_s390x_load_fpc(CPUS390XState *env, uint32_t fpc); =20 /* outside of target/s390x/ */ S390CPU *s390_cpu_addr2state(uint16_t cpu_addr); diff --git a/target/s390x/tcg/fpu_helper.c b/target/s390x/tcg/fpu_helper.c index 6ca0b7162b..107025e675 100644 --- a/target/s390x/tcg/fpu_helper.c +++ b/target/s390x/tcg/fpu_helper.c @@ -1087,6 +1087,19 @@ static const int fpc_to_rnd[8] =3D { float_round_to_odd, }; =20 +void cpu_s390x_load_fpc(CPUS390XState *env, uint32_t fpc) +{ + /* + * Mimic kernel fpu_lfpc_safe(): a corrupt signal frame value that wou= ld + * trigger a specification exception instead results in FPC being set = to 0. + */ + if (fpc_to_rnd[fpc & 0x7] =3D=3D -1 || fpc & 0x03030088u) { + fpc =3D 0; + } + env->fpc =3D fpc; + set_float_rounding_mode(fpc_to_rnd[fpc & 0x7], &env->fpu_status); +} + /* set fpc */ void HELPER(sfpc)(CPUS390XState *env, uint64_t fpc) { @@ -1094,12 +1107,7 @@ void HELPER(sfpc)(CPUS390XState *env, uint64_t fpc) (!s390_has_feat(S390_FEAT_FLOATING_POINT_EXT) && fpc & 0x4)) { tcg_s390_program_interrupt(env, PGM_SPECIFICATION, GETPC()); } - - /* Install everything in the main FPC. */ - env->fpc =3D fpc; - - /* Install the rounding mode in the shadow fpu_status. */ - set_float_rounding_mode(fpc_to_rnd[fpc & 0x7], &env->fpu_status); + cpu_s390x_load_fpc(env, fpc); } =20 /* set fpc and signal */ --=20 2.54.0 From nobody Sat May 30 17:43:39 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1779825855; cv=none; d=zohomail.com; s=zohoarc; b=Y5/awCpx/DHotea89+fBYrfRCO26SHNkDIwb1u9ePMUJ1oqpMCknn9L+0kdHo9N2JKn/3tZghFHd7rs7nZhV4p3k0HmRXMZEKCPcuCslw5lvLtljyrlmQOhdjq1XELe/lQRbY6Y+2tFznmdgNYI2PYIqmzZGU/f/a82JVc1DbSk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779825855; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RzAg/z9ESTOIfX4D/3KjFmD6FehyVHYLgvenUfGbwos=; b=dixN68dDrCfch0pj5cUw5Z7mAth5VW9DNZe06GsguogjZb0IyI+/d4PU1twSQPJHIP2s52ghWDKToNSkf8PA4azLza68Yfw1MYu0nAndhD/JBomoBG6Wpi8XlX6sM06CmYO8AsFlwuAkS3v2CSWvjZrgFAmN3U6DX7gOhm3nD6g= 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 1779825855322425.18785015544086; Tue, 26 May 2026 13:04:15 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRxzN-0004fX-Ro; Tue, 26 May 2026 16:02:57 -0400 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 1wRxzD-0004aQ-AR; Tue, 26 May 2026 16:02:48 -0400 Received: from tor.source.kernel.org ([172.105.4.254]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wRxzB-0002uj-2X; Tue, 26 May 2026 16:02:46 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 85345600BB; Tue, 26 May 2026 20:02:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EF7D1F00A3A; Tue, 26 May 2026 20:02:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779825763; bh=RzAg/z9ESTOIfX4D/3KjFmD6FehyVHYLgvenUfGbwos=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=bFVSGT0p3vp1zsu57dh1SnVsbg3pitv8OorYKKedhy0uyuJnAHrom2cCtWbbCaSyp T/eLNOdnQAYfcRCQyxfy48pPoiPzzYEChHgi8Q8mnLgPfCFY5tCL7gKIGpLiHNSntn FizcZ97uvORQGWlfYJYvfGqqEBIEF2GKkeTlyCQYLmGjrJyz02wl1Hy9icCcDcDGtF 4igvePFvYumLl08JP6rWYNcC3PcUip19OmhE1YsQqmwf+vtF9sKUxG123TQBIDX/0+ f0vQ1H2KZTuQ1WW/YrUnIaNee6AlT/AuFgrPoulxk2fK2iRPteyQh+2E+9zVEeGRr2 XTEgVegP/xLzQ== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , qemu-s390x@nongnu.org, Richard Henderson , Eric Farman , Matthew Rosato , Helge Deller , Aleksandar Rikalo , David Hildenbrand , Laurent Vivier , Cornelia Huck , Jiaxun Yang , Yoshinori Sato , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Aurelien Jarno Subject: [PULL 08/12] linux-user: Implement finer grained madivse() syscall Date: Tue, 26 May 2026 22:02:03 +0200 Message-ID: <20260526200207.79738-9-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526200207.79738-1-deller@kernel.org> References: <20260526200207.79738-1-deller@kernel.org> 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=172.105.4.254; envelope-from=deller@kernel.org; helo=tor.source.kernel.org X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @kernel.org) X-ZM-MESSAGEID: 1779825857061158500 Content-Type: text/plain; charset="utf-8" From: Helge Deller Although most madvise() values are hints, some are important and are checked by userspace, especially by security-relevant applications like BoringSLL. So, return -EINVAL for those functions which we don't emulate. Signed-off-by: Helge Deller Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/3489 --- linux-user/mmap.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/linux-user/mmap.c b/linux-user/mmap.c index b4b7b3e5cc..50916c29a5 100644 --- a/linux-user/mmap.c +++ b/linux-user/mmap.c @@ -1282,7 +1282,7 @@ abi_long target_madvise(abi_ulong start, abi_ulong le= n_in, int advice) case TARGET_MADV_KEEPONFORK: /* parisc */ advice =3D MADV_KEEPONFORK; break; - /* we do not care about the other MADV_xxx values yet */ + /* all other MADV_xxx values are the same across architectures */ } =20 /* @@ -1307,6 +1307,19 @@ abi_long target_madvise(abi_ulong start, abi_ulong l= en_in, int advice) */ mmap_lock(); switch (advice) { + case MADV_NORMAL: + case MADV_RANDOM: + case MADV_SEQUENTIAL: + case MADV_WILLNEED: + case MADV_DOFORK: + case MADV_FREE: + case MADV_COLD: + case MADV_PAGEOUT: + ret =3D 0; /* OK */ + break; + case MADV_REMOVE: + ret =3D -EOPNOTSUPP; + break; case MADV_DONTDUMP: page_set_flags(start, start + len - 1, PAGE_DONTDUMP, 0); break; @@ -1324,6 +1337,23 @@ abi_long target_madvise(abi_ulong start, abi_ulong l= en_in, int advice) page_reset_target_data(start, start + len - 1); } } + break; + case MADV_DONTFORK: + case MADV_MERGEABLE: + case MADV_UNMERGEABLE: + case MADV_HWPOISON: + case MADV_HUGEPAGE: + case MADV_NOHUGEPAGE: + case MADV_COLLAPSE: + case MADV_POPULATE_READ: + case MADV_POPULATE_WRITE: + case -1: /* BoringSSL uses -1 to check if the environment is broken= */ + ret =3D -EINVAL; + break; + default: + qemu_log_mask(LOG_UNIMP, "Unhandled madvise(%d) call.\n", advice); + ret =3D -EINVAL; /* not yet known advise */ + break; } mmap_unlock(); =20 --=20 2.54.0 From nobody Sat May 30 17:43:39 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1779825857; cv=none; d=zohomail.com; s=zohoarc; b=IJrhkYZhcat/FGAg/PCn+xQjxW2j2O+lmQNZkBVolkvjwt0GdbgTcPknJR0b1CdxHWJeX1SFNdYDy0cU3xYV0aoCoTJtmlRYkW/cyhyTmFXiUMXIrQIFLtNhKnC3nvQbIqfxzIaXBOjVb1nM9kstJeCnTSNV2Pbl2ObJSMYLgR8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779825857; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=C6sVTMGfaU3enExNWt9KUDNtvH2iTrHHDQG1z3ZZxHI=; b=jAhppA46Z7uLtD44q64uzOXPJbk0hmQ0LVc/COY4UoorSxUiu8gxfW+cDKmlPspFx5VR/CCrnTxvStZh4gNHrUsyUTaP/rf5/4xtdp3rMjZ8yMXWouqGy4D2vGz8qLZ2s2EdpdMDhO71/4UNt9keAx3NZ9OWvpkBXSmPo2E3p7U= 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 1779825857064995.5650025143484; Tue, 26 May 2026 13:04:17 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRxzK-0004dL-KL; Tue, 26 May 2026 16:02:54 -0400 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 1wRxzF-0004at-MS; Tue, 26 May 2026 16:02:50 -0400 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wRxzE-0002vL-2Y; Tue, 26 May 2026 16:02:49 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id CEAFF403B6; Tue, 26 May 2026 20:02:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 68A1F1F00A3E; Tue, 26 May 2026 20:02:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779825766; bh=C6sVTMGfaU3enExNWt9KUDNtvH2iTrHHDQG1z3ZZxHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AAh6ydRefl/bYGaAYTncsoCg4aIsxV9SJKWVIFZ90Z8UIM52kHQLDEnOfmKs5yF/M X/swpnhR4klC99rL9usydksot6TLrCIb8igMYmkmJ6C3pkI5iOwRFTwcdLH/HoB0Jy YqPGy9WuWnJHw7rAEWsp1kHJxhgWdPGLkFsTZEYFbHqqyN9zmjRRt/LNuFkMVvSrzt ATEVFx7Q4MNklN0Shrsx3JgWjVjfMoVdvTNSzMoeQx0//j3Y69O1VMUFmrrPbv7yQI NX5dUFK3NcAF+f4h6AjzcujprZKWCBCCs3xVdJeoOi3eX5aZzxdOtqMKZjI3EotgcD vdj6LvuQvpj5w== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , qemu-s390x@nongnu.org, Richard Henderson , Eric Farman , Matthew Rosato , Helge Deller , Aleksandar Rikalo , David Hildenbrand , Laurent Vivier , Cornelia Huck , Jiaxun Yang , Yoshinori Sato , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Aurelien Jarno Subject: [PULL 09/12] linux-user: Fix typo in function documentation for pgb_addr_set() Date: Tue, 26 May 2026 22:02:04 +0200 Message-ID: <20260526200207.79738-10-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526200207.79738-1-deller@kernel.org> References: <20260526200207.79738-1-deller@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=2600:3c0a:e001:78e:0:1991:8:25; envelope-from=deller@kernel.org; helo=sea.source.kernel.org X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @kernel.org) X-ZM-MESSAGEID: 1779825858907154100 From: Helge Deller The third parameter is called guest_hiaddr. Reviewed-by: Peter Maydell Reviewed-by: Alex Benn=C3=A9e Signed-off-by: Helge Deller --- linux-user/elfload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index 0e757787d2..f7625c0952 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -848,7 +848,7 @@ static bool pgb_try_mmap_set(const PGBAddrs *ga, uintpt= r_t base, uintptr_t brk) * pgb_addr_set: * @ga: output set of guest addrs * @guest_loaddr: guest image low address - * @guest_loaddr: guest image high address + * @guest_hiaddr: guest image high address * @identity: create for identity mapping * * Fill in @ga with the image, COMMPAGE and NULL page. --=20 2.54.0 From nobody Sat May 30 17:43:39 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1779825901; cv=none; d=zohomail.com; s=zohoarc; b=cF+9vCA1COM5v0dYt9k/kgKRJE+2F8R3oQ4/98oHprH8mwwE7FytJ1JT1LTYhyln0BZ2ceoL/MmpRgkPMuFLPNdj55RRvOoWGge62lhJKa7ogk/72kazotOxXABljo3Wx0J6IAOtsa1CA8DbQzb4IEwmvdlyom+8GJbIhFJg6PU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779825901; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=YmDrG2TezwoliurUbxDzBvTiekL3RGYCv9IQwkBdxx8=; b=RRpGBHkn1LyuxH1BNI+z7slWtIU2vwgc6oaOg7NxbH87LXn1kJk24Vh4Ma1FbHCL6AOi6LU5WEIzyrseA8P7LO+UnIEkDXybWRJTBpX3ff5P+Cq3R5ibRfkqKjlxobAZTHNGHRJQ6+cDrW4AsWivYoSbAPs2zvmKFl+CRGS5D4Q= 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 1779825901843216.14280622581782; Tue, 26 May 2026 13:05:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRxzO-0004fg-1x; Tue, 26 May 2026 16:02:58 -0400 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 1wRxzJ-0004cr-SL; Tue, 26 May 2026 16:02:53 -0400 Received: from sea.source.kernel.org ([2600:3c0a:e001:78e:0:1991:8:25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wRxzI-0002w9-6I; Tue, 26 May 2026 16:02:53 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 97C71435E4; Tue, 26 May 2026 20:02:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31E7E1F000E9; Tue, 26 May 2026 20:02:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779825770; bh=YmDrG2TezwoliurUbxDzBvTiekL3RGYCv9IQwkBdxx8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=lAxeD6juO2NsXMXVeQZB6AGPFrH8DbmKyp0k609gf2iib1RJjWxS+yF3zFCRcipdg Ys4g9EtQzEZlPL+hkSBolDCmihupfiFdDCYBd2BZuvnl+Y9Ii7d3qF/EUYq0HKFQhA +kZAbfJN71J1aZc5WZZpIqfREJ+dQsp4etyp+U+CjKc8ADx5tNhXaA+u6cwJc5DS1f pxLtuaHBc4r/XOWlUKT8Tmu+PFd5L63+bBJSGakEtA4Dpu9lxH0hexzwd2VSEOe66I nB7xZpGk6/8lhgrrgfDgmmU+TPzNzWqZzYB6DJD07ZIRPBMvdY7wKoY20kVBwLKQbr 2aRaFoW1Wb0cQ== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , qemu-s390x@nongnu.org, Richard Henderson , Eric Farman , Matthew Rosato , Helge Deller , Aleksandar Rikalo , David Hildenbrand , Laurent Vivier , Cornelia Huck , Jiaxun Yang , Yoshinori Sato , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Aurelien Jarno Subject: [PULL 10/12] linux-user: Fix loading static ARM cortex-m55 binaries Date: Tue, 26 May 2026 22:02:05 +0200 Message-ID: <20260526200207.79738-11-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526200207.79738-1-deller@kernel.org> References: <20260526200207.79738-1-deller@kernel.org> 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=2600:3c0a:e001:78e:0:1991:8:25; envelope-from=deller@kernel.org; helo=sea.source.kernel.org X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @kernel.org) X-ZM-MESSAGEID: 1779825903271158500 Content-Type: text/plain; charset="utf-8" From: Helge Deller Static built ARM binaries for Cortex-m55 may have been linked to have their load address at address 0 (because they are effectively a bare-metal image). When qemu-user is running as non-root user and will try to mmap() a host address at 0 (which is smaller than mmap_min_addr according to /proc/sys/vm/mmap_min_addr), it will fail with EPERM and as such loading those guest program will fail. Fix pgb_addr_set() to always return false if the guest_loaddr < mmap_min_addr, that way a valdid guest_base address will be calculated and the EPERM can be avoided. Signed-off-by: Helge Deller Suggested-by: Peter Maydell Resolves: https://gitlab.com/qemu-project/qemu/-/work_items/1890 --- linux-user/elfload.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux-user/elfload.c b/linux-user/elfload.c index f7625c0952..62f12e4149 100644 --- a/linux-user/elfload.c +++ b/linux-user/elfload.c @@ -866,7 +866,7 @@ static bool pgb_addr_set(PGBAddrs *ga, abi_ulong guest_= loaddr, if (LO_COMMPAGE !=3D -1 && LO_COMMPAGE < mmap_min_addr) { return false; } - if (guest_loaddr !=3D 0 && guest_loaddr < mmap_min_addr) { + if (guest_loaddr < mmap_min_addr) { return false; } } --=20 2.54.0 From nobody Sat May 30 17:43:39 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1779825883; cv=none; d=zohomail.com; s=zohoarc; b=hO4fm44OcCzzzI8mrlx+AIrzKd6z5/n8HbVcBCgMm9JCt7+3TuSKobiVbmqSUYI8K6R9/WfW/PornzlI0JIAE4GmUgUkt8TITjcFl46T9vKkU3yaSClczUlO22FnMq7p5qAAgD8u833bYLRCeIIy/WIoGfXJadFeJasw3vYDCso= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779825883; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Cw9b2yaVekAwr8cSAaU3u13HS5WHaa+YXcm5rfw6fPc=; b=CWYbJguC73VciIbZ27EHGF4mCt5Y+9V9AeU21wJA18s/Udxedg6owjKIh1c1BSJ5NG8L1umilxx07t3zAihZ/xVlj0h5th6bUB6Ck5DkuDcGunyMxUCUTzhiwRvy0aDox8QWlzZREPhB1AWbIJmLnOB8t35jPdISaTdf4mKET2s= 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 177982588367074.50070223606997; Tue, 26 May 2026 13:04:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRxzQ-0004go-BU; Tue, 26 May 2026 16:03:00 -0400 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 1wRxzN-0004fP-Bl; Tue, 26 May 2026 16:02:57 -0400 Received: from tor.source.kernel.org ([2600:3c04:e001:324:0:1991:8:25]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wRxzL-0002wj-Li; Tue, 26 May 2026 16:02:57 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 8F45A600AB; Tue, 26 May 2026 20:02:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEFF41F000E9; Tue, 26 May 2026 20:02:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779825774; bh=Cw9b2yaVekAwr8cSAaU3u13HS5WHaa+YXcm5rfw6fPc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=KRNRrNOyxDPCO1AY07perfJbVP6xzjjkJer/86as17vkC+UNWqHGJTGk6d81IX9n7 bVdD+asFguL5TH69r7SIRWDC6aINnNozdMLa0tD1eyWHSx8P57PHS5uIzBrr1oi0yi dT/ep00jGriX85P9nsHqTK5w9tFhMlKZQoT3Q1JKycV/TwntsLaU0cTReGuxpefTTh XbiRpca7fNSU0m/busZn1GMQpXv8QoQ61Gcz8YXYoBFcuMYtOSpNAIjfZAwRWPu6jf SUjF7C+56s1j0NlFqvDpbUoDelDR3Xu0Qpo4u/8FGTjepmkjXhZJ1ldQSuxeROuD/2 nEMP6KRWlLK3Q== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , qemu-s390x@nongnu.org, Richard Henderson , Eric Farman , Matthew Rosato , Helge Deller , Aleksandar Rikalo , David Hildenbrand , Laurent Vivier , Cornelia Huck , Jiaxun Yang , Yoshinori Sato , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Aurelien Jarno Subject: [PULL 11/12] linux-user: Move init_main_thread() prototype to user-internals.h Date: Tue, 26 May 2026 22:02:06 +0200 Message-ID: <20260526200207.79738-12-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526200207.79738-1-deller@kernel.org> References: <20260526200207.79738-1-deller@kernel.org> 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=2600:3c04:e001:324:0:1991:8:25; envelope-from=deller@kernel.org; helo=tor.source.kernel.org X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @kernel.org) X-ZM-MESSAGEID: 1779825885139158500 Content-Type: text/plain; charset="utf-8" From: Peter Maydell The init_main_thread() prototype is needed only by code internal to linux-user/, so it doesn't need to be in qemu.h (which is also pulled in by various files outside linux-user/). Move the prototype to user-internals.h, and give it a documentation comment. Signed-off-by: Peter Maydell Reviewed-by: Helge Deller Signed-off-by: Helge Deller --- linux-user/qemu.h | 2 -- linux-user/user-internals.h | 15 +++++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 7f98fb2607..474489f046 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -371,6 +371,4 @@ void *lock_user_string(abi_ulong guest_addr); /* Clone cpu state */ CPUArchState *cpu_copy(CPUArchState *env); =20 -void init_main_thread(CPUState *cs, struct image_info *info); - #endif /* QEMU_H */ diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h index 21daf422b7..fbfd12237f 100644 --- a/linux-user/user-internals.h +++ b/linux-user/user-internals.h @@ -194,6 +194,21 @@ static inline void begin_parallel_context(CPUState *cs) } } =20 +/** + * init_main_thread: Set CPU state for main thread + * @cs: CPU context to set + * @info: information about the image being loaded + * + * This function must be provided by the per-target code. It should + * set the initial CPU state based on the information about the + * starting binary in @image_info. This will be at a minimum setting + * the initial guest program counter and stack pointer; it should + * also set up any other guest register values where the Linux ABI + * defines that they start set to some other value than what the + * guest CPU architecture gives you out of reset. + */ +void init_main_thread(CPUState *cs, struct image_info *info); + /* * Include target-specific struct and function definitions; * they may need access to the target-independent structures --=20 2.54.0 From nobody Sat May 30 17:43:39 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1779825832; cv=none; d=zohomail.com; s=zohoarc; b=Vov0vdeVb7F0YnPbLNz4S4jFAlPwSC2SUAhprud/R71YGsgg4BITU43/AhOSSCK34Qvk1DmxRvZJzzhIfG3L06f0PLBQNVqgAy6tKoqxibCDA09pTzlAdJFRxiQ14Yl6l4XocTRhjQAevTz1vBYMGjx/kThwj+L4vNHiWbyEbfw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779825832; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=E8bOW7It6eBbYAycvmoXErdMpix7xPsPMO3AvIAjmOg=; b=M4XwFFpuibXwwEDqVRMOaWQSx+3myB4oPSgccbNi8Mc6N3PfE2VAnFgvBNAB8A5A/Y9b8zYNGXLqgtdYL+vdGirJ4uUuns8C99O48WTeUWClfIVrvllfsQXx/MCq0QLlh5RU/CrLmaA6ULPr7olKbvCr7ux1uF1ebW96MkEcfGU= 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 1779825832297662.0388435281989; Tue, 26 May 2026 13:03:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRxzS-0004hn-Ls; Tue, 26 May 2026 16:03:02 -0400 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 1wRxzR-0004hJ-21; Tue, 26 May 2026 16:03:01 -0400 Received: from sea.source.kernel.org ([172.234.252.31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wRxzP-00030K-DE; Tue, 26 May 2026 16:03:00 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 2D46D41708; Tue, 26 May 2026 20:02:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BA1411F000E9; Tue, 26 May 2026 20:02:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779825778; bh=E8bOW7It6eBbYAycvmoXErdMpix7xPsPMO3AvIAjmOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BPWhZ+rBUB/m6AHLp1ggykh736Ted4ybZQO5OqvIHDgIZGTk0tle+/t8JgBOVMjHM I+3l33BxLp5l2vxbCItweMZo79bPl5nRcVmTLbPvlOMatCuFnH46qAdi1AnzcbK0yP AUrEZbE/7BGUEpyIirzLsXW+QJvQEAh81C9v/XA4w0uTcNKvHmiV94uEEMJiPlgmm2 2wtaRpsUTN8ZVkUhPXHa7Ss/xNyn2ZDeVhcVRNvlDtspE10O0eW5mk8MibvIZNaajA PdzOg8h0UGZ9lxJ+IrXmGqK076pM5Ip4bcMg/h9wWJYuma+HAmHxOFE4W2gBpINIqX IB/Kim62iKwFQ== From: Helge Deller To: qemu-devel@nongnu.org Cc: Pierrick Bouvier , qemu-s390x@nongnu.org, Richard Henderson , Eric Farman , Matthew Rosato , Helge Deller , Aleksandar Rikalo , David Hildenbrand , Laurent Vivier , Cornelia Huck , Jiaxun Yang , Yoshinori Sato , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ilya Leoshkevich , Aurelien Jarno Subject: [PULL 12/12] linux-user: Move cpu_copy() to user-internals.h Date: Tue, 26 May 2026 22:02:07 +0200 Message-ID: <20260526200207.79738-13-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526200207.79738-1-deller@kernel.org> References: <20260526200207.79738-1-deller@kernel.org> 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=172.234.252.31; envelope-from=deller@kernel.org; helo=sea.source.kernel.org X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.445, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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 @kernel.org) X-ZM-MESSAGEID: 1779825835387158500 Content-Type: text/plain; charset="utf-8" From: Peter Maydell We only use cpu_copy() inside linux-user, so we don't need to have the prototype in qemu.h available to code outside linux-user; move it to user-internals.h. Signed-off-by: Peter Maydell Reviewed-by: Helge Deller Signed-off-by: Helge Deller --- linux-user/qemu.h | 3 --- linux-user/user-internals.h | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index 474489f046..07fe801628 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -368,7 +368,4 @@ void *lock_user_string(abi_ulong guest_addr); #define unlock_user_struct(host_ptr, guest_addr, copy) \ unlock_user(host_ptr, guest_addr, (copy) ? sizeof(*host_ptr) : 0) =20 -/* Clone cpu state */ -CPUArchState *cpu_copy(CPUArchState *env); - #endif /* QEMU_H */ diff --git a/linux-user/user-internals.h b/linux-user/user-internals.h index fbfd12237f..0380d44fe9 100644 --- a/linux-user/user-internals.h +++ b/linux-user/user-internals.h @@ -209,6 +209,9 @@ static inline void begin_parallel_context(CPUState *cs) */ void init_main_thread(CPUState *cs, struct image_info *info); =20 +/* Clone cpu state */ +CPUArchState *cpu_copy(CPUArchState *env); + /* * Include target-specific struct and function definitions; * they may need access to the target-independent structures --=20 2.54.0