[PATCH v3 12/13] arm64: debug: split bkpt32 exception entry

Mark Rutland mark.rutland at arm.com
Wed Jun 18 10:06:28 PDT 2025


On Mon, Jun 09, 2025 at 06:34:12PM +0100, Ada Couprie Diaz wrote:
> Currently all debug exceptions share common entry code and are routed
> to `do_debug_exception()`, which calls dynamically-registered
> handlers for each specific debug exception. This is unfortunate as
> different debug exceptions have different entry handling requirements,
> and it would be better to handle these distinct requirements earlier.
> 
> The BKPT32 exception can only be triggered by a BKPT instruction. Thus,
> we know that the PC is a legitimate address and isn't being used to train
> a branch predictor with a bogus address : we don't need to call
> `arm64_apply_bp_hardening()`.
> 
> The handler for this exception only pends a signal and doesn't depend
> on any per-CPU state : we don't need to inhibit preemption, nor do we
> need to keep the DAIF exceptions masked, so we can unmask them earlier.
> 
> Split the BKPT32 exception entry and adjust function signatures and its
> behaviour to match its relaxed constraints compared to other
> debug exceptions.
> 
> This replaces the last usage of `el0_dbg()`, so remove it.
> 
> Signed-off-by: Ada Couprie Diaz <ada.coupriediaz at arm.com>

> +#ifdef CONFIG_COMPAT
> +void do_bkpt32(unsigned long esr, struct pt_regs *regs)
> +{
> +	arm64_notify_die("aarch32 BKPT", regs, SIGTRAP, TRAP_BRKPT, regs->pc, esr);
> +}
> +NOKPROBE_SYMBOL(do_bkpt32);
> +#endif /* CONFIG_COMPAT */

Trivial nit: we can drop NOKPROBE_SYMBOL() here, since do_bkpt32() can't
be recurse within kprobes.

Otherwise this all looks good to me!

Mark.



More information about the linux-arm-kernel mailing list