From nobody Sat May 30 17:43:37 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=1779822380; cv=none; d=zohomail.com; s=zohoarc; b=DeQuMOoL+WNHRMQWxKgshZuKlxgdE4+82ZGFK9lTZNT6FgMqV2gnhoRb+/yL0X0+1pbSzhQXSH4DPmV0JMLHMzU7/sC0rUsKd6vUCWnp7lwdebNOwrNiGiUAuo6bzymwFKZFH/kpWSS2XE6XO+z2TwzOeR13ZEpozFR2MEbLh3Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779822380; 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=KptzzIHqODmXFZcUkF0CN3AOYXzrhunpxQEUYac88Z+QXC5nhFTJ4ZQMbvoiNLXKqO+Tx/WyDKa9trLmsPrhNsXRbva1MBn+Dr7TB/Oe1nW4/eC0GT/mE/mQO5PGRIFqJxkmgqHgXVtFqfFat6PLSLRJRhDXwxXgIYXbpwTlzs4= 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 1779822380338721.9793653609406; Tue, 26 May 2026 12:06:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRx68-0000Kr-QL; Tue, 26 May 2026 15:05: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 1wRx63-0000K3-Uy; Tue, 26 May 2026 15:05:47 -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 1wRx62-0004Ym-53; Tue, 26 May 2026 15:05:47 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 30FC143785; Tue, 26 May 2026 19:05:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C233B1F000E9; Tue, 26 May 2026 19:05:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779822344; bh=nvntSM18afV4ztUV6noHKCwxuAwGyr+1Agibouoa9Q8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=hDbwH6PJzI2A13sajbmLOdOiOKqBEvaaENUoQ2MplRDZYQaOXFL3B8OCFL1YCiTFC WpG0pBT+dnsJswutWxfIRQB/aNuo+1Xy3FrimRdEo6cG+3sD1LdLKGPYSB0ntzoq96 WtSBWan5SClbQM4d7PCTlRifatNl14LEfSP+Eeyn/t2m9OPWZEMq96BbgXBnk/8XQA PIP+Z50igjvlP8mQjXXF9lzJAEfVDIggCn1wsQt468QyKa3BQenyFdLzTF35/eRXAC UZELFA//jxeS99NvDCxSxhseatjrC505ECilARI84fx+qWpBhiz8Jb3m8P1lEbxG1X JpetaIqZihbYw== From: Helge Deller To: qemu-devel@nongnu.org Cc: Cornelia Huck , Laurent Vivier , Aurelien Jarno , Helge Deller , Richard Henderson , Eric Farman , Jiaxun Yang , Aleksandar Rikalo , Ilya Leoshkevich , Matthew Rosato , Yoshinori Sato , Pierrick Bouvier , qemu-s390x@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Hildenbrand Subject: [PATCH 01/12] linux-user/ppc: restore fp_status from FPSCR on sigreturn Date: Tue, 26 May 2026 21:05:24 +0200 Message-ID: <20260526190535.10833-2-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526190535.10833-1-deller@kernel.org> References: <20260526190535.10833-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: 1779822382778158500 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:37 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=1779822400; cv=none; d=zohomail.com; s=zohoarc; b=XKctOyYmSWE3JRXuUaqQZyHcbJ2+0DT2Jiu4gBEmXE33Xxsvu3SztskifDauSB1a7mhSdd3fBru+ZlRdjrlVAkFT0a6I3tJwE2UtHOoqlxkilEtsDw0sb9zeRTrrHQe5SQelHNGcksXfMRZkrpCa3OsW5MkCcayicKfyWzMnTTI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779822400; 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=K4Tg6iZQUEudPSFucfgr9w2xeMrkfCMSONvnyQ0EqTrth64SA9XT0uT4lHsDtjhEIjdW2BRiOgqA+enmezRkEU0xpl9bewlgAXg5HHzNSqRvihm7IfJaH/Vz5NjKI9usvbaQBjzJ4pNJrIzRu+dj+YwaeZQcYBSkuAqD3VDdaIM= 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 1779822400732234.0431540930274; Tue, 26 May 2026 12:06:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRx6H-0000LT-7U; Tue, 26 May 2026 15:06:04 -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 1wRx67-0000Kk-ED; Tue, 26 May 2026 15:05:51 -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 1wRx65-0004Zx-TS; Tue, 26 May 2026 15:05:51 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id A56E9600C3; Tue, 26 May 2026 19:05:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 873531F000E9; Tue, 26 May 2026 19:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779822347; bh=RL/zGi1pDp8yTNmI8IAlrRDAo9DD/BZhQK5MCrsVinw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AExbJ3M5lZsidIVUfa8PNzQDQasBx1nwdKbO0j99/VtuoHrjP4E60NvcVDqH1bNRE SlTi68109/0ZbANnV/Y+KGUvnYC9PSjJsh2zZypDCQHNbr8ivWPSA8x5kC57AhZR5M k7jTNMnbWWSiMLdlQHrBQHFHLP+mNVf1xlz4khq0QouC4eJXZZKBBh75yw62MkjkxQ 0PKzh9Ghfv9/biirLKkHC/08VunKY7N2QQFbTEFZBW7IgFPngYb0+Va/k3hmMGKWkS eI2h4OJKw9kFuD32PSrKfkkFGyMHsqV9/g+mN9CwB7zylyoxHgMp1qHATYpIeXTzq2 xvOXZqXZJC2/Q== From: Helge Deller To: qemu-devel@nongnu.org Cc: Cornelia Huck , Laurent Vivier , Aurelien Jarno , Helge Deller , Richard Henderson , Eric Farman , Jiaxun Yang , Aleksandar Rikalo , Ilya Leoshkevich , Matthew Rosato , Yoshinori Sato , Pierrick Bouvier , qemu-s390x@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Hildenbrand Subject: [PATCH 02/12] linux-user/mips: save/restore FCSR across signal delivery Date: Tue, 26 May 2026 21:05:25 +0200 Message-ID: <20260526190535.10833-3-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526190535.10833-1-deller@kernel.org> References: <20260526190535.10833-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: 1779822404495154100 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:37 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=1779822481; cv=none; d=zohomail.com; s=zohoarc; b=fiTLPPWq3Z0KVBp0+kv3/b7hPADBdejjG/MY4w9HnAd+r4TXTccoKYAnLO5xz97ndQZVDoK506IsjyrJ4Xrcl4UkpEaUPF6NdAYTbHrEQpakirYlUcQw2DU3QmsbYEggUEvgqKdlFq0t3IgI0xhLsy5tFh2r/kHprN4QYe6gi6Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779822481; 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=gbhSIB+8uU29DfCwxJMX+M01ai2aolmPiD4pGKTYUNE/8+Zt8YOpdr/cEr3Na6J5g4OBhHTvK23hY4MlfV7i7cMs4X1qC9jaqAUB2Za1+6jFQ4mnJ4gu9MRRdN3zrlIvlGrYycwKBH7PHRrnTkm7I0cijI2aG1IxBu/NTfkuLKE= 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 1779822481388186.01723274573578; Tue, 26 May 2026 12:08:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRx6a-0000RV-3r; Tue, 26 May 2026 15:06:20 -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 1wRx6B-0000Lf-SX; Tue, 26 May 2026 15:06:00 -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 1wRx69-0004aF-UM; Tue, 26 May 2026 15:05:55 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 2A6CE600FC; Tue, 26 May 2026 19:05:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DF001F00A3D; Tue, 26 May 2026 19:05:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779822351; bh=czHWASgcVRX6WqaAi+3O59ynkEQ7PMLnAzM69Hv53hg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=AbdGoW0S8LIcfA7uGNT7nWEgtOCmBTB5M0h7QbqGbg0zM1kvsSEmW/ezmy0A4Fz+j 9xnrKvh8VYZDThG2UZg1oQAX9qRCt4JxephX/67+3MfNF7SMGNqK0TvX3SzXIkGftF hsZ4sS4Smk/ThslqqiQpr6PS09P00MwDPHTMoYs8/FNHHQLqdHJ9GAviNw4WFRyR+e MZMtCrxmb9YHmyfIBNEfAI3y9FHF6qu/8rI8JI/To2kKzKb7hIvJs8p5sncbTaT+fH r4G60E5cZQ/lzML/8qqA6HTW557fPLjmNH0jE0JYmRn0QdI35KgzB5tRgEpN7X9QNv 0C4oKm7WDx7dw== From: Helge Deller To: qemu-devel@nongnu.org Cc: Cornelia Huck , Laurent Vivier , Aurelien Jarno , Helge Deller , Richard Henderson , Eric Farman , Jiaxun Yang , Aleksandar Rikalo , Ilya Leoshkevich , Matthew Rosato , Yoshinori Sato , Pierrick Bouvier , qemu-s390x@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Hildenbrand Subject: [PATCH 03/12] linux-user/alpha: add coredump support Date: Tue, 26 May 2026 21:05:26 +0200 Message-ID: <20260526190535.10833-4-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526190535.10833-1-deller@kernel.org> References: <20260526190535.10833-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: 1779822482850158500 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:37 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=1779822455; cv=none; d=zohomail.com; s=zohoarc; b=N5NwO6PNsXz700ChSEehzCsWm6+aP1GbzLB+UIBYb2lF6In691p9tPu1pqVmMHwe3nponfMi+EwFw5sCfAwhJ5KndnVUFyZ7F40n3qjJbUrUdNyOdtQ3voeauptjh+TwzOdV5UsFPkUc2c5MFEGM8vSH4jEmnUBM24zajX2qPiY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779822455; 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=eouVx5OWqH/0mpkCA71ETYgBIJCfW/OPAX3QznzaMNWym9yb8A3hucv3fnNtYOj1hJqct6sFp5HoeQ5OvQtDMb1Z2XYm1IPByfePg0MPslqV6ASzfWXIeT92N4e13FdLRwXhPV7mO9eIo30fFWTo26Y8HtpPYJsZtESdnhkh+kA= 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 1779822455023838.1081729534176; Tue, 26 May 2026 12:07:35 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRx6c-0000Us-3T; Tue, 26 May 2026 15:06:22 -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 1wRx6F-0000M3-8r; Tue, 26 May 2026 15:06:01 -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 1wRx6D-0004ba-Ma; Tue, 26 May 2026 15:05:59 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id A6A6C600AB; Tue, 26 May 2026 19:05:55 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 161181F000E9; Tue, 26 May 2026 19:05:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779822355; bh=2NUQ5FfWOGem1CUHXmWxzCYzWNN2B5soNsg/vFqDPfI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oGokoU6WBrdDSTBX5HduQ3NU8nI/7EohgU/Lye8N4/gDGGBunFmn4M5idzSl9SBnq nuX0cUWd3HD+A6jZUn7fTvEzRtKnDUYb9PtNiPzGCLKkU2FFPxwgjbFkbmVat1tkqe Y3nJ2mTG7+i3P8SIVON/F/AfcvaLDC+xIAppgbtt8vKgzHf0Nj7Fb1WB6huiPaxCXE 8kogdgyZum0l3nDh1H9dXjy5XEag9/AQOJmBMsKJHaHT+B5cC7uTX0xS8xW3CWvPtj X+6tdLa0oaSLb9kpbf15//A6mTRlIBnhLfpb7W/nQcnWL82QeyQuIf0GgqUp4Xc77e SGXhy/ZoOurHA== From: Helge Deller To: qemu-devel@nongnu.org Cc: Cornelia Huck , Laurent Vivier , Aurelien Jarno , Helge Deller , Richard Henderson , Eric Farman , Jiaxun Yang , Aleksandar Rikalo , Ilya Leoshkevich , Matthew Rosato , Yoshinori Sato , Pierrick Bouvier , qemu-s390x@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Hildenbrand Subject: [PATCH 04/12] linux-user/sh4: preserve T/M/Q bits across signal delivery Date: Tue, 26 May 2026 21:05:27 +0200 Message-ID: <20260526190535.10833-5-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526190535.10833-1-deller@kernel.org> References: <20260526190535.10833-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: 1779822456870154100 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:37 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=1779822451; cv=none; d=zohomail.com; s=zohoarc; b=nPE+RAn9FeGLj62EKvaT71tROjRVRd2H2le8ZiURLsq5XTUWNKnE0q1i4r1r5tNhS8wnI1NYkxX+EwNC+N57/mjT0LzArIF6YXYuy1ixdvPIrq302JMZWjS81khCg3r7GHdkSZAZBTC3CjvwS89N56UCgB2+3UKa/ZyRa5cvtAM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779822451; 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=IJa1fKFqhL/tTBixAneWdMJEX3IApxVelJj4NfVbUr6ow6sxAIx1I71xBUuSJToLUDtousU0ZRNFlAkuQ2OEAn7cRrCl2DqRAwkIBhMeo6ZF2EoxOjflT+Z8WObfGJ0Kw/gC01Fl09Dk/iNvBuGOMtxw0/kZcC9QW0COrJU/Du0= 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 1779822451817221.13713677310034; Tue, 26 May 2026 12:07:31 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRx6d-0000W5-29; Tue, 26 May 2026 15:06:23 -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 1wRx6I-0000Mb-2W; Tue, 26 May 2026 15:06:06 -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 1wRx6G-0004dm-Dq; Tue, 26 May 2026 15:06:01 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 41A2D42AE9; Tue, 26 May 2026 19:05:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D19D51F00A3A; Tue, 26 May 2026 19:05:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779822359; bh=0dQnwUFE5S5dYS/jm+p+iJZyIvrikm45NzygrKgjVW0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Gh1SmD3bkhkgwI3nS+xCmNo3TjXk3lIogOtfsFd3AEjyjem3rYFgJWkgS034m4Ggg qnkMN7B6Mq4HJhuz4uHYRlJMvcn49rYWnm+rDEDicvEJa4zNd3WCGK8c4qO72OkIrZ Y1D4n/rSfy6cUZKNAPryB9qaxDkUaSUBmVQm8XJIdaR4LzLkdTTGdId6nFjB6z7iXl GG6+yLDEG5Q+bZFAWSni8tqx4v2T5vJvocPN7xioHQspLBWXNgpIxF2uNRl73t0DfJ 1osxVrYqnPO5ZjJU9JWm46QSSwKU9TlihVAzfcqOtNg15wSY8K7iPDqwDazrr/85UQ 5EpCLoHs0KJqg== From: Helge Deller To: qemu-devel@nongnu.org Cc: Cornelia Huck , Laurent Vivier , Aurelien Jarno , Helge Deller , Richard Henderson , Eric Farman , Jiaxun Yang , Aleksandar Rikalo , Ilya Leoshkevich , Matthew Rosato , Yoshinori Sato , Pierrick Bouvier , qemu-s390x@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Hildenbrand Subject: [PATCH 05/12] linux-user/sh4: restore FP rounding mode on sigreturn Date: Tue, 26 May 2026 21:05:28 +0200 Message-ID: <20260526190535.10833-6-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526190535.10833-1-deller@kernel.org> References: <20260526190535.10833-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: 1779822452683158500 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:37 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=1779822440; cv=none; d=zohomail.com; s=zohoarc; b=CgaCNBpz13arrR+Mw/TlGToTFjffbinjvTB+iZhC2pBO//7o8BUHxgPUTR6GLLOpbzlJc60z1zGITxh43dtsYR4R3aDxJeqQJPwweIEyhETLd8HP0DKZL7e+kYdvSH55S1AJpMR4vmHvgFzxum/+29v0ntuJ/oHPRXz/hay3S1k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779822440; 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=LVw0oJwSyj8qVZGcgZ9jOYfsLP0lo5J//WpBZ8DrzZ8dKlRjV+N2xrpumldkDOT11M0oeMcvfn9UC9N1M/jSEQPzpEeWi2wKoSgDhpKR3xCsp4cuHLbarspLxsOoQDqOd/VWNDcqDGcSRiaR8YwrVXZedrIo64b5ZBEn3YmHU/c= 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 17798224407951016.9186657435502; Tue, 26 May 2026 12:07:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRx6e-0000YJ-HI; Tue, 26 May 2026 15:06:24 -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 1wRx6O-0000NI-0c; Tue, 26 May 2026 15:06:17 -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 1wRx6L-0004dz-8E; Tue, 26 May 2026 15:06:07 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 34B4E60120; Tue, 26 May 2026 19:06:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 980B71F00A3A; Tue, 26 May 2026 19:05:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779822362; bh=/5CGgZ/X7uMiJB5eErY0sF7KyvBhWLSMYSs2M1AmyjE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Wq+k3sEEzsKuqSqsP70oMVOoqzKo6K5R5vEaC9KfgVLbQG1VEyEP1N3sGlJxUkPlH mDivh+G6Xn8KeCttNBrM4x0SxkLck67fFr+iFd8jXLJcIQNB9aKtlZ07vN2HKrzZxz L0ukvNh/jGgRqDMoSpLRGXdMyVDyQQq3a94mNQ7KoMUlZBBayW3eKgCvMz89KySg2l Zr7C6SfO6edS1QjDFczOpMNhY0JOwdYUCHQ0x0WxrEq+01P0RuX+F1z6uoGLNFMX+W qmLV4PzuQUTkCMReHOwJTHCdwPpI7PMiYFlQ3fqU7h8tlo2ptaSIaloMAeLifs04Ss ofhyVbKuIP8TA== From: Helge Deller To: qemu-devel@nongnu.org Cc: Cornelia Huck , Laurent Vivier , Aurelien Jarno , Helge Deller , Richard Henderson , Eric Farman , Jiaxun Yang , Aleksandar Rikalo , Ilya Leoshkevich , Matthew Rosato , Yoshinori Sato , Pierrick Bouvier , qemu-s390x@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Hildenbrand Subject: [PATCH 06/12] target/sh4: sync fp_status when gdb writes FPSCR Date: Tue, 26 May 2026 21:05:29 +0200 Message-ID: <20260526190535.10833-7-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526190535.10833-1-deller@kernel.org> References: <20260526190535.10833-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: 1779822442742154100 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:37 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=1779822485; cv=none; d=zohomail.com; s=zohoarc; b=TWJMPhUL3dR6j/91vbPEBUf6z51RkGri7bwkf1Hk5VpYx/EgyoH6dH8Zh0ZUoFYIURV6poIlEqjus8eJeJt16bBT+lPtwoKs0cZGFaox68CQvZSt8V5LCcdxgaQoRXh9A+Vb69nO28w1I4OHUOcYDi9+4w2PZnRTOely3wTKVTU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779822485; 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=kP+sxZwoLDlb1s3QQAfxPUs7PQXLdaX/obc2YCHB88jem3RvhuMMXSqmFTuzEHVFdyzT7lojrmPEH1TtTvWTfbSi06HPGZeLcz3AL6A5rXH9ygY7MileaMj8WAhtvWYajKQG79mv2X4v3wwswF7Pm9U35OyXnejr8smBssGphQs= 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 1779822485312423.3596794465526; Tue, 26 May 2026 12:08:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRx6a-0000RU-4G; Tue, 26 May 2026 15:06:20 -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 1wRx6Q-0000NQ-As; Tue, 26 May 2026 15:06:17 -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 1wRx6O-0004eB-15; Tue, 26 May 2026 15:06:09 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id F3F84600BB; Tue, 26 May 2026 19:06:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5F6321F00A3C; Tue, 26 May 2026 19:06:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779822366; bh=pGlSoLvSkWLWM09alJZgROZ3NJFIPwvSs1E7yFYC654=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ozgq2w+matKNFjJj5OZXdHdY8dqie6KjzJiLLuSgZFq/1JSpwMWQWlwAvPuCnSnxf uRk4w8AeQOls9mcpA/zsb/Bf4w4ocohIUXI4fDcFQfbRkCjir2a58J7m+9KUhJnjyL Afkm9Uz5g96c1YmchM7GhrmjJ8xtkIwtUPOYaNT6epCcXN6Uz065UIMA+rpiK6uaee AOv1Ko6XIfBRwuhi3R3vgX17ufYV340nx/YdJCwghp807I8DoS4E4OLe0buaoAIuyC yJ2WROgGJgoUaghaCg/5JHNUOm/8ctx+MVDKguOYDhD+WxmHtLCrIKJ4P4W/Vunf77 oND3ATI9QuQxQ== From: Helge Deller To: qemu-devel@nongnu.org Cc: Cornelia Huck , Laurent Vivier , Aurelien Jarno , Helge Deller , Richard Henderson , Eric Farman , Jiaxun Yang , Aleksandar Rikalo , Ilya Leoshkevich , Matthew Rosato , Yoshinori Sato , Pierrick Bouvier , qemu-s390x@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Hildenbrand Subject: [PATCH 07/12] linux-user/s390x: restore fpu_status rounding mode from FPC on sigreturn Date: Tue, 26 May 2026 21:05:30 +0200 Message-ID: <20260526190535.10833-8-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526190535.10833-1-deller@kernel.org> References: <20260526190535.10833-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: 1779822487286154100 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:37 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=1779822397; cv=none; d=zohomail.com; s=zohoarc; b=mx7+wNRkWuPzUqg77g8Z9LKMaBjA+Etky4QbTlQfILNwSAaohc39C2bl5gqkIAJ0U5pgC9MlJAd591YHFg9zPv4pWvQbHPpTGB63oYtfbnnmRdz1Gb0YniyAjDBE2MVMjObXg+4jMG5PLyoPN4WwhN6UtDZ5fBoJ8FpD+oNBERU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779822397; 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=DxyLGCVO+ooPj3yQMAvWyh5mWuXqUGwidheSSvDQDTaBKyObKI3k4PRWaMDO+/AV/a8l651NNAQMcWxxwfuYu5f25abxrDYBnoXskzNwT85g1rkTHRdnKSI3/HBohyDCHml1ED/UiCT6XEo1VvUPU9Iz7tEqlzckhgpAW9bIpaM= 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 1779822397157615.9647889869188; Tue, 26 May 2026 12:06:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRx6i-0000Zg-Bz; Tue, 26 May 2026 15:06:28 -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 1wRx6V-0000NZ-6h; Tue, 26 May 2026 15:06:17 -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 1wRx6S-0004eW-OL; Tue, 26 May 2026 15:06:14 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 9017943BAE; Tue, 26 May 2026 19:06:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A0291F00A3A; Tue, 26 May 2026 19:06:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779822370; bh=RzAg/z9ESTOIfX4D/3KjFmD6FehyVHYLgvenUfGbwos=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ORIuHVnTaIWZE7tA/BMfeu0xNX/RJZwxrEpAKez36fGBZxuNJk6cU/5Hem0rEHxer Od83Hd61oFNgSn1smaP4RI7cy5FhchfhtaIrom+hC0HhF1qa2HmobAfzlWPSHNWL+N 0UNqgMX0q3JtzGYyYCIAn6LPJeYkrWA8bZUSjWrKN+XpmoPrfGbryZD1+wYp+Wlprd P+39nTaoENuJ4YCYl/GD8Gh1+061VBOeJd4LUgB97chlPRZQOnSzntFB3nEx+19uvD 9tUBzQJFwvvL62MfePuW9IF2IkHA3jF4zw7CwcHhSJ2ogPqYWeVldeYEswt/VLpTtF 4r+mKITr4A6Zw== From: Helge Deller To: qemu-devel@nongnu.org Cc: Cornelia Huck , Laurent Vivier , Aurelien Jarno , Helge Deller , Richard Henderson , Eric Farman , Jiaxun Yang , Aleksandar Rikalo , Ilya Leoshkevich , Matthew Rosato , Yoshinori Sato , Pierrick Bouvier , qemu-s390x@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Hildenbrand Subject: [PATCH 08/12] linux-user: Implement finer grained madivse() syscall Date: Tue, 26 May 2026 21:05:31 +0200 Message-ID: <20260526190535.10833-9-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526190535.10833-1-deller@kernel.org> References: <20260526190535.10833-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: 1779822398453158500 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:37 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=1779822486; cv=none; d=zohomail.com; s=zohoarc; b=TScYLll6vDvue6EKzCLU1Tn1TAytfzHnvS4/qpQpnNHCMyXFcyvR9jx6WF+jedNE8gcDYdovVSVJDcV826E5N/43Cou6Y2XxFiMp2n2kV938clEGeLhx003X/7Dmkz0KvtvRYReg5l7GL1GsggLfKZeO9TW4r4754aSrND6ZGXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779822486; 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=NCSNE0Tms7pJoTW3qZM1/8p91nkWq3/StjYyb08BpQzOrL1zvpX9DWtpCjpSPSkB6Hah+9cacPWp0qC9QsVbcw7gWmJnnX0i63ROq3sfWAZwgctXGxuFnX4SeWA9V9l2v7aVfJfc/s+sUsI/t9XOP2UXoCZh+a/dJPn+9xiTOEs= 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 1779822486387298.5656410692603; Tue, 26 May 2026 12:08:06 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRx6o-0000bC-8p; Tue, 26 May 2026 15:06:34 -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 1wRx6Y-0000Nz-3g; Tue, 26 May 2026 15:06:18 -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 1wRx6W-0004gs-Kq; Tue, 26 May 2026 15:06:17 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 55CFF44377; Tue, 26 May 2026 19:06:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E6F711F000E9; Tue, 26 May 2026 19:06:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779822374; bh=C6sVTMGfaU3enExNWt9KUDNtvH2iTrHHDQG1z3ZZxHI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Y7PMcqjyufk/A8x7l0q0622kgMZ6WiVO+9SJLVSM5vZSZdvRRqdtAT6tbSLJECc6g yV28YoxJEhwJJzQzn9sOL10cDatz0A7t2HeNnoNbiVky64dUUPM1HZ8c3UTWrnoD84 O4895LDMBgV6vXz6tA6fPa7MaoI2eIGLkZh0Vy+KB+H2oNN/QhNpNov2S/l60Q+2S7 4hysgim9P0jwdIQk3iN4aZlzPc+xTlmmwlbNwlSNwi5rP+ca92fuZZ9VYhak4kqp5a Vj6n78ohahShJoKDX8LlGVflr6OuvTx7WdCOan4Xx6vmTOjZqOVYofSKc1cXDmhKXU wGv8jppdhKPBg== From: Helge Deller To: qemu-devel@nongnu.org Cc: Cornelia Huck , Laurent Vivier , Aurelien Jarno , Helge Deller , Richard Henderson , Eric Farman , Jiaxun Yang , Aleksandar Rikalo , Ilya Leoshkevich , Matthew Rosato , Yoshinori Sato , Pierrick Bouvier , qemu-s390x@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Hildenbrand Subject: [PATCH 09/12] linux-user: Fix typo in function documentation for pgb_addr_set() Date: Tue, 26 May 2026 21:05:32 +0200 Message-ID: <20260526190535.10833-10-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526190535.10833-1-deller@kernel.org> References: <20260526190535.10833-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: 1779822487256154100 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:37 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=1779822448; cv=none; d=zohomail.com; s=zohoarc; b=KiMhsJG5ZGS9A9M4gXDOqC+oITz3bqj70zYRmbjQts+X2G4VyZGBTCwuVahPDHASxEToTtjO2/7R8gUaUWRRrozwHyiObnxfq7oGv2tt2TWOUtcimjackHphmTJcCEjPqZKMaVptPD4ilmaVSWi+r04UJDH2MIm36kJrQqQT5Jg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779822448; 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=KvueWLqr4VruWVBJUy/CyEtgpVVJWopB/JOPkLzNM2lOyklpa9BW1bT4OJs5P8O77xosTib0RF1tj7CQ7PiKq2mfeazJsCG8+ZfCx+GDgblup1ZmXJQVXIbswCD6LnIoVMspoDJKekFKzIs+zKF1N48qPjG0JPNIh+8/WEPSYdg= 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 1779822448872530.9589393936207; Tue, 26 May 2026 12:07:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRx6q-0000cc-Js; Tue, 26 May 2026 15:06:36 -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 1wRx6b-0000Uo-Ey; Tue, 26 May 2026 15:06:21 -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 1wRx6Z-0004hN-Jg; Tue, 26 May 2026 15:06:21 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 1CF0B438F3; Tue, 26 May 2026 19:06:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC33B1F000E9; Tue, 26 May 2026 19:06:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779822378; bh=YmDrG2TezwoliurUbxDzBvTiekL3RGYCv9IQwkBdxx8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=npX76Brbf2MixQO187ZMVQ6vKX5oeNNSSSsc3DreDvoucNyVrMptk6EhXpi4EwT+B MQt4VHAca8OORzlmY0DSKKa+e58MoiKCf/Wi1NrzbLsWH/R5Rm9dXBh5c2YIGvrGHA tf8gu7CwOtC2/uq/MPZ8LBSa0ZxbjPdyetlLkacH4LxND5e0sYoh+83T0KfGj/fDkg XUVW0imxoqakv0X4t0Ecm3JnBP75FuKt2NbD3Zxg2YCkDAm113G9CA11UOC00peA6Q Dtx9oiPOpKdcd2QMeIFN5/oAekKu4IFzZlrcjj3OJO6nCufz9uL7tpMDEBYUdmvoRF pVk+t/cKGPVXA== From: Helge Deller To: qemu-devel@nongnu.org Cc: Cornelia Huck , Laurent Vivier , Aurelien Jarno , Helge Deller , Richard Henderson , Eric Farman , Jiaxun Yang , Aleksandar Rikalo , Ilya Leoshkevich , Matthew Rosato , Yoshinori Sato , Pierrick Bouvier , qemu-s390x@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Hildenbrand Subject: [PATCH 10/12] linux-user: Fix loading static ARM cortex-m55 binaries Date: Tue, 26 May 2026 21:05:33 +0200 Message-ID: <20260526190535.10833-11-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526190535.10833-1-deller@kernel.org> References: <20260526190535.10833-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: 1779822450827154100 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:37 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=1779822457; cv=none; d=zohomail.com; s=zohoarc; b=PKQ7OraiFVuVAxUlJNSd31qCaizemwUsr5Htbh7p9LgXJ0ueawKUa3FbmhbXCtFs6sFLYrpcrBluNt64xRWwwQAbvtas06eE3aXQOT978znD5knDZ979Q98l60xNsZ/ZbcFHz9ThqCYf+PDjg/qC8HlPBzMuuf3TJLeN+6ERjkY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779822457; 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=K7+0BsU2T5A8++g7dRnV+kntjXZgkBhvC0sPRrOW93RAqLZVDtMTLbqx8woA+NWIBSKO7m02B9cdadB3RmeLEs8U0LvrywJ24oVukr9Poktpr9TvnSpgMO5+YFSmn5CUXeUmuD33WDLE9wv5kDKdjs7zCjBDMDpnNrvriqDpqnQ= 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 1779822457396661.6852096224691; Tue, 26 May 2026 12:07:37 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRx6o-0000bc-Cx; Tue, 26 May 2026 15:06:34 -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 1wRx6f-0000Z4-Uk; Tue, 26 May 2026 15:06:26 -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 1wRx6e-0004iX-HF; Tue, 26 May 2026 15:06:25 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 12C1460121; Tue, 26 May 2026 19:06:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 73DF41F000E9; Tue, 26 May 2026 19:06:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779822381; bh=Cw9b2yaVekAwr8cSAaU3u13HS5WHaa+YXcm5rfw6fPc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=m4nG1c/70qCPw2yFUTxgY4+BBz2x8b7d2aoKSTKFQ1CYDUWpM+GNiXRXNP7qHGZtV yU2qRgc03He2/tiUaOlSoclNgS0E81aIvSvO1lo57AvTrfq+bzjIgNH0P7B5hbVzYz 2TRjO/HQScx3DHxK940jhdy73vzdA5r69X3Kq7tTQEjIEfS7BZtf4m528M9XIYNx5a b+CFspuSoqpqbxzsWPSc8Zhq2a09azgo4RYk0fL1xjxF474lH7q4mnW99nqzwdC4P+ ZzN/BxXqOWwnhba24RoahB7/igSoQdn3eCwPPs/spurc4NxeRSuQOHPbQSADSU9AXo m+tNgQ3db10ew== From: Helge Deller To: qemu-devel@nongnu.org Cc: Cornelia Huck , Laurent Vivier , Aurelien Jarno , Helge Deller , Richard Henderson , Eric Farman , Jiaxun Yang , Aleksandar Rikalo , Ilya Leoshkevich , Matthew Rosato , Yoshinori Sato , Pierrick Bouvier , qemu-s390x@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Hildenbrand Subject: [PATCH 11/12] linux-user: Move init_main_thread() prototype to user-internals.h Date: Tue, 26 May 2026 21:05:34 +0200 Message-ID: <20260526190535.10833-12-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526190535.10833-1-deller@kernel.org> References: <20260526190535.10833-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: 1779822458858154100 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:37 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=1779822405; cv=none; d=zohomail.com; s=zohoarc; b=QjUfAGRajAgvhWb8uWRl1Oxv+0FGRGO04cm01x+nQsF0AQToac3y4pVdWBOc27cR72PKwAGQ6yY2lW+oyDiZHyt+kAqNvLLIsV4RK+wttgHRS71MTSR/bRulNvQUUQjfuPYb0/3kWq/HICqs4NhUKt+YRXG1Mvsuqa2Ed8x73BM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1779822405; 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=NY/aeD2KZXH+S2hmBx8zSVWXlgTkrVBSfGCtpT3ApzVMsdwizIo3TOLwT+JK0BnEXIUCJvF+p8dbVsKsIQKCJsZrkNRa0qe9EX+WUa6W7azGNG93rZI9QZtmT40aoG4t2wlMwdIVAjsLhMtX2Wu/dl5AYuEvKflry/4h4o9hVlU= 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 1779822405428339.24144510585427; Tue, 26 May 2026 12:06:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wRx6s-0000es-Kw; Tue, 26 May 2026 15:06:38 -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 1wRx6i-0000a3-NX; Tue, 26 May 2026 15:06:30 -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 1wRx6g-0004jW-VY; Tue, 26 May 2026 15:06:28 -0400 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id 1AA8E600CB; Tue, 26 May 2026 19:06:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C9AF1F00A3A; Tue, 26 May 2026 19:06:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779822385; bh=E8bOW7It6eBbYAycvmoXErdMpix7xPsPMO3AvIAjmOg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CQ+g5vWDm1WqXR31ZXiO0zfxHtouPqW62wi7dsVNsBBpZMB4v4ituVXil4z1RrWQH n6K7CbPEy5vi9toi2iVqHD1PYuQzFDoiwY6vGvrg5WdRj6B8K00UCASxTzNVqAtrZt ipsWF4hDyqUq4cD1wn4e6u6XMHWTaI3ARJi2OwZo7SFUW6Taup9ao+k3KJWHJCwy/Q VLedlvOIpRP5ztYDdHpwRBhR/gi96wifTBLbKmcaMhShD91VGncnvaqn5GTt5tPvp8 WZ43bL9Zi3gj44IKTzUFhPJRRFJkkjKYFmntnN+yYNA0VFeWndYdfHIKPH3cTvwsXe 6SRKrv84rVkhA== From: Helge Deller To: qemu-devel@nongnu.org Cc: Cornelia Huck , Laurent Vivier , Aurelien Jarno , Helge Deller , Richard Henderson , Eric Farman , Jiaxun Yang , Aleksandar Rikalo , Ilya Leoshkevich , Matthew Rosato , Yoshinori Sato , Pierrick Bouvier , qemu-s390x@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , David Hildenbrand Subject: [PATCH 12/12] linux-user: Move cpu_copy() to user-internals.h Date: Tue, 26 May 2026 21:05:35 +0200 Message-ID: <20260526190535.10833-13-deller@kernel.org> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260526190535.10833-1-deller@kernel.org> References: <20260526190535.10833-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: 1779822408308154100 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