Skip to contentSkip to conversation

target/riscv: remove obsolete smstateen check for JVT

PATCH Daniel Henrique Barboza 1 participant 1 message Aug 27 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Daniel Henrique Barboza

author Reviewed-by
#1 lore raw
Quoted 8 lines · Zongmin Zhou

From: Zongmin Zhou <[email protected]>

The RISC-V ISA manual used to (incorrectly) state that the JVT CSR and the cm.jalt/cm.jt instructions are controlled by mstateen0/hstateen0 bit 2. That text was spurious and has been removed from the spec by riscv/riscv-isa-manual PR #2637 (merged 2026-02-05, closing issue #2620).

Quoted 8 lines

Drop the corresponding smstateen_acc_ok() checks from the Zcmt CSR predicate and the cm_jalt() helper, along with the now unused SMSTATEEN0_JVT definition, so that JVT accesses are no longer incorrectly trapped when stateen0 bit 2 is clear.

Reference: https://github.com/riscv/riscv-isa-manual/pull/2637

---

Quoted 53 lines
  target/riscv/cpu_bits.h       | 1 -
  target/riscv/tcg/csr.c        | 7 -------
  target/riscv/tcg/zce_helper.c | 7 -------
  3 files changed, 15 deletions(-)
target/riscv/cpu_bits.h +0 -1
index c01050ce2b..11648abecf 100644
@@ -354,7 +354,6 @@
  #define SMSTATEEN_MAX_COUNT 4
  #define SMSTATEEN0_CS       (1ULL << 0)
  #define SMSTATEEN0_FCSR     (1ULL << 1)
-#define SMSTATEEN0_JVT      (1ULL << 2)
  #define SMSTATEEN0_CTR      (1ULL << 54)
  #define SMSTATEEN0_P1P13    (1ULL << 56)
  #define SMSTATEEN0_HSCONTXT (1ULL << 57)
target/riscv/tcg/csr.c +0 -7
index 78fdd14a08..967626be75 100644
@@ -180,13 +180,6 @@ static RISCVException zcmt(CPURISCVState *env, int csrno)
          return RISCV_EXCP_ILLEGAL_INST;
      }
 
-#if !defined(CONFIG_USER_ONLY)
-    RISCVException ret = smstateen_acc_ok(env, 0, SMSTATEEN0_JVT);
-    if (ret != RISCV_EXCP_NONE) {
-        return ret;
-    }
-#endif
-
      return RISCV_EXCP_NONE;
  }
 
target/riscv/tcg/zce_helper.c +0 -7
index c6ba4c1a47..2fa8945b2d 100644
@@ -28,13 +28,6 @@ target_ulong HELPER(cm_jalt)(CPURISCVState *env, uint32_t index)
      MemOp endian = mo_endian_env(env);
      MemOpIdx oi;
 
-#if !defined(CONFIG_USER_ONLY)
-    RISCVException ret = smstateen_acc_ok(env, 0, SMSTATEEN0_JVT);
-    if (ret != RISCV_EXCP_NONE) {
-        riscv_raise_exception(env, ret, 0);
-    }
-#endif
-
      target_ulong target;
      target_ulong val = env->jvt;
      int xlen = riscv_cpu_xlen(env);