]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
target/riscv: Do not allow sfence.vma from user mode
authorJonathan Behrens <fintelia@gmail.com>
Mon, 1 Apr 2019 19:12:07 +0000 (15:12 -0400)
committerPalmer Dabbelt <palmer@sifive.com>
Fri, 24 May 2019 19:09:19 +0000 (12:09 -0700)
The 'sfence.vma' instruction is privileged, and should only ever be allowed
when executing in supervisor mode or higher.

Signed-off-by: Jonathan Behrens <fintelia@gmail.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
target/riscv/op_helper.c

index b7dc18a41e219ce78b4b3dcc0f9e210748f876f7..644d0fb35f16cc77b2dda14e6379f57daf353065 100644 (file)
@@ -145,9 +145,10 @@ void helper_tlb_flush(CPURISCVState *env)
 {
     RISCVCPU *cpu = riscv_env_get_cpu(env);
     CPUState *cs = CPU(cpu);
-    if (env->priv == PRV_S &&
-        env->priv_ver >= PRIV_VERSION_1_10_0 &&
-        get_field(env->mstatus, MSTATUS_TVM)) {
+    if (!(env->priv >= PRV_S) ||
+        (env->priv == PRV_S &&
+         env->priv_ver >= PRIV_VERSION_1_10_0 &&
+         get_field(env->mstatus, MSTATUS_TVM))) {
         riscv_raise_exception(env, RISCV_EXCP_ILLEGAL_INST, GETPC());
     } else {
         tlb_flush(cs);