[PATCH v2 10/11] arm64: debug: split bkpt32 exception entry

Will Deacon will at kernel.org
Wed May 21 02:07:20 PDT 2025


On Mon, May 12, 2025 at 06:43:25PM +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>
> ---
>  arch/arm64/include/asm/exception.h |  1 +
>  arch/arm64/kernel/debug-monitors.c |  9 +++++++++
>  arch/arm64/kernel/entry-common.c   | 21 +++++++++------------
>  3 files changed, 19 insertions(+), 12 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/exception.h b/arch/arm64/include/asm/exception.h
> index af9b521e35f9..4ca43d4eaf98 100644
> --- a/arch/arm64/include/asm/exception.h
> +++ b/arch/arm64/include/asm/exception.h
> @@ -66,6 +66,7 @@ void do_softstep(unsigned long esr, struct pt_regs *regs);
>  void do_watchpoint(unsigned long addr, unsigned long esr,
>  			struct pt_regs *regs);
>  void do_brk64(unsigned long esr, struct pt_regs *regs);
> +void do_bkpt32(unsigned long esr, struct pt_regs *regs);
>  void do_fpsimd_acc(unsigned long esr, struct pt_regs *regs);
>  void do_sve_acc(unsigned long esr, struct pt_regs *regs);
>  void do_sme_acc(unsigned long esr, struct pt_regs *regs);
> diff --git a/arch/arm64/kernel/debug-monitors.c b/arch/arm64/kernel/debug-monitors.c
> index 94779c957b70..53f0b2281f14 100644
> --- a/arch/arm64/kernel/debug-monitors.c
> +++ b/arch/arm64/kernel/debug-monitors.c
> @@ -298,6 +298,15 @@ void do_brk64(unsigned long esr, struct pt_regs *regs)
>  }
>  NOKPROBE_SYMBOL(do_brk64);
>  
> +#ifdef CONFIG_COMPAT
> +/* BRKPT exception always traps to be handled. */

nit: I don't understand this comment

Will



More information about the linux-arm-kernel mailing list