diff options
author | wchen <waylingii@gmail.com> | 2023-05-20 18:01:16 +0300 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2023-06-06 06:34:11 +0300 |
commit | 19bff88e65b552f54c191e600498bd50ff47e1ef (patch) | |
tree | b7b06a0ac002f1773476916f9d3c6079dadaba78 /arch/riscv/kvm | |
parent | 78329084b86436b9a77cedd3e1331734c442d413 (diff) | |
download | linux-19bff88e65b552f54c191e600498bd50ff47e1ef.tar.xz |
RISC-V: KVM: Redirect AMO load/store misaligned traps to guest
The M-mode redirects an unhandled misaligned 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.
Here is a way to handle misaligned traps in KVM,
not only directing them to VS-mode or terminate it.
Signed-off-by: wchen <waylingII@gmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Anup Patel <anup@brainfault.org>
Diffstat (limited to 'arch/riscv/kvm')
-rw-r--r-- | arch/riscv/kvm/vcpu_exit.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/arch/riscv/kvm/vcpu_exit.c b/arch/riscv/kvm/vcpu_exit.c index 4ea101a73d8b..2415722c01b8 100644 --- a/arch/riscv/kvm/vcpu_exit.c +++ b/arch/riscv/kvm/vcpu_exit.c @@ -183,6 +183,8 @@ int kvm_riscv_vcpu_exit(struct kvm_vcpu *vcpu, struct kvm_run *run, run->exit_reason = KVM_EXIT_UNKNOWN; switch (trap->scause) { case EXC_INST_ILLEGAL: + case EXC_LOAD_MISALIGNED: + case EXC_STORE_MISALIGNED: if (vcpu->arch.guest_context.hstatus & HSTATUS_SPV) { kvm_riscv_vcpu_trap_redirect(vcpu, trap); ret = 1; |