Skip to content

Commit 3b467b1

Browse files
author
Marc Zyngier
committed
KVM: arm64: Force injection of a data abort on NISV MMIO exit
If a vcpu exits for a data abort with an invalid syndrome, the expectations are that userspace has a chance to save the day if it has requested to see such exits. However, this is completely futile in the case of a protected VM, as none of the state is available. In this particular case, inject a data abort directly into the vcpu, consistent with what userspace could do. This also helps with pKVM, which discards all syndrome information when forwarding data aborts that are not known to be MMIO. Finally, document this tweak to the API. Signed-off-by: Fuad Tabba <[email protected]> Acked-by: Oliver Upton <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Marc Zyngier <[email protected]>
1 parent 9253699 commit 3b467b1

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Documentation/virt/kvm/api.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6894,6 +6894,13 @@ Note that KVM does not skip the faulting instruction as it does for
68946894
KVM_EXIT_MMIO, but userspace has to emulate any change to the processing state
68956895
if it decides to decode and emulate the instruction.
68966896

6897+
This feature isn't available to protected VMs, as userspace does not
6898+
have access to the state that is required to perform the emulation.
6899+
Instead, a data abort exception is directly injected in the guest.
6900+
Note that although KVM_CAP_ARM_NISV_TO_USER will be reported if
6901+
queried outside of a protected VM context, the feature will not be
6902+
exposed if queried on a protected VM file descriptor.
6903+
68976904
::
68986905

68996906
/* KVM_EXIT_X86_RDMSR / KVM_EXIT_X86_WRMSR */

arch/arm64/kvm/mmio.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,19 @@ int io_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa)
133133
/*
134134
* No valid syndrome? Ask userspace for help if it has
135135
* volunteered to do so, and bail out otherwise.
136+
*
137+
* In the protected VM case, there isn't much userspace can do
138+
* though, so directly deliver an exception to the guest.
136139
*/
137140
if (!kvm_vcpu_dabt_isvalid(vcpu)) {
138141
trace_kvm_mmio_nisv(*vcpu_pc(vcpu), kvm_vcpu_get_esr(vcpu),
139142
kvm_vcpu_get_hfar(vcpu), fault_ipa);
140143

144+
if (vcpu_is_protected(vcpu)) {
145+
kvm_inject_dabt(vcpu, kvm_vcpu_get_hfar(vcpu));
146+
return 1;
147+
}
148+
141149
if (test_bit(KVM_ARCH_FLAG_RETURN_NISV_IO_ABORT_TO_USER,
142150
&vcpu->kvm->arch.flags)) {
143151
run->exit_reason = KVM_EXIT_ARM_NISV;

0 commit comments

Comments
 (0)