Skip to content

Commit 02949f3

Browse files
Quentin PerretMarc Zyngier
authored andcommitted
KVM: arm64: Avoid BUG-ing from the host abort path
Under certain circumstances __get_fault_info() may resolve the faulting address using the AT instruction. Given that this is being done outside of the host lock critical section, it is racy and the resolution via AT may fail. We currently BUG() in this situation, which is obviously less than ideal. Moving the address resolution to the critical section may have a performance impact, so let's keep it where it is, but bail out and return to the host to try a second time. Signed-off-by: Quentin Perret <qperret@google.com> Signed-off-by: Fuad Tabba <tabba@google.com> Acked-by: Oliver Upton <oliver.upton@linux.dev> Link: https://lore.kernel.org/r/20240423150538.2103045-7-tabba@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent cb16301 commit 02949f3

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

arch/arm64/kvm/hyp/nvhe/mem_protect.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,13 @@ void handle_host_mem_abort(struct kvm_cpu_context *host_ctxt)
533533
int ret = 0;
534534

535535
esr = read_sysreg_el2(SYS_ESR);
536-
BUG_ON(!__get_fault_info(esr, &fault));
536+
if (!__get_fault_info(esr, &fault)) {
537+
/*
538+
* We've presumably raced with a page-table change which caused
539+
* AT to fail, try again.
540+
*/
541+
return;
542+
}
537543

538544
addr = (fault.hpfar_el2 & HPFAR_MASK) << 8;
539545
ret = host_stage2_idmap(addr);

0 commit comments

Comments
 (0)