From nobody Thu Apr 10 21:18:04 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1739913750; cv=none; d=zohomail.com; s=zohoarc; b=b1Aqzw/jyIXYAka6UGkwmm11LLU4Q7lb5pwWdTjD3MKmj+/ByOGFumm5HJR2RhbLgyp+8/yQfGZFxMfdl1I7zf6NtUZ2c0S4AVy4Wx4yMQWLE/Wk1a/8zTVR/v5veQzFbNG/ptKQ+4Kf1buIv0GMVN4Q+WCREQ3ZUp2kfcExcWs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1739913750; 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:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=Q0nTTDlTbisLockfMnOkNHTw9QBYDwCgUvNVg9c8e2k=; b=oGgVHtWgLfVGtFNy/NSSXW162B8kSifoYUWaPHdEJZOerPT/q3rqfBSmrGK5yR7tkh/nPMIXK0JK/sp8nWrCIn1UyORrYDuDihWIihfheKGmnnY4KBTWMPa2STniFFNfEegxp61oJvBuRuSVUWbWFZjd0RsxD3xPOUyblCKYqVM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1739913750229567.5662941950408; Tue, 18 Feb 2025 13:22:30 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tkV2G-00033q-V4; Tue, 18 Feb 2025 16:21:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tkV2E-00032f-Ii for qemu-devel@nongnu.org; Tue, 18 Feb 2025 16:21:42 -0500 Received: from home.keithp.com ([63.227.221.253] helo=elaine.keithp.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tkV2A-000335-RP for qemu-devel@nongnu.org; Tue, 18 Feb 2025 16:21:42 -0500 Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id 5178C3F22879 for ; Tue, 18 Feb 2025 13:21:36 -0800 (PST) Received: from elaine.keithp.com ([127.0.0.1]) by localhost (elaine.keithp.com [127.0.0.1]) (amavis, port 10024) with LMTP id ThcbEjBnbYD7; Tue, 18 Feb 2025 13:21:34 -0800 (PST) Received: from keithp.com (koto.keithp.com [192.168.11.2]) by elaine.keithp.com (Postfix) with ESMTPSA id E155B3F20D3C; Tue, 18 Feb 2025 13:21:34 -0800 (PST) Received: by keithp.com (Postfix, from userid 1000) id B79FE1E6007A; Tue, 18 Feb 2025 13:21:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1739913696; bh=hEdGGrdRnyKcM0NWUuU9kjR/8KwYnsAxspFYskjaN3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZM6lnfK4B8qYV33BPavYbeZ4Ok/JALi4AFz4TL8hLKSQEq57zzncuvGxlJk6YkVN0 Sraejzp1ZOcZgmG5GXkCPWHD1cPaCmA+YGs4IAujWknJBUL4d5kDHWiqlDYGZuSVNE gc4L8ZaAe8GtdpEKk6kYgfcXe0Icm62t6sKX8yuVEEEoXkJZc1TXSH3TzVYZDxDs0f Lu1zb+bugpS+TLy2uZUJ+PcuVyYW98d/hNFtIh44n2/2AODgrgnFwfwmAA0YFaDKPN 0ZdHZxKZDZ0kMhmPolEimSLcWB7E4QnThjOxK5/xddgmHU4QIkxTGXnbqqVY3gi1+D FCLnJhm67KF3g== X-Virus-Scanned: Debian amavis at keithp.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1739913694; bh=hEdGGrdRnyKcM0NWUuU9kjR/8KwYnsAxspFYskjaN3Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MJSt5ORqY3ukYJWqkUsjCvT5dAnv3rLwlZFvw3YIZf1JT2etDza8VtZ+8PPVl3XmI hAQnMiO4z5UIpMmmRA7AMvfaxVnd5KRni25VIpGKuwU+pgK//ipeM1zL8HZwRn3dj0 HMHK7Cm/8oaMn+nfD7h32tHzD8LOsQ1d0/6iq9I1UaurX0YMtYZYljVS33OsGGSA04 q/YTlYIBzA8pLPlWzy9wWRXGOHvgo3NAApKFnOnV+YGFJErq9jGPdUbAPasgyi6awv Q9VLwwc/uFoknJTztTKd2Kb3nVXpw2OmMML2jeqJcTMWZz4GXNazS0RyuFa5YISu1X kWERFAAsL3RBQ== To: qemu-devel@nongnu.org Cc: Keith Packard Subject: [PATCH 1/4] target/rx: Set exception vector base to 0xffffff80 Date: Tue, 18 Feb 2025 13:21:00 -0800 Message-ID: <20250218212103.2024039-2-keithp@keithp.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250218212103.2024039-1-keithp@keithp.com> References: <20250215021654.1786679-1-keithp@keithp.com> <20250218212103.2024039-1-keithp@keithp.com> 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=lists.gnu.org; Received-SPF: pass client-ip=63.227.221.253; envelope-from=keithp@keithp.com; helo=elaine.keithp.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Keith Packard From: Keith Packard via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZM-MESSAGEID: 1739913753109019100 Content-Type: text/plain; charset="utf-8" The documentation says the vector is at 0xffffff80, instead of the previous value of 0xffffffc0. That value must have been a bug because the standard vector values (20, 21, 23, 25, 30) were all past the end of the array. Signed-off-by: Keith Packard Reviewed-by: Peter Maydell --- target/rx/helper.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target/rx/helper.c b/target/rx/helper.c index 80912e8dcb..55e2ae4a11 100644 --- a/target/rx/helper.c +++ b/target/rx/helper.c @@ -90,7 +90,7 @@ void rx_cpu_do_interrupt(CPUState *cs) cpu_stl_data(env, env->isp, env->pc); =20 if (vec < 0x100) { - env->pc =3D cpu_ldl_data(env, 0xffffffc0 + vec * 4); + env->pc =3D cpu_ldl_data(env, 0xffffff80 + vec * 4); } else { env->pc =3D cpu_ldl_data(env, env->intb + (vec & 0xff) * 4); } --=20 2.47.2 From nobody Thu Apr 10 21:18:04 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1739913737; cv=none; d=zohomail.com; s=zohoarc; b=MQkkAo6T/bvafqhG4Lpb1FeKQ95pG0H3Hv9Jf3936warXIIr7OuiUaf15jofseVgVG9E+TOFTh9rEbs8Ud/130PwFxQ8I3kNRwuBwp+pdIeQfV3pSli9E+keybCiyp19u7RPtjdCOu611jTVKImlZNEIJYlXraYuQ8u1FvMPt80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1739913737; 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:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=iFjOHgaZy8KQRrs6hvEkaNPD6h4VEesJGOjyY68hZ9o=; b=dNwsopSQlde9jv84FTeCUj7Db/5RV72OOUJgAACdNPUMZTrPaXP5DlwOpkTamHlKNgAvzPxZo919pazjHjXs71UDb5mMp2bW7oxUFVFqFQMEEjLtvous9Cuml6xCW+k4dOTnYOorQN82PC8HlHj5kBAjRJAe1rjIBy6RFqnDwY8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 173991373714262.970963933263874; Tue, 18 Feb 2025 13:22:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tkV2J-00034J-5B; Tue, 18 Feb 2025 16:21:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tkV2E-00032z-Tz for qemu-devel@nongnu.org; Tue, 18 Feb 2025 16:21:42 -0500 Received: from home.keithp.com ([63.227.221.253] helo=elaine.keithp.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tkV2B-00033L-LQ for qemu-devel@nongnu.org; Tue, 18 Feb 2025 16:21:42 -0500 Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id ECF073F20DB1 for ; Tue, 18 Feb 2025 13:21:37 -0800 (PST) Received: from elaine.keithp.com ([127.0.0.1]) by localhost (elaine.keithp.com [127.0.0.1]) (amavis, port 10024) with LMTP id 0UXT2VrVZUh2; Tue, 18 Feb 2025 13:21:35 -0800 (PST) Received: from keithp.com (koto.keithp.com [192.168.11.2]) by elaine.keithp.com (Postfix) with ESMTPSA id DD39E3F20C61; Tue, 18 Feb 2025 13:21:34 -0800 (PST) Received: by keithp.com (Postfix, from userid 1000) id BAAFB1E6009D; Tue, 18 Feb 2025 13:21:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1739913697; bh=rseh06rZwnj1XEKSik48UBym2dlowjYs00+a91IMU/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pPyVDpbilkb/Lg87lqPdvESOf7R6IernWyIfrys9+F8ybiZPtQn/KOiGR9eCzitaV XP4G7+4VmuLwFa24EfadqwFnkzMjtdDTqJoXjOIJDVYb/EPaV2SKVLMOR8XvaMUDI9 BUCdedCH/bWoOl+L3g2x9itiOqy+slNTW2vcTYS+Eveo41UtfohIIUsvl2lOqwNmQW wwydC3Yj8LjloV2QV3F+NlW3ptefB3E7A8ySAQhr4eftdhb7CEVbEPmsRf/Ew2jjxG C0qUJP4bK9GertIf12m0ose74JKejvkTsFmX6ZEA6YbD5yyTETHmdvV1GiiBEenvWb pUeR02TpqH+hQ== X-Virus-Scanned: Debian amavis at keithp.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1739913694; bh=rseh06rZwnj1XEKSik48UBym2dlowjYs00+a91IMU/Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wMFItj/5ACqrAqmuVNiG8L9uwxpcVyUlUSrfdAMBRau7AteCr7S4+vHZmLmPmpDUX HdZPKt2cBxGj6AiKbPgNM/e/DVqpcLBUusrVeHXFFKxkdy3ZGwZadCpQhZsghxIRI4 E31jChVom6NpQm1nu5cKEoTzUNfGuRd2qFC8NuMhs/qtaKFhSD21dELC14eJU8UvEQ 0Kg021iSmExX9XEScKcMzWEaE8a1VsRAlZ5iELoyZXWrdtrf4tsrz51ngd2xCDLcWy iIvtlK+ELgCr6MfE/+PDOTfk/9ydSjYYJ3kXPjV3gDj0zd8OsiFsC+pFWy1tx/j1BM e2mF3fXGXpqZA== To: qemu-devel@nongnu.org Cc: Keith Packard Subject: [PATCH 2/4] target/rx: Remove TCG_CALL_NO_WG from helpers which write env Date: Tue, 18 Feb 2025 13:21:01 -0800 Message-ID: <20250218212103.2024039-3-keithp@keithp.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250218212103.2024039-1-keithp@keithp.com> References: <20250215021654.1786679-1-keithp@keithp.com> <20250218212103.2024039-1-keithp@keithp.com> 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=lists.gnu.org; Received-SPF: pass client-ip=63.227.221.253; envelope-from=keithp@keithp.com; helo=elaine.keithp.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Keith Packard From: Keith Packard via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZM-MESSAGEID: 1739913738328019000 Content-Type: text/plain; charset="utf-8" Functions which modify virtual machine state (such as virtual registers stored in memory) must not be marked TCG_CALL_NO_WG as that tells the optimizer that virtual registers values already loaded in machine registers are still valid, hence discards any changes which these helpers may have made. This seems to also mean that functions which set condition codes may also not use this flag Signed-off-by: Keith Packard Reviewed-by: Peter Maydell --- target/rx/helper.h | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/target/rx/helper.h b/target/rx/helper.h index ebb4739474..8cc38b0cb7 100644 --- a/target/rx/helper.h +++ b/target/rx/helper.h @@ -4,27 +4,27 @@ DEF_HELPER_1(raise_privilege_violation, noreturn, env) DEF_HELPER_1(wait, noreturn, env) DEF_HELPER_2(rxint, noreturn, env, i32) DEF_HELPER_1(rxbrk, noreturn, env) -DEF_HELPER_FLAGS_3(fadd, TCG_CALL_NO_WG, f32, env, f32, f32) -DEF_HELPER_FLAGS_3(fsub, TCG_CALL_NO_WG, f32, env, f32, f32) -DEF_HELPER_FLAGS_3(fmul, TCG_CALL_NO_WG, f32, env, f32, f32) -DEF_HELPER_FLAGS_3(fdiv, TCG_CALL_NO_WG, f32, env, f32, f32) -DEF_HELPER_FLAGS_3(fcmp, TCG_CALL_NO_WG, void, env, f32, f32) -DEF_HELPER_FLAGS_2(ftoi, TCG_CALL_NO_WG, i32, env, f32) -DEF_HELPER_FLAGS_2(round, TCG_CALL_NO_WG, i32, env, f32) -DEF_HELPER_FLAGS_2(itof, TCG_CALL_NO_WG, f32, env, i32) +DEF_HELPER_3(fadd, f32, env, f32, f32) +DEF_HELPER_3(fsub, f32, env, f32, f32) +DEF_HELPER_3(fmul, f32, env, f32, f32) +DEF_HELPER_3(fdiv, f32, env, f32, f32) +DEF_HELPER_3(fcmp, void, env, f32, f32) +DEF_HELPER_2(ftoi, i32, env, f32) +DEF_HELPER_2(round, i32, env, f32) +DEF_HELPER_2(itof, f32, env, i32) DEF_HELPER_2(set_fpsw, void, env, i32) -DEF_HELPER_FLAGS_2(racw, TCG_CALL_NO_WG, void, env, i32) -DEF_HELPER_FLAGS_2(set_psw_rte, TCG_CALL_NO_WG, void, env, i32) -DEF_HELPER_FLAGS_2(set_psw, TCG_CALL_NO_WG, void, env, i32) +DEF_HELPER_2(racw, void, env, i32) +DEF_HELPER_2(set_psw_rte, void, env, i32) +DEF_HELPER_2(set_psw, void, env, i32) DEF_HELPER_1(pack_psw, i32, env) -DEF_HELPER_FLAGS_3(div, TCG_CALL_NO_WG, i32, env, i32, i32) -DEF_HELPER_FLAGS_3(divu, TCG_CALL_NO_WG, i32, env, i32, i32) -DEF_HELPER_FLAGS_1(scmpu, TCG_CALL_NO_WG, void, env) +DEF_HELPER_3(div, i32, env, i32, i32) +DEF_HELPER_3(divu, i32, env, i32, i32) +DEF_HELPER_1(scmpu, void, env) DEF_HELPER_1(smovu, void, env) DEF_HELPER_1(smovf, void, env) DEF_HELPER_1(smovb, void, env) DEF_HELPER_2(sstr, void, env, i32) -DEF_HELPER_FLAGS_2(swhile, TCG_CALL_NO_WG, void, env, i32) -DEF_HELPER_FLAGS_2(suntil, TCG_CALL_NO_WG, void, env, i32) -DEF_HELPER_FLAGS_2(rmpa, TCG_CALL_NO_WG, void, env, i32) +DEF_HELPER_2(swhile, void, env, i32) +DEF_HELPER_2(suntil, void, env, i32) +DEF_HELPER_2(rmpa, void, env, i32) DEF_HELPER_1(satr, void, env) --=20 2.47.2 From nobody Thu Apr 10 21:18:04 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1739913737; cv=none; d=zohomail.com; s=zohoarc; b=H+B91HBhi60Ho0Xka2REy/nJBi6XB5OXlrY8AQJCR7ARRxE/VQkHfwdlvJ2NnxvqwdSNHK1Y9f6JsOJeRRzEIgItdZM/9mWQvnTX6qU90GpAUXAPELOKb9VpYp5Ysqv7fMLl2tFiAXCOQy6z56cXGN618XRwMBbx3HQc1LPjGkg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1739913737; 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:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=HbbAO2q/OMePzzI7m7UpUr/gJpXIsTOAtwc7B4InJkg=; b=OkxVH6znPO1g+cbCYCCjgbfHMzW2eC8Ef2sDdxpwCGZQja8momjKW3YYWxr7kVcfkXBlBBv+0YiOs99xl0j6TH3KDQ11fYAMcsZWpnZcVc0NEoGnK9YdqXd70tv6m0q/5lq9ClT0pD1+tLjZTKnrLQ2bZQxxuHo54n1MUUFEvXw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 17399137375971017.2879919139053; Tue, 18 Feb 2025 13:22:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tkV2E-00032b-Jv; Tue, 18 Feb 2025 16:21:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tkV2D-00032M-FX for qemu-devel@nongnu.org; Tue, 18 Feb 2025 16:21:41 -0500 Received: from home.keithp.com ([63.227.221.253] helo=elaine.keithp.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tkV2A-00033B-Sh for qemu-devel@nongnu.org; Tue, 18 Feb 2025 16:21:41 -0500 Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id 428253F20D3C for ; Tue, 18 Feb 2025 13:21:37 -0800 (PST) Received: from elaine.keithp.com ([127.0.0.1]) by localhost (elaine.keithp.com [127.0.0.1]) (amavis, port 10024) with LMTP id kI16fiP6pMAe; Tue, 18 Feb 2025 13:21:36 -0800 (PST) Received: from keithp.com (koto.keithp.com [192.168.11.2]) by elaine.keithp.com (Postfix) with ESMTPSA id E7EBE3F20DB1; Tue, 18 Feb 2025 13:21:34 -0800 (PST) Received: by keithp.com (Postfix, from userid 1000) id BDBC21E6009E; Tue, 18 Feb 2025 13:21:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1739913697; bh=teoTsh+CvtnyfxlQFH0EO7DMOroSayuJqtpkRTSKTfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n3NvL8NiPH/rHw8FKMJbdXIIFYgY/Dn/528dNZloXwAR0nZk7aqo4EQNDLQAT5qYO oDcrJt1ge11oux8z2WSAzNC2H5woJhxDudH50rTicVRO5LM8hTVQgSB9h6FpbH6Coh oHj+sRo98S9Bg0R6t3WA2nIz2dOm888vUldBemsRzUM89N6d96jnaNjiH2C48LhGtU yzEzApIseB0Putu4AOwbMCnOB5/bmxWl4qDsFLg9SM2Ql9EspwcGTNszhe8xz06grq W/1HcVZURLsE09jiluxgsBP/RQhRuBCPyKYSEvxEiagwkdL0AshxlMjjUSnKcNo4nK zCMzyas+cdiyg== X-Virus-Scanned: Debian amavis at keithp.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1739913694; bh=teoTsh+CvtnyfxlQFH0EO7DMOroSayuJqtpkRTSKTfg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K2w1gBLPfGrank0tzejcTv8+SNqFbR80HEIxJXYTmi+ZZhpROaKFjVScIn0DID26Q 0lYczHqQthQebWpzUNqV8eY32wLg/NfqoDsqvNA3aHHF9NRaqGdq3pA4ZuECLcBLXb V3hrCRCvJDKkjgPMhx0P0//bVsEXqOFwS1e1TZu3iSLgM6LfedQr1YSp78ymffHzVU msFeuns179kYgC/LGzzqYFgkoDxLPOFkaOjvYh8nwvmG7GoAXgf3lN6gOX9T9jJYbm iQMpkUaiL02nQ8d+CIXCl6g/m15195BPJLTrOFKU/kWPtrTBLRYO1rmT2TIcXxvy5o Kz2jGhVZYVHVA== To: qemu-devel@nongnu.org Cc: Keith Packard Subject: [PATCH 3/4] hw/rx: Reset the CPU at qemu reset time Date: Tue, 18 Feb 2025 13:21:02 -0800 Message-ID: <20250218212103.2024039-4-keithp@keithp.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250218212103.2024039-1-keithp@keithp.com> References: <20250215021654.1786679-1-keithp@keithp.com> <20250218212103.2024039-1-keithp@keithp.com> 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=lists.gnu.org; Received-SPF: pass client-ip=63.227.221.253; envelope-from=keithp@keithp.com; helo=elaine.keithp.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Keith Packard From: Keith Packard via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZM-MESSAGEID: 1739913742227019100 Content-Type: text/plain; charset="utf-8" This ensure that the CPU gets reset every time QEMU resets. Use either the kernel entry point or the reset vector if no kernel was loaded. Signed-off-by: Keith Packard --- hw/rx/rx-gdbsim.c | 36 +++++++++++++++++++++++++++++++++++- target/rx/cpu.c | 9 ++------- target/rx/cpu.h | 3 +++ 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/hw/rx/rx-gdbsim.c b/hw/rx/rx-gdbsim.c index 4afd77efd5..9e395ae345 100644 --- a/hw/rx/rx-gdbsim.c +++ b/hw/rx/rx-gdbsim.c @@ -22,6 +22,7 @@ #include "qemu/guest-random.h" #include "qemu/units.h" #include "qapi/error.h" +#include "exec/cpu_ldst.h" #include "hw/loader.h" #include "hw/rx/rx62n.h" #include "system/qtest.h" @@ -56,6 +57,34 @@ DECLARE_OBJ_CHECKERS(RxGdbSimMachineState, RxGdbSimMachi= neClass, RX_GDBSIM_MACHINE, TYPE_RX_GDBSIM_MACHINE) =20 =20 +static void rx_cpu_reset(void *opaque) +{ + RXCPU *cpu =3D opaque; + CPUState *cs =3D CPU(cpu); + CPURXState *env =3D cpu_env(cs); + + cpu_reset(cs); + + if (env->use_reset_pc) { + /* + * Load the PC with the starting address for the kernel + */ + env->pc =3D env->reset_pc; + } else { + /* + * Load the initial PC from the reset vector. If there is + * a ROM containing that vector use that, otherwise read + * it from target memory. + */ + uint32_t *resetvec_p =3D rom_ptr_for_as(cs->as, 0xfffffffc, 4); + if (resetvec_p) { + env->pc =3D ldl_p(resetvec_p); + } else { + env->pc =3D cpu_ldl_data(env, 0xfffffffc); + } + } +} + static void rx_load_image(RXCPU *cpu, const char *filename, uint32_t start, uint32_t size) { @@ -68,7 +97,8 @@ static void rx_load_image(RXCPU *cpu, const char *filenam= e, fprintf(stderr, "qemu: could not load kernel '%s'\n", filename); exit(1); } - cpu->env.pc =3D start; + cpu->env.reset_pc =3D start; + cpu->env.use_reset_pc =3D true; =20 /* setup exception trap trampoline */ /* linux kernel only works little-endian mode */ @@ -87,6 +117,7 @@ static void rx_gdbsim_init(MachineState *machine) const char *kernel_filename =3D machine->kernel_filename; const char *dtb_filename =3D machine->dtb; uint8_t rng_seed[32]; + CPUState *cs; =20 if (machine->ram_size < mc->default_ram_size) { char *sz =3D size_to_str(mc->default_ram_size); @@ -153,6 +184,9 @@ static void rx_gdbsim_init(MachineState *machine) s->mcu.cpu.env.regs[1] =3D SDRAM_BASE + dtb_offset; } } + for (cs =3D first_cpu; cs; cs =3D CPU_NEXT(cs)) { + qemu_register_reset(rx_cpu_reset, RX_CPU(cs)); + } } =20 static void rx_gdbsim_class_init(ObjectClass *oc, void *data) diff --git a/target/rx/cpu.c b/target/rx/cpu.c index 37a6fdd569..528cda486c 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -76,7 +76,6 @@ static void rx_cpu_reset_hold(Object *obj, ResetType type) CPUState *cs =3D CPU(obj); RXCPUClass *rcc =3D RX_CPU_GET_CLASS(obj); CPURXState *env =3D cpu_env(cs); - uint32_t *resetvec; =20 if (rcc->parent_phases.hold) { rcc->parent_phases.hold(obj, type); @@ -84,11 +83,6 @@ static void rx_cpu_reset_hold(Object *obj, ResetType typ= e) =20 memset(env, 0, offsetof(CPURXState, end_reset_fields)); =20 - resetvec =3D rom_ptr(0xfffffffc, 4); - if (resetvec) { - /* In the case of kernel, it is ignored because it is not set. */ - env->pc =3D ldl_p(resetvec); - } rx_cpu_unpack_psw(env, 0, 1); env->regs[0] =3D env->isp =3D env->usp =3D 0; env->fpsw =3D 0; @@ -142,7 +136,6 @@ static void rx_cpu_realize(DeviceState *dev, Error **er= rp) } =20 qemu_init_vcpu(cs); - cpu_reset(cs); =20 rcc->parent_realize(dev, errp); } @@ -189,6 +182,8 @@ static void rx_cpu_init(Object *obj) { RXCPU *cpu =3D RX_CPU(obj); =20 + cpu->env.reset_pc =3D 0; + cpu->env.use_reset_pc =3D false; qdev_init_gpio_in(DEVICE(cpu), rx_cpu_set_irq, 2); } =20 diff --git a/target/rx/cpu.h b/target/rx/cpu.h index 5ba1874bd7..c42a03efb3 100644 --- a/target/rx/cpu.h +++ b/target/rx/cpu.h @@ -98,6 +98,9 @@ typedef struct CPUArchState { uint32_t ack_ipl; /* execute ipl */ float_status fp_status; qemu_irq ack; /* Interrupt acknowledge */ + + bool use_reset_pc; /* Use reset_pc instead of reset vector */ + uint32_t reset_pc; /* PC reset value when use_reset_pc */ } CPURXState; =20 /* --=20 2.47.2 From nobody Thu Apr 10 21:18:04 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1739913782; cv=none; d=zohomail.com; s=zohoarc; b=klMccJvqFImsTMp6b8rvFl6Ge4tISnEr/hCR0YNK2C7QPJ4RXjyJEzVgBK5P4yZjCya0YZJnx/lR0C3ft4CcPDjm7WhaPtP4JITPIBo44SIFyYExGuy4bj+KzPQLtCSyJjAVuzPUhKWys9XyhFt6BPD4fFmj03LMgBq5EnaZuVQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1739913782; 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:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=TID+LNXbTjzmKFb5eITrysB1v6mI+UDsFs+E3I70TGw=; b=I/qBiPrzgjzbX7HwhAaQahsaVNY7qzKaXHDvpKC39dJwZdFuN3sQpjfKG+1aKaqx+PmEQzJYr+VqP/DhGvUGOpymMv0IVH0QIhVRo4cY8XCJZEFQopveQZB1dFnsfemC5JCXl2eZ19fzpmNcjwWOTCZFihdzI1MFwIyv34SjGKk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1739913782119385.2581326989392; Tue, 18 Feb 2025 13:23:02 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tkV2I-00034A-I9; Tue, 18 Feb 2025 16:21:46 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tkV2E-00032m-Nr for qemu-devel@nongnu.org; Tue, 18 Feb 2025 16:21:42 -0500 Received: from home.keithp.com ([63.227.221.253] helo=elaine.keithp.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tkV2B-00033S-V3 for qemu-devel@nongnu.org; Tue, 18 Feb 2025 16:21:42 -0500 Received: from localhost (localhost [127.0.0.1]) by elaine.keithp.com (Postfix) with ESMTP id BBC813F20C61 for ; Tue, 18 Feb 2025 13:21:38 -0800 (PST) Received: from elaine.keithp.com ([127.0.0.1]) by localhost (elaine.keithp.com [127.0.0.1]) (amavis, port 10024) with LMTP id iT7caFC17IXn; Tue, 18 Feb 2025 13:21:37 -0800 (PST) Received: from keithp.com (koto.keithp.com [192.168.11.2]) by elaine.keithp.com (Postfix) with ESMTPSA id EDC3E3F22241; Tue, 18 Feb 2025 13:21:34 -0800 (PST) Received: by keithp.com (Postfix, from userid 1000) id C0ADE1E6009F; Tue, 18 Feb 2025 13:21:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1739913698; bh=86QjUrEhAuhhbXN0b8DnVM4v1JDgzxiyHIi3K8dZDjA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Uub6E4KCzOJqh67mOc6PRlNn2CRUdj/jntCwFdwF0mcqloJDQ7uR1dTGAofYOdaR1 /QHt5N7LkAEZK2vIWk9J2KO04GbswweA6iIObJEchfAbhxLh8suWK4/kV3hdcR+50a LyZyJYLRs2wMPQO+kZqyOQtKZ/z0vdL3aTDh0i8/t7L+zY6TZRHwo+n8nTsO+VAcx0 1vHnRIGsyesvILOXUVYvDnIf9TP8Ejbxz9G/hE+Ph0o+VmmX7Ajans6IrTXD7e+Vhd 9us0yEVCMiTEDftbJoeMryoMDiZOYI/ZSwgVhMdUBc81n+NgipY6YDcuLTQ2Oyvfgy 3mcWKv9KmBwrg== X-Virus-Scanned: Debian amavis at keithp.com DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=keithp.com; s=mail; t=1739913694; bh=86QjUrEhAuhhbXN0b8DnVM4v1JDgzxiyHIi3K8dZDjA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WAUVOqTsOyKQla6hHO/qlMj3gZi1+LoGo6453tTBprxpUglA1GtsygF3+yCu6cSDl XrOLgKIZnV+VHB/Xn9cCGdMRUnPtGdCZLADUGuXQ6+JQMGpxYo118PQAB/flEuM+tb qvg2g+s473eu0EWle7uQi87QgxwTRW/hEsPbjUeHHm+GxCWXtce+UrGZgrlvwiT+Bb iO3e4fkjCDhopZ0N5jUr8hKfDGEW9EbAwS6E/asG5BkKeZN5bHaqvFwRnkoMJ02Uw5 KjcpJbs6NrxurZbs1wXh9DbCb218yPis3P96hLUNFDIHHsD4JVBg6YaezJ9jMpN3LE qv1DnTo4aqbBw== To: qemu-devel@nongnu.org Cc: Keith Packard Subject: [PATCH 4/4] rx: Support loading of ELF files too Date: Tue, 18 Feb 2025 13:21:03 -0800 Message-ID: <20250218212103.2024039-5-keithp@keithp.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250218212103.2024039-1-keithp@keithp.com> References: <20250215021654.1786679-1-keithp@keithp.com> <20250218212103.2024039-1-keithp@keithp.com> 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=lists.gnu.org; Received-SPF: pass client-ip=63.227.221.253; envelope-from=keithp@keithp.com; helo=elaine.keithp.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Keith Packard From: Keith Packard via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (found 2 invalid signatures) X-ZM-MESSAGEID: 1739913783113019100 Content-Type: text/plain; charset="utf-8" The existing loader supports raw binary blobs with the entry point defined as the start of the blob. Add support for loading ELF files by first checking if the provided filename has a valid ELF header, falling back to the existing loader code when that fails. Signed-off-by: Keith Packard --- hw/rx/rx-gdbsim.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/hw/rx/rx-gdbsim.c b/hw/rx/rx-gdbsim.c index 9e395ae345..58492b713f 100644 --- a/hw/rx/rx-gdbsim.c +++ b/hw/rx/rx-gdbsim.c @@ -25,6 +25,7 @@ #include "exec/cpu_ldst.h" #include "hw/loader.h" #include "hw/rx/rx62n.h" +#include "elf.h" #include "system/qtest.h" #include "system/device_tree.h" #include "system/reset.h" @@ -85,6 +86,37 @@ static void rx_cpu_reset(void *opaque) } } =20 +static bool rx_load_elf(RXCPU *cpu, const char *filename) +{ + CPUState *cs =3D CPU(cpu); + Elf32_Ehdr elf_header; + bool elf_is64; + Error *err =3D NULL; + uint64_t lowaddr, highaddr, entry; + ssize_t ret; + + load_elf_hdr(filename, &elf_header, &elf_is64, &err); + if (err) { + error_free(err); + return false; + } + + ret =3D load_elf_as(filename, NULL, NULL, NULL, + &entry, &lowaddr, &highaddr, NULL, false, + EM_RX, 1, 0, cs->as); + + if (ret <=3D 0) { + /* The header loaded but the image didn't */ + error_report("qemu: could not load elf '%s': %s", + filename, load_elf_strerror(ret)); + exit(1); + } + + cpu->env.reset_pc =3D entry; + cpu->env.use_reset_pc =3D true; + return true; +} + static void rx_load_image(RXCPU *cpu, const char *filename, uint32_t start, uint32_t size) { @@ -92,6 +124,10 @@ static void rx_load_image(RXCPU *cpu, const char *filen= ame, long kernel_size; int i; =20 + if (rx_load_elf(cpu, filename)) { + return; + } + kernel_size =3D load_image_targphys(filename, start, size); if (kernel_size < 0) { fprintf(stderr, "qemu: could not load kernel '%s'\n", filename); --=20 2.47.2