From nobody Mon Nov 25 09:51:20 2024 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=reject dis=none) header.from=sifive.com ARC-Seal: i=1; a=rsa-sha256; t=1715347161; cv=none; d=zohomail.com; s=zohoarc; b=aF5gfYRKrMUacQePw6rnQ45YuP7Xg9ROBPnMVaeX55FniOTivrX/sRW9hGy9LhUsKFZhQLJO5JOjdbzu55Sr8lNRmcCT2dwArLr2UQ/XG8yNlOBbzttYLIOQDxAR6jviMWxvsAf4guIdTK89DvL9+AW+UPsQ0cvXxt4GCaYsaQo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715347161; 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=rYDRJr2Sli1gOcjJSn4QR8SIHpM0aP0XTZg/I/oH8oI=; b=dzWAYIaDfeUXFuQB5pYtr76LBjnGzj9YDcsCf4l/jAXSOcDktNuDSHUM0M/1oAZ+sTgzIYTLtXGEFjb9VUwNELFAK5aoolORfGaw2CO9XQbL2WITtGoktArV3CUV8FZAi3Ixfwx93LfQ3xvfjkSZiDQ+Pt6hCDfDYgpqVdCfzXs= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715347161099888.3618078468972; Fri, 10 May 2024 06:19:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5Q8N-0005sI-Em; Fri, 10 May 2024 09:17:59 -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 1s5K8M-0001ck-Rd for qemu-devel@nongnu.org; Fri, 10 May 2024 02:53:34 -0400 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s5K8K-0004nm-Di for qemu-devel@nongnu.org; Fri, 10 May 2024 02:53:34 -0400 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1edfc57ac0cso13698855ad.3 for ; Thu, 09 May 2024 23:53:32 -0700 (PDT) Received: from hsinchu36-syssw02.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0bf31a7asm25579175ad.140.2024.05.09.23.53.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 23:53:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1715324011; x=1715928811; 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=rYDRJr2Sli1gOcjJSn4QR8SIHpM0aP0XTZg/I/oH8oI=; b=L2rPqW7wYgk3RXcgEPyAAsfUwiE7sH7vCRSMvKhsFLcymQVLR6fFlCLg0Lb0QjbKaG lZKR69n6ch5z/tEi4CEuTt2dd5AO79mMSMVebt9ZDdb9etPhEw77JWVxd/yOit85IcAv DwNSDYdGjiGo6IkRxlFeB+Vr6IUe5wecyeUaLldvTvkVoaHe7PYsdV4PXQOys29hVoxJ RpI+5u3jNv8wvj4k720NFQO66ga7G9fiz5Mx5bdlUwtnBGB6QmfBoezYp2QKQ/kgN7Or QyrZF7/poPYGGrplxK6AA7YwODcg64kFgtRbLj6u40Q4zUaF+1D6CrSZ3opRmll7dBwN LUsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715324011; x=1715928811; 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=rYDRJr2Sli1gOcjJSn4QR8SIHpM0aP0XTZg/I/oH8oI=; b=uCgkbYDUmA3KMjak7GBrpPqWIY1FiRQ5JYInTxc+zcBMHMHU/zNncMG24eBG0fI0/v iHAGhRfgXSUeA/nt+jOvKCm5HiyqsvJLhqMUGn81OORkOZlptoV40FTBNttRUc2T3rmc PUKMUGlX/pTPoBUDaJTIo4nkGCX9yjjY4Evj086SBpdVTuywl4DXEncYQFbMrM/PSHi4 ZW9nXhDnewcGLnw1mor+9gDUv4l/8C1F5EMr1ZcItgp/dB4PrssEzu09IxrqlosCksE8 acvKzDYuz5nkqmkXaZzHjCvrcMd+hGbkICOliOvcvRf6nV+CdWFVfPGOaOnJpkt15nEJ rlDA== X-Gm-Message-State: AOJu0YzWD10T8PLvnpx6hA348OtpWWHjm/PUGBz6W9wij8Hw0laXOvAT 8QXsoFyzc2kD+gJOqEM0rTXYUtNL5NrrsUD69/k2ypaQY+bYJiP1wPyB7cprtwlrPlVIQukjAbM /TSBRn2YeS3oixbcOTpJ2hrVGvH27mPLKx7kdvi4VlMEAe4Qy+n+eBNLhzJkrs+h2EprTWvQkWO /xBRAJ0k+0E8w82XkmsPKHD1l/9w0nq2EiKjLPyA== X-Google-Smtp-Source: AGHT+IFqSvcyZDzNEa8Xwql2/wnMqC8tb8/gVujYDB6CGU+TT1+FPPqwfdtPBMkX5M36O7kCeBCxxw== X-Received: by 2002:a17:903:124b:b0:1ea:d979:d778 with SMTP id d9443c01a7336-1ef43c0fd92mr19470505ad.5.1715324010471; Thu, 09 May 2024 23:53:30 -0700 (PDT) From: "Fea.Wang" To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Jim Shu , "Fea . Wang" , Frank Chang , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Andrew Jones , Max Chou Subject: [PATCH 1/5] target/riscv: Reuse the conversion function of priv_spec and string Date: Fri, 10 May 2024 14:58:51 +0800 Message-Id: <20240510065856.2436870-2-fea.wang@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240510065856.2436870-1-fea.wang@sifive.com> References: <20240510065856.2436870-1-fea.wang@sifive.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::62c; envelope-from=fea.wang@sifive.com; helo=mail-pl1-x62c.google.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_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 10 May 2024 09:17:57 -0400 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 @sifive.com) X-ZM-MESSAGEID: 1715347161950100001 Content-Type: text/plain; charset="utf-8" From: Jim Shu Public the conversion function of priv_spec and string in cpu.h, so that tcg-cpu.c could also use it. Signed-off-by: Jim Shu Signed-off-by: Fea.Wang Reviewed-by: Frank Chang Reviewed-by: LIU Zhiwei --- target/riscv/cpu.c | 4 ++-- target/riscv/cpu.h | 3 +++ target/riscv/tcg/tcg-cpu.c | 13 +++++-------- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index a74f0eb29c..b6b48e5620 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1769,7 +1769,7 @@ static const PropertyInfo prop_pmp =3D { .set =3D prop_pmp_set, }; =20 -static int priv_spec_from_str(const char *priv_spec_str) +int priv_spec_from_str(const char *priv_spec_str) { int priv_version =3D -1; =20 @@ -1784,7 +1784,7 @@ static int priv_spec_from_str(const char *priv_spec_s= tr) return priv_version; } =20 -static const char *priv_spec_to_str(int priv_version) +const char *priv_spec_to_str(int priv_version) { switch (priv_version) { case PRIV_VERSION_1_10_0: diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index e0dd1828b5..7696102697 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -829,4 +829,7 @@ target_ulong riscv_new_csr_seed(target_ulong new_value, uint8_t satp_mode_max_from_map(uint32_t map); const char *satp_mode_str(uint8_t satp_mode, bool is_32_bit); =20 +const char *priv_spec_to_str(int priv_version); +int priv_spec_from_str(const char *priv_spec_str); + #endif /* RISCV_CPU_H */ diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index 4ebebebe09..faa8de9b83 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -76,16 +76,13 @@ static void riscv_cpu_write_misa_bit(RISCVCPU *cpu, uin= t32_t bit, =20 static const char *cpu_priv_ver_to_str(int priv_ver) { - switch (priv_ver) { - case PRIV_VERSION_1_10_0: - return "v1.10.0"; - case PRIV_VERSION_1_11_0: - return "v1.11.0"; - case PRIV_VERSION_1_12_0: - return "v1.12.0"; + const char *priv_spec_str =3D priv_spec_to_str(priv_ver); + + if (priv_spec_str =3D=3D NULL) { + g_assert_not_reached(); } =20 - g_assert_not_reached(); + return priv_spec_str; } =20 static void riscv_cpu_synchronize_from_tb(CPUState *cs, --=20 2.34.1 From nobody Mon Nov 25 09:51:20 2024 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=reject dis=none) header.from=sifive.com ARC-Seal: i=1; a=rsa-sha256; t=1715347149; cv=none; d=zohomail.com; s=zohoarc; b=CMw+oK8GR2cavwPkmS0PatfHQxMGl9x1NoSqeZWKf2lBpaWexVaidLUWOrbc5PaPcCvvGrLdDfWVT6eRUUr20hgKGbnnGtP8/avFLga6urAaoNn+WTW4kjzk47XIG9PKQrZsj1ggsAXgGLHc14qRve+lNYq+qDfY6M4EgtAjt5s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715347149; 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=VAsL4QSkEAe6lAFIQlVDgyR+n6eZ4E85ah8Bz0EmYD0=; b=fC3DY28MMW/jaimdB/NCE4ehUxxM/8OQmE4mg2o70BU8xibgxcC7T4eezlAdIF/v9PrNK8OFMce42bhzqdVkaJv4wCCGJtzXkON6MdfzPslWSCPzpqYpldiBB6g4K4tuCJU+aVbeBbEE8ryhFdtlUJkHFTsPDGSz0tir8VQ7yP8= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715347149008173.51663173207044; Fri, 10 May 2024 06:19:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5Q8P-0005tC-6G; Fri, 10 May 2024 09:18:01 -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 1s5K8R-0001fE-3i for qemu-devel@nongnu.org; Fri, 10 May 2024 02:53:39 -0400 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s5K8P-0004oe-CM for qemu-devel@nongnu.org; Fri, 10 May 2024 02:53:38 -0400 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-6f447260f9dso1494963b3a.0 for ; Thu, 09 May 2024 23:53:37 -0700 (PDT) Received: from hsinchu36-syssw02.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0bf31a7asm25579175ad.140.2024.05.09.23.53.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 23:53:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1715324015; x=1715928815; 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=VAsL4QSkEAe6lAFIQlVDgyR+n6eZ4E85ah8Bz0EmYD0=; b=SVVRpz/GwFF9uMyfbiOV9+yei4et7thMAB9J/RAHg33CGzWKyPovW2Jp4SiviXLUGi E8xizI+cIM/YVT8Zha/TdoRc5XcbBNs1rWoRcdG1k1azArs2/7pqknqlS5DdUO342P0G FPbIAqdIMBEnXDkYhUeSaJjtPXSTtGp0eZug8AejzqnzYwSqAWbffh6RgpgTTwYoFmNj SU79r2NE96Tn5pRKuICL5lIkBUXi53kKdTEChBlYtmyemTrEfoobqztzYRQElbIzGx10 O03N8HItbTXZunExH+rr2JrzC4uJx47btqEvLx2pkaWn593tPemmNqVOLsJAkr+2W/Or cpNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715324015; x=1715928815; 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=VAsL4QSkEAe6lAFIQlVDgyR+n6eZ4E85ah8Bz0EmYD0=; b=uYcDtX3JYhoctlNfmEwQHARg/rdih3cCNq/NqO6lHB6fjendFI2I5LnBRRfJHtlvVh hHJbnifTbfknZnNRgHZMNrfjcYgQFD6EFwp8ZgVfP1ETr/D5jj4TMKUawsZY4/T2ctZL OoV51X/12FdslAna1afo07BapFXtyPM2FureRueROQH8nFkqRJLdct1FdSHpoyE8Vs/U aJQJ/8rMnjMp11weHH8+lavTV3CTcg/mjze5wnflV6H9gTa7UnkaBhhp3Wn/SDGmP93S Am2bx7DyGcR9nUK2A2Yw2HGDD/XHtZggSewhNI4z/A8GS8M4g4Li3eUOT/0PDouNz78a oSSQ== X-Gm-Message-State: AOJu0Yyr6OENRys73z1AeJ/FW+bsg0N2HWsQuUZTkcBMD7lZoWLo9Jo2 91bwD7TfmpuA15cg1AalG/wfcFVhdbewChE03S6Cxvh8hha3ouW+T+AlieIeOtiCrEcjOz+A5o9 sD8qrGpNIBhTtaS9luauVbfGKg7uFtG2v8+5XyzSJ3ullBzidu/CaoIo3I2YDxtydWWZz1zOGbG 4479Fz6eI3a21KmBGiGEcv3Fd8rAqbUK/yj/MF5A== X-Google-Smtp-Source: AGHT+IFB/h0yf0oUPaFIYpT5TbgQkYZMBTvyBBPDGTbnqSCimmq/zEPgB4SaDGJWomYSgwV2V77NRA== X-Received: by 2002:a05:6a20:96cd:b0:1aa:4289:5921 with SMTP id adf61e73a8af0-1afde1b0187mr1686905637.50.1715324015361; Thu, 09 May 2024 23:53:35 -0700 (PDT) From: "Fea.Wang" To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: "Fea.Wang" , Frank Chang , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , Andrew Jones , Max Chou Subject: [PATCH 2/5] target/riscv: Support the version for ss1p13 Date: Fri, 10 May 2024 14:58:52 +0800 Message-Id: <20240510065856.2436870-3-fea.wang@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240510065856.2436870-1-fea.wang@sifive.com> References: <20240510065856.2436870-1-fea.wang@sifive.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::42f; envelope-from=fea.wang@sifive.com; helo=mail-pf1-x42f.google.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_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 10 May 2024 09:17:57 -0400 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 @sifive.com) X-ZM-MESSAGEID: 1715347150021100003 Content-Type: text/plain; charset="utf-8" Add RISC-V privilege 1.13 support. Signed-off-by: Fea.Wang Reviewed-by: Frank Chang Reviewed-by: LIU Zhiwei Reviewed-by:=C2=A0 Weiwei Li --- target/riscv/cpu.c | 6 +++++- target/riscv/cpu.h | 4 +++- target/riscv/cpu_cfg.h | 1 + target/riscv/tcg/tcg-cpu.c | 4 ++++ 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index b6b48e5620..a6298c3298 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -1773,7 +1773,9 @@ int priv_spec_from_str(const char *priv_spec_str) { int priv_version =3D -1; =20 - if (!g_strcmp0(priv_spec_str, PRIV_VER_1_12_0_STR)) { + if (!g_strcmp0(priv_spec_str, PRIV_VER_1_13_0_STR)) { + priv_version =3D PRIV_VERSION_1_13_0; + } else if (!g_strcmp0(priv_spec_str, PRIV_VER_1_12_0_STR)) { priv_version =3D PRIV_VERSION_1_12_0; } else if (!g_strcmp0(priv_spec_str, PRIV_VER_1_11_0_STR)) { priv_version =3D PRIV_VERSION_1_11_0; @@ -1793,6 +1795,8 @@ const char *priv_spec_to_str(int priv_version) return PRIV_VER_1_11_0_STR; case PRIV_VERSION_1_12_0: return PRIV_VER_1_12_0_STR; + case PRIV_VERSION_1_13_0: + return PRIV_VER_1_13_0_STR; default: return NULL; } diff --git a/target/riscv/cpu.h b/target/riscv/cpu.h index 7696102697..776939b56b 100644 --- a/target/riscv/cpu.h +++ b/target/riscv/cpu.h @@ -96,12 +96,14 @@ extern RISCVCPUProfile *riscv_profiles[]; #define PRIV_VER_1_10_0_STR "v1.10.0" #define PRIV_VER_1_11_0_STR "v1.11.0" #define PRIV_VER_1_12_0_STR "v1.12.0" +#define PRIV_VER_1_13_0_STR "v1.13.0" enum { PRIV_VERSION_1_10_0 =3D 0, PRIV_VERSION_1_11_0, PRIV_VERSION_1_12_0, + PRIV_VERSION_1_13_0, =20 - PRIV_VERSION_LATEST =3D PRIV_VERSION_1_12_0, + PRIV_VERSION_LATEST =3D PRIV_VERSION_1_13_0, }; =20 #define VEXT_VERSION_1_00_0 0x00010000 diff --git a/target/riscv/cpu_cfg.h b/target/riscv/cpu_cfg.h index e1e4f32698..fb7eebde52 100644 --- a/target/riscv/cpu_cfg.h +++ b/target/riscv/cpu_cfg.h @@ -136,6 +136,7 @@ struct RISCVCPUConfig { * TCG always implement/can't be user disabled, * based on spec version. */ + bool has_priv_1_13; bool has_priv_1_12; bool has_priv_1_11; =20 diff --git a/target/riscv/tcg/tcg-cpu.c b/target/riscv/tcg/tcg-cpu.c index faa8de9b83..a9d188a9fd 100644 --- a/target/riscv/tcg/tcg-cpu.c +++ b/target/riscv/tcg/tcg-cpu.c @@ -320,6 +320,10 @@ static void riscv_cpu_update_named_features(RISCVCPU *= cpu) cpu->cfg.has_priv_1_12 =3D true; } =20 + if (cpu->env.priv_ver >=3D PRIV_VERSION_1_13_0) { + cpu->cfg.has_priv_1_13 =3D true; + } + /* zic64b is 1.12 or later */ cpu->cfg.ext_zic64b =3D cpu->cfg.cbom_blocksize =3D=3D 64 && cpu->cfg.cbop_blocksize =3D=3D 64 && --=20 2.34.1 From nobody Mon Nov 25 09:51:20 2024 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=reject dis=none) header.from=sifive.com ARC-Seal: i=1; a=rsa-sha256; t=1715347100; cv=none; d=zohomail.com; s=zohoarc; b=WMbJ+yGnPoaL9uxGSbg/RvHMKF4oBZilrzy8MHJw4E6eNDWcBjj3dQW4SL7xR2jp9tPLZe1ESoyXTo71R8FWpeC4ENgtHNt0ohB6YoG9r1WNvcPAboAp4IHawrAP74413+2+4+Ty90qF2QtIfVKFgVDYN7T6OG6q9xHICgcHgTM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715347100; 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=myUSGxZ6KvD2m50MweZ9w07eN6Ng2ZhuGkrMddDWFfY=; b=Zfrze/d9V54MguTnY9BFmvTkgpqropDsa0Wg6juN9sw+UX7nmU60g7nJ0pyin7NztbYmg3gqDjdenWmEd2JQsqeVbRwcYKx4xhZUR4SDuIjVBH/qHGxIZTfcwFyZXWwtF2L0eIKh0c2tz2cBW8TyopqqXOKQ5UvXP8D/Txlhe7w= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715347100663761.3787599602146; Fri, 10 May 2024 06:18:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5Q8M-0005rX-OH; Fri, 10 May 2024 09:17:58 -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 1s5K8U-0001gM-Pc for qemu-devel@nongnu.org; Fri, 10 May 2024 02:53:42 -0400 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s5K8T-0004pQ-2M for qemu-devel@nongnu.org; Fri, 10 May 2024 02:53:42 -0400 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-1ec4dc64c6cso11652905ad.0 for ; Thu, 09 May 2024 23:53:40 -0700 (PDT) Received: from hsinchu36-syssw02.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0bf31a7asm25579175ad.140.2024.05.09.23.53.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 23:53:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1715324019; x=1715928819; 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=myUSGxZ6KvD2m50MweZ9w07eN6Ng2ZhuGkrMddDWFfY=; b=YhzqElQQG35Qnc+odVyaNYcKY0j9zfsGFTYe1DMUsHRsyqjkUXZMi6eUAotdmMCrrF QLlcbYGIlEY660mPofqwYKGs2JGVRcwPpFyeUD840q8SgxtrabdD9cXpTphxaqnT6HYj aB3tmcTpujhsLLhpTvy+JAWswRGOg16M+Y9SO9YDYkrg/8Yu80AMX495Wx/nqUpsw1r4 LZzPJDFhs9wAEQhB0sqnh9hKAvs2oELXLuYLxI1dJlpAaPBixRlPp9y5n98A1P3n51ad B+tErjxAJ8FYdm9qTa67a0MheM2773WvjXGuvpS5Q59A8X+eMUURH4WuPhYdQoiDnndS qHuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715324019; x=1715928819; 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=myUSGxZ6KvD2m50MweZ9w07eN6Ng2ZhuGkrMddDWFfY=; b=th06z/9jaRxJKX4WxLHzLqn4fYdfC3hBtGh5baS81S3/zlRBPmOim8Zl6bSQIFhmbx phNhFkSDGmB8H0x+FuRd64lDW9yeE/Pv5CLndIO9ZoayFSmQ4BjDvUyROh8YjXMc48qG 96y6n8+4gthNYTcVIp0kP2v89dXTIXTcij+v7IIr7M6sa9HyoHIGzdVRU+xMstcEo+Us qLuXfLkVocNNfDyr7sD1RwlxS8zK66MXEwv9z2qU0y+HE1yXc7BBVY6ysxD9XexId9vO Syi+8TwrIT+oBZUWvgWRYVOOkCaq1gFR8GscZSwLW4zvPgovAukK+0snFgHmGt8FuVgb jswA== X-Gm-Message-State: AOJu0YwJkr6+raVfoGKc/u6A3fcZSfSwmlr0OcPNzpJCxlT0SvU4yA6+ tKW0r568L4VRML6mrsTLTzYR6Uhpf9GugKPFBqNi/o09mGdsVcgMY7qHM9y88PO4wqGsjqusp2N UClCTw4Ebsbh62I85rmwMokn5IJsodIEybnPqNd3xNtLHYxJDLQk4XOW9O3cS8DfTD/e6RCnKHw 2mdNfjbjgllWcwhOQTm8ZV9LKHjYdJh7ScJMkTsg== X-Google-Smtp-Source: AGHT+IFGUFRFueFUDNZ9d5BFLoP8Hn1ZDnL5G0nYVH3EA/EArusX9dl1OazLYLdkHre6SLyO/nAP/g== X-Received: by 2002:a17:903:8c3:b0:1e8:a63b:d427 with SMTP id d9443c01a7336-1ef43f522b1mr22968315ad.49.1715324019119; Thu, 09 May 2024 23:53:39 -0700 (PDT) From: "Fea.Wang" To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: "Fea.Wang" , Frank Chang , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei Subject: [PATCH 3/5] target/riscv: Add 'P1P13' bit in SMSTATEEN0 Date: Fri, 10 May 2024 14:58:53 +0800 Message-Id: <20240510065856.2436870-4-fea.wang@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240510065856.2436870-1-fea.wang@sifive.com> References: <20240510065856.2436870-1-fea.wang@sifive.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::633; envelope-from=fea.wang@sifive.com; helo=mail-pl1-x633.google.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_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 10 May 2024 09:17:57 -0400 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 @sifive.com) X-ZM-MESSAGEID: 1715347101707100003 Content-Type: text/plain; charset="utf-8" Based on privilege 1.13 spec, there should be a bit56 for 'P1P13' in SMSTATEEN0 that controls access to the hedeleg. Signed-off-by: Fea.Wang Reviewed-by: Frank Chang Reviewed-by:=C2=A0 Weiwei Li --- target/riscv/cpu_bits.h | 1 + target/riscv/csr.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 74318a925c..28bd3fb0b4 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -315,6 +315,7 @@ #define SMSTATEEN0_CS (1ULL << 0) #define SMSTATEEN0_FCSR (1ULL << 1) #define SMSTATEEN0_JVT (1ULL << 2) +#define SMSTATEEN0_P1P13 (1ULL << 56) #define SMSTATEEN0_HSCONTXT (1ULL << 57) #define SMSTATEEN0_IMSIC (1ULL << 58) #define SMSTATEEN0_AIA (1ULL << 59) diff --git a/target/riscv/csr.c b/target/riscv/csr.c index 6b460ee0e8..d844ce770e 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -2248,6 +2248,11 @@ static RISCVException write_mstateen0(CPURISCVState = *env, int csrno, wr_mask |=3D SMSTATEEN0_FCSR; } =20 + RISCVCPU *cpu =3D env_archcpu(env); + if (cpu->env.priv_ver >=3D PRIV_VERSION_1_13_0) { + wr_mask |=3D SMSTATEEN0_P1P13; + } + return write_mstateen(env, csrno, wr_mask, new_val); } =20 @@ -2283,6 +2288,11 @@ static RISCVException write_mstateen0h(CPURISCVState= *env, int csrno, { uint64_t wr_mask =3D SMSTATEEN_STATEEN | SMSTATEEN0_HSENVCFG; =20 + RISCVCPU *cpu =3D env_archcpu(env); + if (cpu->env.priv_ver >=3D PRIV_VERSION_1_13_0) { + wr_mask |=3D SMSTATEEN0_P1P13; + } + return write_mstateenh(env, csrno, wr_mask, new_val); } =20 --=20 2.34.1 From nobody Mon Nov 25 09:51:20 2024 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=reject dis=none) header.from=sifive.com ARC-Seal: i=1; a=rsa-sha256; t=1715347166; cv=none; d=zohomail.com; s=zohoarc; b=HniRc7Gg1HcBzSvEJ9Coxs0jWNpILCtlFTjfnlx/E4fYta7LcPuDFbQblqpKj4yBvZCgcsTxc7C2zqB8ZasM5F61IjBBDo+bZtw8iUQusLGq3aSbeC/9R4RLZIQofh3dCg0pQugxQDkxRyZnSB0exghpokxces/32ujtCqCysSs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715347166; 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=wQ6x5YYUL/lDfqaZOQY3/NuL3tGGxwqwExXQMFAPOo4=; b=HQMOrTbOqvXuDZemW33wvUvk10MLXXx8rA4NYpcirSXhqOW1Am0lKX9MnisVmAl8T1qjsYQG63djW4tV/875K6n6AYey6SidOlUw4muEfAJtS1vWiBdCbRm9vY/1OlLHmSsFiQavymWTh9RLuDoRQwRYUBGjUwg2xnzoveJn1Ac= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715347166922113.51301870850011; Fri, 10 May 2024 06:19:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5Q8N-0005rq-5C; Fri, 10 May 2024 09:17:59 -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 1s5K8Z-0001hF-5q for qemu-devel@nongnu.org; Fri, 10 May 2024 02:53:47 -0400 Received: from mail-pf1-x42a.google.com ([2607:f8b0:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s5K8X-0004q4-IK for qemu-devel@nongnu.org; Fri, 10 May 2024 02:53:46 -0400 Received: by mail-pf1-x42a.google.com with SMTP id d2e1a72fcca58-6ed3cafd766so1576483b3a.0 for ; Thu, 09 May 2024 23:53:44 -0700 (PDT) Received: from hsinchu36-syssw02.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0bf31a7asm25579175ad.140.2024.05.09.23.53.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 23:53:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1715324023; x=1715928823; 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=wQ6x5YYUL/lDfqaZOQY3/NuL3tGGxwqwExXQMFAPOo4=; b=RMF999yi/chZfC8i/HeNzcQiqg1lAuGEi3BOO9cJ4RKvj1Lc9B/v5GX2LiXErQC8U2 Lfe/gyy34/pJJEcrtgSgCDMCAxbFVLejI89MQuNrxkQvxd474MchAxmOPe8nJxpQE2yx 1BdTexk2OMvSpvmWUOPboQjMN+6iUUQCG6i5FzgTDcOXg7YaRneAfJNUUVjX7lCrl9ON voph5xTr4FB0ZcUX50x+xUt2nvqS7WzD5i7/Ky99S2CPRdaA74mxAMBLAHy1o9KjutUB IUK34oNvUgzfVpw2cgNtUwDgPP4vRvWPlgzkLRzqTU6QOuxCXq1K3p5WyF3d4fDsqprg o09g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715324023; x=1715928823; 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=wQ6x5YYUL/lDfqaZOQY3/NuL3tGGxwqwExXQMFAPOo4=; b=J01+zXaAMl+QwxYh8u28bhUkKbGfg0esLiNRqIpOeVI+PWpWYD0SiZQCwxIb9UUhn5 WmT3HZifNIGy2nt1Ol/xTbPjSaoJThcCcvJGR2wkxYZPBkD3jO+3HDcLj7fqpzrsnASx 2m30mO+tIuvbqzeJ2DMSi/Dz7Y2sd/TEY3Se7FCiozxnNcStoibcK/k18nJb9mxvAnrE cl41xsYTw8F7btZ9H3m0Bx+kQmeyf0tGch5b9czezj+0ZvxE2ZE6cd5PDQBsRR634jCa lui2iyFYqH1/nJJ24qVQ6XczprKBdcKsGoS6UUDNc7AcYeJ8rJgFsf1BLUV2k0BhpjLt qmkg== X-Gm-Message-State: AOJu0Yzze2aVDrIvXqek2B08+s1CRQMgN64OV8y5Z2i8cjBrjK09VJxB LgEAm3GuRKFjwnEsmbk4H6Hyrhm93XXyZ69+ayTbfB3aXMDUahlo2XQj7bH78Mj+xi1pppWLnVl BRdMq9XlBlpkRiUL8Ino51HbE829tXX1PWpWufWb9Wks181v4VYapuVIoBNJfpS+Eubu80pa7iU p0o7Bg3igUWuQChoTaUCiN/CyWQUYrkL9bS85WdA== X-Google-Smtp-Source: AGHT+IFHmlCOLyDzgMs9n27eOyHn22NwhAbhtFCaEYhwZn0J1+DEzVbg5zOaQoLE2fRFmtdpJSawgQ== X-Received: by 2002:a05:6a21:680b:b0:1ac:e07f:e3aa with SMTP id adf61e73a8af0-1afde1b7264mr2328560637.48.1715324022840; Thu, 09 May 2024 23:53:42 -0700 (PDT) From: "Fea.Wang" To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: "Fea.Wang" , Frank Chang , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei Subject: [PATCH 4/5] target/riscv: Add MEDELEGH, HEDELEGH csrs for RV32 Date: Fri, 10 May 2024 14:58:54 +0800 Message-Id: <20240510065856.2436870-5-fea.wang@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240510065856.2436870-1-fea.wang@sifive.com> References: <20240510065856.2436870-1-fea.wang@sifive.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::42a; envelope-from=fea.wang@sifive.com; helo=mail-pf1-x42a.google.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_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 10 May 2024 09:17:57 -0400 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 @sifive.com) X-ZM-MESSAGEID: 1715347168003100006 Content-Type: text/plain; charset="utf-8" Based on privileged spec 1.13, the RV32 needs to implement MEDELEGH and HEDELEGH for exception codes 32-47 for reserving and exception codes 48-63 for custom use. Add the CSR number though the implementation is just reading zero and writing ignore. Besides, for accessing HEDELEGH, it should be controlled by mstateen0 'P1P13' bit. Signed-off-by: Fea.Wang Reviewed-by: Frank Chang Reviewed-by: LIU Zhiwei --- target/riscv/cpu_bits.h | 2 ++ target/riscv/csr.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index 28bd3fb0b4..f888025c59 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -156,6 +156,8 @@ =20 /* 32-bit only */ #define CSR_MSTATUSH 0x310 +#define CSR_MEDELEGH 0x312 +#define CSR_HEDELEGH 0x612 =20 /* Machine Trap Handling */ #define CSR_MSCRATCH 0x340 diff --git a/target/riscv/csr.c b/target/riscv/csr.c index d844ce770e..4d7313f456 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -3227,6 +3227,33 @@ static RISCVException write_hedeleg(CPURISCVState *e= nv, int csrno, return RISCV_EXCP_NONE; } =20 +static RISCVException read_hedelegh(CPURISCVState *env, int csrno, + target_ulong *val) +{ + RISCVException ret; + ret =3D smstateen_acc_ok(env, 0, SMSTATEEN0_P1P13); + if (ret !=3D RISCV_EXCP_NONE) { + return ret; + } + + /* Reserved, now read zero */ + *val =3D 0; + return RISCV_EXCP_NONE; +} + +static RISCVException write_hedelegh(CPURISCVState *env, int csrno, + target_ulong val) +{ + RISCVException ret; + ret =3D smstateen_acc_ok(env, 0, SMSTATEEN0_P1P13); + if (ret !=3D RISCV_EXCP_NONE) { + return ret; + } + + /* Reserved, now write ignore */ + return RISCV_EXCP_NONE; +} + static RISCVException rmw_hvien64(CPURISCVState *env, int csrno, uint64_t *ret_val, uint64_t new_val, uint64_t wr_mask) @@ -4674,6 +4701,10 @@ riscv_csr_operations csr_ops[CSR_TABLE_SIZE] =3D { =20 [CSR_MSTATUSH] =3D { "mstatush", any32, read_mstatush, write_mstatush = }, + [CSR_MEDELEGH] =3D { "medelegh", any32, read_zero, write_ignore, + .min_priv_ver =3D PRIV_VERSION_1_13_0 = }, + [CSR_HEDELEGH] =3D { "hedelegh", any32, read_hedelegh, write_hede= legh, + .min_priv_ver =3D PRIV_VERSION_1_13_0 = }, =20 /* Machine Trap Handling */ [CSR_MSCRATCH] =3D { "mscratch", any, read_mscratch, write_mscratch, --=20 2.34.1 From nobody Mon Nov 25 09:51:20 2024 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=reject dis=none) header.from=sifive.com ARC-Seal: i=1; a=rsa-sha256; t=1715347166; cv=none; d=zohomail.com; s=zohoarc; b=BzdkPMcCV59atzl7JSWwO/ZY9Gh4GrHQES5VLJNM3rQixdEYD7bqbpD3Ll8ULyZuAmoYK/3FF3L0dME9941mrB63s5N64fAC2xFYuSsAEzEf4OC9WPkfMf3KPQLNAYQ3SPRC6EmudlnpDz27q5HlPTdGEWzEFiXuUZ7ebtCpeow= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1715347166; 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=yu8hvEmMVZKvLb7jw48LlBWGJrT9gAdbX9dylAP6AFY=; b=QgDf16evcFCSkfFa2YjsD8z+ONaPQX4K7m364EhfTLHJbeMqBf8CKkC91thcrwbDv1fMrLtwmr8W9zE/WLqm84eottIkPGsd1Yneh9XuDUtfS/AHeqAQhH9AqQmQWOAG6pENJrtvbqgq7BotDeDsUib3d3EOfg7BSfqFDULbd8U= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1715347166530369.27861496882656; Fri, 10 May 2024 06:19:26 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s5Q8N-0005ss-UB; Fri, 10 May 2024 09:17:59 -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 1s5K8c-0001kS-MG for qemu-devel@nongnu.org; Fri, 10 May 2024 02:53:50 -0400 Received: from mail-pg1-x529.google.com ([2607:f8b0:4864:20::529]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s5K8b-0004s1-2O for qemu-devel@nongnu.org; Fri, 10 May 2024 02:53:50 -0400 Received: by mail-pg1-x529.google.com with SMTP id 41be03b00d2f7-61bbb208ea5so1371395a12.0 for ; Thu, 09 May 2024 23:53:48 -0700 (PDT) Received: from hsinchu36-syssw02.internal.sifive.com (59-124-168-89.hinet-ip.hinet.net. [59.124.168.89]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0bf31a7asm25579175ad.140.2024.05.09.23.53.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 23:53:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1715324027; x=1715928827; 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=yu8hvEmMVZKvLb7jw48LlBWGJrT9gAdbX9dylAP6AFY=; b=PpDd9I0FIjzje4R7Tok1GspNqyQ+wb0PJjourFYAvb3NnTpbFQhQEu4UGk+5T1rHix H3nbOEaMuya6iq4ZI8mHibuV36+ofqNm3dgdIeH6+v1BrI+nxTPKsTKiWbtGu/uJEnDE r84y489ic1/Ouwi7IBBmIrH9/1Ua2gF7Ooas9xAXeiGGR453r1oJps//1d70JyBBH3YV IFwXUyhG4XZbP/idmqjtiRhsvJOWeiSFLjjLTtXZxOP2B+UVIg7Vj8GOlNDwgDd73cXx pvTKiJGwXW/QdUGBfo5Lkr8Ge/7UrigO9GQOJqA0N528omLP3BMInloyIun0GmQ+6+4k jZJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715324027; x=1715928827; 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=yu8hvEmMVZKvLb7jw48LlBWGJrT9gAdbX9dylAP6AFY=; b=FrgNo60wNtKFVPw1KVEZLIG3KguzKPv6c8Ta7kfatIN4Vv+uQP1fFoA8m4TGtGYOoZ jhdX3bYIsAxVA4ncS1mJonQXpvsngaJILtPjifjlBWxpzrHnxZv3cAiDGB7sVCGRUA69 nvBrTgd8hi6wM7Z//D3xv8HIDIkyBx+Tqg89SqRqLVtFLzRgotHjduWdVBpRv7rR9YAZ 3uBtooP1jMpUUX246HD3bPm1py/axEEMXxyDUOhahGzAy/xQloJvR/ggkscxbPodRXUR ZFwierrYIMSMI2TTZ75At7RnDwGcjH6l+8xf10ull6GhOBwzA8yomnrAs1au1geGcsP1 d4Eg== X-Gm-Message-State: AOJu0YwVpaT2m89aU/8PzwDHraN/8M4vQCFOU8nZCqK7MBVFtWNz80Mn WdJTIauMPR69cFPOg3LRnqc726ivgEuLkDsnqIdwx2bJ/SKHDc5MzRgAKsRvxOGfwosJNfMQT6g 9Az/H6fAudppyAiYoYMkdhVCxUiB2SpuFfa0VEg4VFp4R7kra3rXzMp+LAaka7gg2pMN72dHnxT hUWn3zBoHLJo+yZOVaGLwNRgTftbMKsZ7Zc7oC7A== X-Google-Smtp-Source: AGHT+IHksYpxv8qPTXANxmC+6wogUEdNVPXf5rqfL896HpeuiV+WqRaXvrDW1t3r7R+MUvEcUE0m7A== X-Received: by 2002:a05:6a20:96d2:b0:1af:d810:9d0e with SMTP id adf61e73a8af0-1afde1c57dfmr1838159637.49.1715324026803; Thu, 09 May 2024 23:53:46 -0700 (PDT) From: "Fea.Wang" To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: "Fea.Wang" , Frank Chang , Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei Subject: [PATCH 5/5] target/riscv: Reserve exception codes for sw-check and hw-err Date: Fri, 10 May 2024 14:58:55 +0800 Message-Id: <20240510065856.2436870-6-fea.wang@sifive.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240510065856.2436870-1-fea.wang@sifive.com> References: <20240510065856.2436870-1-fea.wang@sifive.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::529; envelope-from=fea.wang@sifive.com; helo=mail-pg1-x529.google.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_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Fri, 10 May 2024 09:17:57 -0400 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 @sifive.com) X-ZM-MESSAGEID: 1715347167992100005 Content-Type: text/plain; charset="utf-8" Based on the priv-1.13.0, add the exception codes for Software-check and Hardware-error. Signed-off-by: Fea.Wang Reviewed-by: Frank Chang Reviewed-by: LIU Zhiwei --- target/riscv/cpu_bits.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/riscv/cpu_bits.h b/target/riscv/cpu_bits.h index f888025c59..f037f727d9 100644 --- a/target/riscv/cpu_bits.h +++ b/target/riscv/cpu_bits.h @@ -673,6 +673,8 @@ typedef enum RISCVException { RISCV_EXCP_INST_PAGE_FAULT =3D 0xc, /* since: priv-1.10.0 */ RISCV_EXCP_LOAD_PAGE_FAULT =3D 0xd, /* since: priv-1.10.0 */ RISCV_EXCP_STORE_PAGE_FAULT =3D 0xf, /* since: priv-1.10.0 */ + RISCV_EXCP_SW_CHECK =3D 0x12, /* since: priv-1.13.0 */ + RISCV_EXCP_HW_ERR =3D 0x13, /* since: priv-1.13.0 */ RISCV_EXCP_INST_GUEST_PAGE_FAULT =3D 0x14, RISCV_EXCP_LOAD_GUEST_ACCESS_FAULT =3D 0x15, RISCV_EXCP_VIRT_INSTRUCTION_FAULT =3D 0x16, --=20 2.34.1