]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
target/riscv: Record misa_ext in TCGTBCPUState.cs_base
authorRichard Henderson <richard.henderson@linaro.org>
Fri, 5 Sep 2025 16:53:50 +0000 (18:53 +0200)
committerRichard Henderson <richard.henderson@linaro.org>
Wed, 24 Sep 2025 17:29:43 +0000 (10:29 -0700)
The tb_flush within write_misa was incorrect.  It assumed
that we could adjust the ISA of the current processor and
discard all TB and all would be well.  But MISA is per vcpu,
so globally flushing TB does not mean that the TB matches
the MISA of any given vcpu.

By recording misa in the tb state, we ensure that the code
generated matches the vcpu.

Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
target/riscv/csr.c
target/riscv/tcg/tcg-cpu.c

index 8842e07a735a5db3370c6c64bbf397d4b21888b1..3c8989f522e8ff79ec48b9c833dd7b91a2541775 100644 (file)
@@ -25,7 +25,6 @@
 #include "pmu.h"
 #include "time_helper.h"
 #include "exec/cputlb.h"
-#include "exec/tb-flush.h"
 #include "exec/icount.h"
 #include "accel/tcg/getpc.h"
 #include "qemu/guest-random.h"
@@ -2173,8 +2172,6 @@ static RISCVException write_misa(CPURISCVState *env, int csrno,
         env->mstatus &= ~MSTATUS_FS;
     }
 
-    /* flush translation cache */
-    tb_flush(env_cpu(env));
     env->xl = riscv_cpu_mxl(env);
     return RISCV_EXCP_NONE;
 }
index 78fb2791847e3343dd228fc6d87404b5609e3a25..143ab079d49bf19247b45f3ceb50639cb5819888 100644 (file)
@@ -191,7 +191,8 @@ static TCGTBCPUState riscv_get_tb_cpu_state(CPUState *cs)
 
     return (TCGTBCPUState){
         .pc = env->xl == MXL_RV32 ? env->pc & UINT32_MAX : env->pc,
-        .flags = flags
+        .flags = flags,
+        .cs_base = env->misa_ext,
     };
 }