Commit 44669275 authored by Mostafa Saleh's avatar Mostafa Saleh Committed by Marc Zyngier
Browse files

KVM: arm64: Handle UBSAN faults



As now UBSAN can be enabled, handle brk64 exits from UBSAN.
Re-use the decoding code from the kernel, and panic with
UBSAN message.

Signed-off-by: default avatarMostafa Saleh <smostafa@google.com>
Reviewed-by: default avatarKees Cook <kees@kernel.org>
Link: https://lore.kernel.org/r/20250430162713.1997569-5-smostafa@google.com


Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
parent 61b38f75
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@

#include <linux/kvm.h>
#include <linux/kvm_host.h>
#include <linux/ubsan.h>

#include <asm/esr.h>
#include <asm/exception.h>
@@ -474,6 +475,11 @@ void __noreturn __cold nvhe_hyp_panic_handler(u64 esr, u64 spsr,
			print_nvhe_hyp_panic("BUG", panic_addr);
	} else if (IS_ENABLED(CONFIG_CFI_CLANG) && esr_is_cfi_brk(esr)) {
		kvm_nvhe_report_cfi_failure(panic_addr);
	} else if (IS_ENABLED(CONFIG_UBSAN_KVM_EL2) &&
		   ESR_ELx_EC(esr) == ESR_ELx_EC_BRK64 &&
		   esr_is_ubsan_brk(esr)) {
		print_nvhe_hyp_panic(report_ubsan_failure(esr & UBSAN_BRK_MASK),
				     panic_addr);
	} else {
		print_nvhe_hyp_panic("panic", panic_addr);
	}