]> www.infradead.org Git - nvme.git/commitdiff
RISC-V: KVM: Redirect AMO load/store access fault traps to guest
authorYu-Wei Hsu <betterman5240@gmail.com>
Mon, 29 Apr 2024 09:21:13 +0000 (09:21 +0000)
committerAnup Patel <anup@brainfault.org>
Wed, 26 Jun 2024 13:07:41 +0000 (18:37 +0530)
The KVM RISC-V does not delegate AMO load/store access fault traps to
VS-mode (hedeleg) so typically M-mode takes these traps and redirects
them back to HS-mode. However, upon returning from M-mode, the KVM
RISC-V running in HS-mode terminates VS-mode software.

The KVM RISC-V should redirect AMO load/store access fault traps back
to VS-mode and let the VS-mode trap handler determine the next steps.

Signed-off-by: Yu-Wei Hsu <betterman5240@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20240429092113.70695-1-betterman5240@gmail.com
Signed-off-by: Anup Patel <anup@brainfault.org>
arch/riscv/kvm/vcpu_exit.c

index 5761f95abb60be3735171b4b7fff2c8ebabe600e..fa98e5c024b219a3312f98c2821dcc5ae3e32819 100644 (file)
@@ -185,6 +185,8 @@ int kvm_riscv_vcpu_exit(struct kvm_vcpu *vcpu, struct kvm_run *run,
        case EXC_INST_ILLEGAL:
        case EXC_LOAD_MISALIGNED:
        case EXC_STORE_MISALIGNED:
+       case EXC_LOAD_ACCESS:
+       case EXC_STORE_ACCESS:
                if (vcpu->arch.guest_context.hstatus & HSTATUS_SPV) {
                        kvm_riscv_vcpu_trap_redirect(vcpu, trap);
                        ret = 1;