arm64: debug: call software breakpoint handlers statically
authorAda Couprie Diaz <ada.coupriediaz@arm.com>
Mon, 7 Jul 2025 11:40:59 +0000 (12:40 +0100)
committerWill Deacon <will@kernel.org>
Tue, 8 Jul 2025 12:27:41 +0000 (13:27 +0100)
commit6adfdc5e2ef9c71a76d8d127a2eb54f0fbe9be5e
tree206f13b36bed122dc1c8933bb9cdba87c775c4fb
parentb1e2d95524e4d0f5b643394c739212869e95cf6a
arm64: debug: call software breakpoint handlers statically

Software breakpoints pass an immediate value in ESR ("comment") that can
be used to call a specialized handler (KGDB, KASAN...).
We do so in two different ways :
 - During early boot, `early_brk64` statically checks against known
   immediates and calls the corresponding handler,
 - During init, handlers are dynamically registered into a list. When
   called, the generic software breakpoint handler will iterate over
   the list to find the appropriate handler.

The dynamic registration does not provide any benefit here as it is not
exported and all its uses are within the arm64 tree. It also depends on an
RCU list, whose safe access currently relies on the non-preemptible state
of `do_debug_exception`.

Replace the list iteration logic in `call_break_hooks` to call
the breakpoint handlers statically if they are enabled, like in
`early_brk64`.
Expose the handlers in their respective headers to be reachable from
`arch/arm64/kernel/debug-monitors.c` at link time.

Unify the naming of the software breakpoint handlers to XXX_brk_handler(),
making it clear they are related and to differentiate from the
hardware breakpoints.

Signed-off-by: Ada Couprie Diaz <ada.coupriediaz@arm.com>
Tested-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com>
Reviewed-by: Will Deacon <will@kernel.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Link: https://lore.kernel.org/r/20250707114109.35672-4-ada.coupriediaz@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/include/asm/kgdb.h
arch/arm64/include/asm/kprobes.h
arch/arm64/include/asm/traps.h
arch/arm64/include/asm/uprobes.h
arch/arm64/kernel/debug-monitors.c
arch/arm64/kernel/kgdb.c
arch/arm64/kernel/probes/kprobes.c
arch/arm64/kernel/probes/kprobes_trampoline.S
arch/arm64/kernel/probes/uprobes.c
arch/arm64/kernel/traps.c