]> Git Repo - qemu.git/commitdiff
target/riscv: Fix VS mode hypervisor CSR access
authorDylan Reid <[email protected]>
Fri, 6 May 2022 16:54:57 +0000 (16:54 +0000)
committerAlistair Francis <[email protected]>
Mon, 23 May 2022 23:48:20 +0000 (09:48 +1000)
VS mode access to hypervisor CSRs should generate virtual, not illegal,
instruction exceptions.

Don't return early and indicate an illegal instruction exception when
accessing a hypervisor CSR from VS mode. Instead, fall through to the
`hmode` predicate to return the correct virtual instruction exception.

Signed-off-by: Dylan Reid <[email protected]>
Reviewed-by: Alistair Francis <[email protected]>
Message-Id: <20220506165456[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
target/riscv/csr.c

index 3500e07f92e1610dd58b3fcee8d7af6832b244a7..4ea7df02c933a0b806321e74003268d652a1f00a 100644 (file)
@@ -3141,13 +3141,13 @@ static inline RISCVException riscv_csrrw_check(CPURISCVState *env,
 #if !defined(CONFIG_USER_ONLY)
     int effective_priv = env->priv;
 
-    if (riscv_has_ext(env, RVH) &&
-        env->priv == PRV_S &&
-        !riscv_cpu_virt_enabled(env)) {
+    if (riscv_has_ext(env, RVH) && env->priv == PRV_S) {
         /*
-         * We are in S mode without virtualisation, therefore we are in HS Mode.
+         * We are in either HS or VS mode.
          * Add 1 to the effective privledge level to allow us to access the
-         * Hypervisor CSRs.
+         * Hypervisor CSRs. The `hmode` predicate will determine if access
+         * should be allowed(HS) or if a virtual instruction exception should be
+         * raised(VS).
          */
         effective_priv++;
     }
This page took 0.030473 seconds and 4 git commands to generate.