Skip to content

Commit dc1fd37

Browse files
misalehMarc Zyngier
authored andcommitted
arm64: Introduce esr_is_ubsan_brk()
Soon, KVM is going to use this logic for hypervisor panics, so add it in a wrapper that can be used by the hypervisor exit handler to decode hyp panics. Signed-off-by: Mostafa Saleh <smostafa@google.com> Reviewed-by: Kees Cook <kees@kernel.org> Link: https://lore.kernel.org/r/20250430162713.1997569-2-smostafa@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 9c32cda commit dc1fd37

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

arch/arm64/include/asm/esr.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,11 @@ static inline bool esr_is_cfi_brk(unsigned long esr)
440440
(esr_brk_comment(esr) & ~CFI_BRK_IMM_MASK) == CFI_BRK_IMM_BASE;
441441
}
442442

443+
static inline bool esr_is_ubsan_brk(unsigned long esr)
444+
{
445+
return (esr_brk_comment(esr) & ~UBSAN_BRK_MASK) == UBSAN_BRK_IMM;
446+
}
447+
443448
static inline bool esr_fsc_is_translation_fault(unsigned long esr)
444449
{
445450
esr = esr & ESR_ELx_FSC;

arch/arm64/kernel/traps.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ int __init early_brk64(unsigned long addr, unsigned long esr,
11451145
return kasan_handler(regs, esr) != DBG_HOOK_HANDLED;
11461146
#endif
11471147
#ifdef CONFIG_UBSAN_TRAP
1148-
if ((esr_brk_comment(esr) & ~UBSAN_BRK_MASK) == UBSAN_BRK_IMM)
1148+
if (esr_is_ubsan_brk(esr))
11491149
return ubsan_handler(regs, esr) != DBG_HOOK_HANDLED;
11501150
#endif
11511151
return bug_handler(regs, esr) != DBG_HOOK_HANDLED;

0 commit comments

Comments
 (0)