]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
RISC-V: KVM: Redirect instruction access fault trap to guest
authorQuan Zhou <zhouquan@iscas.ac.cn>
Tue, 24 Dec 2024 21:04:53 +0000 (13:04 -0800)
committerAnup Patel <anup@brainfault.org>
Mon, 30 Dec 2024 08:31:02 +0000 (14:01 +0530)
The M-mode redirects an unhandled instruction access
fault trap back to S-mode when not delegating it to
VS-mode(hedeleg). However, KVM running in HS-mode
terminates the VS-mode software when back from M-mode.

The KVM should redirect the trap back to VS-mode, and
let VS-mode trap handler decide the next step.

Signed-off-by: Quan Zhou <zhouquan@iscas.ac.cn>
Reviewed-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Atish Patra <atishp@rivosinc.com>
Link: https://lore.kernel.org/r/20241224-kvm_guest_stat-v2-1-08a77ac36b02@rivosinc.com
Signed-off-by: Anup Patel <anup@brainfault.org>
arch/riscv/kvm/vcpu_exit.c

index fa98e5c024b219a3312f98c2821dcc5ae3e32819..c9f8b2094554381bcda42216bc58e5c6f252ba13 100644 (file)
@@ -187,6 +187,7 @@ int kvm_riscv_vcpu_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,
        case EXC_STORE_MISALIGNED:
        case EXC_LOAD_ACCESS:
        case EXC_STORE_ACCESS:
+       case EXC_INST_ACCESS:
                if (vcpu->arch.guest_context.hstatus & HSTATUS_SPV) {
                        kvm_riscv_vcpu_trap_redirect(vcpu, trap);
                        ret = 1;