From nobody Mon Oct 27 01:11:31 2025 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=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1759462339; cv=none; d=zohomail.com; s=zohoarc; b=Gt/oIkNw7BFIye2IkK2OmRR+FbUnaeHPHiEQjjusUoGPuIoTVYT7ewW/7ULhtaBJZKIyB7AMbIBdptk7L/t1bxR7e7aA8oPr4lkcmtzy6ZYWR3IUpW0udNAiTEUCtcoZDSvZRK+GKPn7l0cj4vOsQ6YT3C3+rJAVd2/W2WTAPIM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1759462339; 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=L0riEgKAhZ2Tj4OdOkweDZUA2Gpqfb/brOq+0ojNKrY=; b=JQGpXmV1alctrD+ap2DCOCzqnI6MuO0ZBRDJOS8hE5yCN0sPomNyhdWV5gK2BgULQfsd40QotIrzr+5QCWlWixvbuzPmb6577OM8+in9eu4sYv5yuqb4VcTdPEnYMjREtvAhUFWxSyedw+bF0ojmm+0SvlIEoiQRb+1KMNVk4go= 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=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1759462339683882.8793864419141; Thu, 2 Oct 2025 20:32:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1v4WTg-0007KT-41; Thu, 02 Oct 2025 23:29:04 -0400 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 1v4WTa-0007Gs-CN for qemu-devel@nongnu.org; Thu, 02 Oct 2025 23:28:59 -0400 Received: from mail-pj1-x1032.google.com ([2607:f8b0:4864:20::1032]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1v4WTK-0001I9-LK for qemu-devel@nongnu.org; Thu, 02 Oct 2025 23:28:55 -0400 Received: by mail-pj1-x1032.google.com with SMTP id 98e67ed59e1d1-3352018dfbcso1548663a91.0 for ; Thu, 02 Oct 2025 20:28:40 -0700 (PDT) Received: from toolbx.alistair23.me (2403-580b-97e8-0-82ce-f179-8a79-69f4.ip6.aussiebb.net. [2403:580b:97e8:0:82ce:f179:8a79:69f4]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b62ce55205csm844202a12.18.2025.10.02.20.28.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Oct 2025 20:28:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1759462117; x=1760066917; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=L0riEgKAhZ2Tj4OdOkweDZUA2Gpqfb/brOq+0ojNKrY=; b=J4lLga/moW5zwnBwLVtn/R8arUbmT04si0Yfe7xzIVjLdrw17vu+B431etKCIJCCab jOwPrLx5KmVCt6GcfsDYT2ih3HJX6iCWpzVAnOCvIsWin/cK6SpNfkOP1LfpzTQLPaWC FrlSmjlL6IGxJ/aAnQlIef1NxRH+nrfraEl/JqXQQs3sPe2RFu7VG5WJCXzY2khapIXa 9gyx5M6zS2j6EfC40HM+UqdAG2dxs7hF3P15iNta55QUMFnBhwEXR7GHUbKySjFBssTc T+q6p+ftQTlrfL8No2o9cTGqEIvtP6FaMZxH4eo+NXxL3CYegjhxs7uHx5/RUg7jZk/w 1hrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759462117; x=1760066917; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=L0riEgKAhZ2Tj4OdOkweDZUA2Gpqfb/brOq+0ojNKrY=; b=sWQhd/7f1OQuaSUokXyiOCEK5k3FuSc4l2ueJQYOmsYi4x8ESQRD35ByEV33S+6Ox7 wyVB9FMlYEkBtKgFomgFONPTTmyNrQQ6SUdlkjPz+EBDGEWV4XNd9YgK6lfIWeyI1RHv t4uCrQt8NpyxKp48R8LKfX1ddaUKJW3fess0bb3bB/TRhq2hGnd1OpfT9FQ4K2NOLg3C KRghk5rGGR03Shje/bXL5koE/D1wkoRDqb1rvXoK6C7H++RGDWFUTqhf1c2O5hxyYHI0 e1qCIwwCYsRfGpmcw6abt+XqO5HWGKvs6jJ+gTAT9p/X4LMGf39bySP0dmvADB32ncuC HXiQ== X-Gm-Message-State: AOJu0YwMePg9nvAVgjGOCP3lhmuXlWi2s1H0btkATf2WbWesOwQ/YJsc Mg1LqxAIct8xJzw8NQ+q2DzaEf9+BciIOx0Z34hhyJM7Tn4GOS7SH9g54Axx3Q== X-Gm-Gg: ASbGnctch+kNNZih3hS+cWm1pNDtbwDknykXoMQGLpulFOpAWmOydyRQscTXbYTfL4Q B90Ew+UaE3DSNg4X24AWuI4Tp8OgFWvde3mK66kiy+7gqT2G1zAZFC1CZ8WHoIyDhpGE7SCMkCd D0AfEgiQ1eDE+fTbOUVVQ/ZwushPxFpMvyWqCkIJXovjWy3H+N93M92TnngOW36Qv0gz7UI5+5E c03LJkG6QLpvlB9BC+8wlVrJjTvxTkeoQ1EUeJVRqZZpSSUYvWhfg20XKHaYeZZyvZ1wbosuFiK obSNjwRTTJyMXpxsq7whjvnuPdL3NCkkNPouTlpVqGXbyj3TVoK5Ac7LRziXdgMZpD3Y03mXpym Dlwc0F35ttJstliqkM7xpBu/VR4ly7n/yDqEE42zUbqgUtovKwjxt25537KuqBcGdI2c2FGK03l hED8ePOtLuXU0Ju9p4p6Kp0geZTV9UdW9m7VrhSPNF3RGU/CY1fbir X-Google-Smtp-Source: AGHT+IG2gB9sk9i5DQKx2nikAewjXTszZ/Smue7Nh3pXu99WAtPO1RRQ5uDp7xsUMoHwUf5r89dMqw== X-Received: by 2002:a17:90b:4b08:b0:32f:98da:c397 with SMTP id 98e67ed59e1d1-339c27db05dmr1800965a91.24.1759462117473; Thu, 02 Oct 2025 20:28:37 -0700 (PDT) From: alistair23@gmail.com X-Google-Original-From: alistair.francis@wdc.com To: qemu-devel@nongnu.org Cc: alistair23@gmail.com, Jim Shu , Alistair Francis Subject: [PULL 18/26] target/riscv: Fix the mepc when sspopchk triggers the exception Date: Fri, 3 Oct 2025 13:27:10 +1000 Message-ID: <20251003032718.1324734-19-alistair.francis@wdc.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251003032718.1324734-1-alistair.francis@wdc.com> References: <20251003032718.1324734-1-alistair.francis@wdc.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=2607:f8b0:4864:20::1032; envelope-from=alistair23@gmail.com; helo=mail-pj1-x1032.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1759462341264116600 Content-Type: text/plain; charset="utf-8" From: Jim Shu When sspopchk is in the middle of TB and triggers the SW check exception, it should update PC from gen_update_pc(). If not, RISC-V mepc CSR will get wrong PC address which is still at the start of TB. Signed-off-by: Jim Shu Reviewed-by: Alistair Francis Message-ID: <20250924074818.230010-2-jim.shu@sifive.com> Signed-off-by: Alistair Francis --- target/riscv/insn_trans/trans_rvzicfiss.c.inc | 1 + 1 file changed, 1 insertion(+) diff --git a/target/riscv/insn_trans/trans_rvzicfiss.c.inc b/target/riscv/i= nsn_trans/trans_rvzicfiss.c.inc index b0096adcd0..45686af4d6 100644 --- a/target/riscv/insn_trans/trans_rvzicfiss.c.inc +++ b/target/riscv/insn_trans/trans_rvzicfiss.c.inc @@ -40,6 +40,7 @@ static bool trans_sspopchk(DisasContext *ctx, arg_sspopch= k *a) tcg_gen_brcond_tl(TCG_COND_EQ, data, rs1, skip); tcg_gen_st_tl(tcg_constant_tl(RISCV_EXCP_SW_CHECK_BCFI_TVAL), tcg_env, offsetof(CPURISCVState, sw_check_code)); + gen_update_pc(ctx, 0); gen_helper_raise_exception(tcg_env, tcg_constant_i32(RISCV_EXCP_SW_CHECK)); gen_set_label(skip); --=20 2.51.0