RISC-V: KVM: Fix privilege mode setting in kvm_riscv_vcpu_trap_redirect()
authorAnup Patel <apatel@ventanamicro.com>
Sat, 28 Jan 2023 07:48:25 +0000 (13:18 +0530)
committerAnup Patel <anup@brainfault.org>
Tue, 7 Feb 2023 15:05:26 +0000 (20:35 +0530)
The kvm_riscv_vcpu_trap_redirect() should set guest privilege mode
to supervisor mode because guest traps/interrupts are always handled
in virtual supervisor mode.

Fixes: 9f7013265112 ("RISC-V: KVM: Handle MMIO exits for VCPU")
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Atish Patra <atishp@rivosinc.com>
Signed-off-by: Anup Patel <anup@brainfault.org>
arch/riscv/kvm/vcpu_exit.c

index c9f741ab26f5b8a9d70af94cdad121a36fb5e11d..af7c4bc07929d863f53b830854e1fe3d6d1d67fc 100644 (file)
@@ -160,6 +160,9 @@ void kvm_riscv_vcpu_trap_redirect(struct kvm_vcpu *vcpu,
 
        /* Set Guest PC to Guest exception vector */
        vcpu->arch.guest_context.sepc = csr_read(CSR_VSTVEC);
+
+       /* Set Guest privilege mode to supervisor */
+       vcpu->arch.guest_context.sstatus |= SR_SPP;
 }
 
 /*