Skip to content

Commit 022c832

Browse files
willdeaconMarc Zyngier
authored andcommitted
KVM: arm64: Move S1PTW S2 fault logic out of io_mem_abort()
To allow for re-injection of stage-2 faults on stage-1 page-table walks due to either a missing or read-only memslot, move the triage logic out of io_mem_abort() and into kvm_handle_guest_abort(), where these aborts can be handled before anything else. Signed-off-by: Will Deacon <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Cc: Marc Zyngier <[email protected]> Cc: Quentin Perret <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 54dc0d2 commit 022c832

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

arch/arm64/kvm/mmio.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -145,12 +145,6 @@ int io_mem_abort(struct kvm_vcpu *vcpu, struct kvm_run *run,
145145
return -ENOSYS;
146146
}
147147

148-
/* Page table accesses IO mem: tell guest to fix its TTBR */
149-
if (kvm_vcpu_dabt_iss1tw(vcpu)) {
150-
kvm_inject_dabt(vcpu, kvm_vcpu_get_hfar(vcpu));
151-
return 1;
152-
}
153-
154148
/*
155149
* Prepare MMIO operation. First decode the syndrome data we get
156150
* from the CPU. Then try if some in-kernel emulation feels

arch/arm64/kvm/mmu.c

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2105,12 +2105,23 @@ int kvm_handle_guest_abort(struct kvm_vcpu *vcpu, struct kvm_run *run)
21052105
hva = gfn_to_hva_memslot_prot(memslot, gfn, &writable);
21062106
write_fault = kvm_is_write_fault(vcpu);
21072107
if (kvm_is_error_hva(hva) || (write_fault && !writable)) {
2108+
/*
2109+
* The guest has put either its instructions or its page-tables
2110+
* somewhere it shouldn't have. Userspace won't be able to do
2111+
* anything about this (there's no syndrome for a start), so
2112+
* re-inject the abort back into the guest.
2113+
*/
21082114
if (is_iabt) {
2109-
/* Prefetch Abort on I/O address */
21102115
ret = -ENOEXEC;
21112116
goto out;
21122117
}
21132118

2119+
if (kvm_vcpu_dabt_iss1tw(vcpu)) {
2120+
kvm_inject_dabt(vcpu, kvm_vcpu_get_hfar(vcpu));
2121+
ret = 1;
2122+
goto out_unlock;
2123+
}
2124+
21142125
/*
21152126
* Check for a cache maintenance operation. Since we
21162127
* ended-up here, we know it is outside of any memory

0 commit comments

Comments
 (0)