diff options
| author | Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com> | 2026-05-14 16:45:36 -0300 |
|---|---|---|
| committer | Michael Tokarev <mjt@tls.msk.ru> | 2026-06-17 10:19:26 +0300 |
| commit | 7c9787408a9d7c88bfba0b4f675954d025725a1e (patch) | |
| tree | f27d017311a6c0e3ce3a01261f67f780a17549a5 | |
| parent | 81073858e625e2e569a8a169908e296a4bd6ee9d (diff) | |
| download | qemu-7c9787408a9d7c88bfba0b4f675954d025725a1e.tar.gz qemu-7c9787408a9d7c88bfba0b4f675954d025725a1e.zip | |
target/riscv/csr.c: do not allow mstatus MPV/GVA writes
The priv spec states the following about mstatus.MPV:
"The MPV bit (Machine Previous Virtualization Mode) is written by the
implementation whenever a trap is taken into M-mode."
And, about mstatus.GVA:
"Field GVA (Guest Virtual Address) is written by the implementation
whenever a trap is taken into M-mode."
Both are written during riscv_cpu_do_interrupt(). They're not supposed
to be written by userspace. As far as write_mstatus goes these fields
are read only. The same applies for mstatush.MPV/mstatush.GVA.
Fixes: 03dd405dd5 ("target/riscv: Support MSTATUS.MPV/GVA only when RVH is enabled")
Signed-off-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com>
Acked-by: Alistair Francis <alistair.francis@wdc.com>
Message-ID: <20260514194537.2416243-2-daniel.barboza@oss.qualcomm.com>
Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
(cherry picked from commit 18645f19578955ec5ff2c40cd2c8753d6bc460c2)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
| -rw-r--r-- | target/riscv/csr.c | 5 |
1 files changed, 1 insertions, 4 deletions
diff --git a/target/riscv/csr.c b/target/riscv/csr.c index a62b16feae..5e1b840087 100644 --- a/target/riscv/csr.c +++ b/target/riscv/csr.c @@ -2014,9 +2014,6 @@ static RISCVException write_mstatus(CPURISCVState *env, int csrno, } if (xl != MXL_RV32 || env->debugger) { - if (riscv_has_ext(env, RVH)) { - mask |= MSTATUS_MPV | MSTATUS_GVA; - } if ((val & MSTATUS64_UXL) != 0) { mask |= MSTATUS64_UXL; } @@ -2053,7 +2050,7 @@ static RISCVException write_mstatush(CPURISCVState *env, int csrno, target_ulong val) { uint64_t valh = (uint64_t)val << 32; - uint64_t mask = riscv_has_ext(env, RVH) ? MSTATUS_MPV | MSTATUS_GVA : 0; + uint64_t mask = 0; if (riscv_cpu_cfg(env)->ext_smdbltrp) { mask |= MSTATUS_MDT; |
