From: Jim Shu <jim.shu@sifive.com>
To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: Palmer Dabbelt <palmer@dabbelt.com>,
Alistair Francis <alistair.francis@wdc.com>,
Weiwei Li <liwei1518@gmail.com>,
Daniel Henrique Barboza <dbarboza@ventanamicro.com>,
Liu Zhiwei <zhiwei_liu@linux.alibaba.com>,
Jim Shu <jim.shu@sifive.com>
Subject: [PATCH v2 3/4] target/riscv: Fix VSTIP bit in sstc extension.
Date: Wed, 9 Apr 2025 10:51:30 +0800 [thread overview]
Message-ID: <20250409025131.3670-4-jim.shu@sifive.com> (raw)
In-Reply-To: <20250409025131.3670-1-jim.shu@sifive.com>
VSTIP is only writable when both [mh]envcfg.STCE is enabled, or it will
revert it's defined behavior as if sstc extension is not implemented.
Signed-off-by: Jim Shu <jim.shu@sifive.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
---
target/riscv/csr.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/target/riscv/csr.c b/target/riscv/csr.c
index 7948188356..e86808fd98 100644
--- a/target/riscv/csr.c
+++ b/target/riscv/csr.c
@@ -3635,7 +3635,14 @@ static RISCVException rmw_mip64(CPURISCVState *env, int csrno,
if (riscv_cpu_cfg(env)->ext_sstc && (env->priv == PRV_M) &&
get_field(env->menvcfg, MENVCFG_STCE)) {
/* sstc extension forbids STIP & VSTIP to be writeable in mip */
- mask = mask & ~(MIP_STIP | MIP_VSTIP);
+
+ /* STIP is not writable when menvcfg.STCE is enabled. */
+ mask = mask & ~MIP_STIP;
+
+ /* VSTIP is not writable when both [mh]envcfg.STCE are enabled. */
+ if (get_field(env->henvcfg, HENVCFG_STCE)) {
+ mask = mask & ~MIP_VSTIP;
+ }
}
if (mask) {
--
2.17.1
next prev parent reply other threads:[~2025-04-09 2:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-09 2:51 [PATCH v2 0/4] Several sstc extension fixes Jim Shu
2025-04-09 2:51 ` [PATCH v2 1/4] target/riscv: Add the checking into stimecmp write function Jim Shu
2025-04-09 2:51 ` [PATCH v2 2/4] hw/intc: riscv_aclint: Fix mtime write for sstc extension Jim Shu
2025-05-19 0:38 ` Alistair Francis
2025-04-09 2:51 ` Jim Shu [this message]
2025-04-09 2:51 ` [PATCH v2 4/4] target/riscv: Enable/Disable S/VS-mode Timer when STCE bit is changed Jim Shu
2025-05-19 0:44 ` Alistair Francis
2025-04-09 2:58 ` [PATCH v2 0/4] Several sstc extension fixes Jim Shu
2025-04-29 2:27 ` Jim Shu
2025-05-19 3:24 ` Alistair Francis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250409025131.3670-4-jim.shu@sifive.com \
--to=jim.shu@sifive.com \
--cc=alistair.francis@wdc.com \
--cc=dbarboza@ventanamicro.com \
--cc=liwei1518@gmail.com \
--cc=palmer@dabbelt.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=zhiwei_liu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).