Skip to content

Commit e590879

Browse files
committed
arm64: debug: remove debug exception registration infrastructure
JIRA: https://issues.redhat.com/browse/RHEL-65658 CONFLICTS: context due to the lack of commit 8ce71d2 ("arm64/traps: Handle GCS exceptions") and commit 25b8400 ("arm64: Support Clang UBSAN trap codes for better reporting") commit a8b8cce Author: Ada Couprie Diaz <ada.coupriediaz@arm.com> Date: Mon Jul 7 12:41:09 2025 +0100 arm64: debug: remove debug exception registration infrastructure Now that debug exceptions are handled individually and without the need for dynamic registration, remove the unused registration infrastructure. This removes the external caller for `debug_exception_enter()` and `debug_exception_exit()`. Make them static again and remove them from the header. Remove `early_brk64()` as it has been made redundant by (arm64: debug: split brk64 exception entry) and is not used anymore. Note : in `early_brk64()` `bug_brk_handler()` is called unconditionally as a fall-through, but now `call_break_hook()` only calls it if the immediate matches. This does not change the behaviour in early boot, as if `bug_brk_handler()` was called on a non-BUG immediate it would return DBG_HOOK_ERROR anyway, which `call_break_hook()` will do if no immediate matches. Remove `trap_init()`, as it would be empty and a weak definition already exists in `init/main.c`. 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-14-ada.coupriediaz@arm.com Signed-off-by: Will Deacon <will@kernel.org> Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com>
1 parent 551ce83 commit e590879

File tree

7 files changed

+2
-94
lines changed

7 files changed

+2
-94
lines changed

arch/arm64/include/asm/debug-monitors.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,5 @@ static inline bool try_step_suspended_breakpoints(struct pt_regs *regs)
9393

9494
bool try_handle_aarch32_break(struct pt_regs *regs);
9595

96-
void debug_traps_init(void);
97-
9896
#endif /* __ASSEMBLY */
9997
#endif /* __ASM_DEBUG_MONITORS_H */

arch/arm64/include/asm/exception.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,6 @@ void do_el0_undef(struct pt_regs *regs, unsigned long esr);
5757
void do_el1_undef(struct pt_regs *regs, unsigned long esr);
5858
void do_el0_bti(struct pt_regs *regs);
5959
void do_el1_bti(struct pt_regs *regs, unsigned long esr);
60-
void do_debug_exception(unsigned long addr_if_watchpoint, unsigned long esr,
61-
struct pt_regs *regs);
6260
#ifdef CONFIG_HAVE_HW_BREAKPOINT
6361
void do_breakpoint(unsigned long esr, struct pt_regs *regs);
6462
void do_watchpoint(unsigned long addr, unsigned long esr,
@@ -91,8 +89,4 @@ void do_serror(struct pt_regs *regs, unsigned long esr);
9189
void do_signal(struct pt_regs *regs);
9290

9391
void __noreturn panic_bad_stack(struct pt_regs *regs, unsigned long esr, unsigned long far);
94-
95-
void debug_exception_enter(struct pt_regs *regs);
96-
void debug_exception_exit(struct pt_regs *regs);
97-
9892
#endif /* __ASM_EXCEPTION_H */

arch/arm64/include/asm/system_misc.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ void arm64_notify_die(const char *str, struct pt_regs *regs,
2525
int signo, int sicode, unsigned long far,
2626
unsigned long err);
2727

28-
void hook_debug_fault_code(int nr, int (*fn)(unsigned long, unsigned long,
29-
struct pt_regs *),
30-
int sig, int code, const char *name);
31-
3228
struct mm_struct;
3329
extern void __show_regs(struct pt_regs *);
3430

arch/arm64/kernel/debug-monitors.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,9 +313,6 @@ bool try_handle_aarch32_break(struct pt_regs *regs)
313313
}
314314
NOKPROBE_SYMBOL(try_handle_aarch32_break);
315315

316-
void __init debug_traps_init(void)
317-
{}
318-
319316
/* Re-enable single step for syscall restarting. */
320317
void user_rewind_single_step(struct task_struct *task)
321318
{

arch/arm64/kernel/entry-common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ static inline void fp_user_discard(void)
425425
* accidentally schedule in exception context and it will force a warning
426426
* if we somehow manage to schedule by accident.
427427
*/
428-
void debug_exception_enter(struct pt_regs *regs)
428+
static void debug_exception_enter(struct pt_regs *regs)
429429
{
430430
preempt_disable();
431431

@@ -434,7 +434,7 @@ void debug_exception_enter(struct pt_regs *regs)
434434
}
435435
NOKPROBE_SYMBOL(debug_exception_enter);
436436

437-
void debug_exception_exit(struct pt_regs *regs)
437+
static void debug_exception_exit(struct pt_regs *regs)
438438
{
439439
preempt_enable_no_resched();
440440
}

arch/arm64/kernel/traps.c

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1061,27 +1061,3 @@ int kasan_brk_handler(struct pt_regs *regs, unsigned long esr)
10611061
return DBG_HOOK_HANDLED;
10621062
}
10631063
#endif
1064-
1065-
1066-
/*
1067-
* Initial handler for AArch64 BRK exceptions
1068-
* This handler only used until debug_traps_init().
1069-
*/
1070-
int __init early_brk64(unsigned long addr, unsigned long esr,
1071-
struct pt_regs *regs)
1072-
{
1073-
#ifdef CONFIG_CFI_CLANG
1074-
if (esr_is_cfi_brk(esr))
1075-
return cfi_brk_handler(regs, esr) != DBG_HOOK_HANDLED;
1076-
#endif
1077-
#ifdef CONFIG_KASAN_SW_TAGS
1078-
if ((esr_brk_comment(esr) & ~KASAN_BRK_MASK) == KASAN_BRK_IMM)
1079-
return kasan_brk_handler(regs, esr) != DBG_HOOK_HANDLED;
1080-
#endif
1081-
return bug_brk_handler(regs, esr) != DBG_HOOK_HANDLED;
1082-
}
1083-
1084-
void __init trap_init(void)
1085-
{
1086-
debug_traps_init();
1087-
}

arch/arm64/mm/fault.c

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -52,18 +52,12 @@ struct fault_info {
5252
};
5353

5454
static const struct fault_info fault_info[];
55-
static struct fault_info debug_fault_info[];
5655

5756
static inline const struct fault_info *esr_to_fault_info(unsigned long esr)
5857
{
5958
return fault_info + (esr & ESR_ELx_FSC);
6059
}
6160

62-
static inline const struct fault_info *esr_to_debug_fault_info(unsigned long esr)
63-
{
64-
return debug_fault_info + DBG_ESR_EVT(esr);
65-
}
66-
6761
static void data_abort_decode(unsigned long esr)
6862
{
6963
unsigned long iss2 = ESR_ELx_ISS2(esr);
@@ -857,53 +851,6 @@ void do_sp_pc_abort(unsigned long addr, unsigned long esr, struct pt_regs *regs)
857851
}
858852
NOKPROBE_SYMBOL(do_sp_pc_abort);
859853

860-
/*
861-
* __refdata because early_brk64 is __init, but the reference to it is
862-
* clobbered at arch_initcall time.
863-
* See traps.c and debug-monitors.c:debug_traps_init().
864-
*/
865-
static struct fault_info __refdata debug_fault_info[] = {
866-
{ do_bad, SIGTRAP, TRAP_HWBKPT, "hardware breakpoint" },
867-
{ do_bad, SIGTRAP, TRAP_HWBKPT, "hardware single-step" },
868-
{ do_bad, SIGTRAP, TRAP_HWBKPT, "hardware watchpoint" },
869-
{ do_bad, SIGKILL, SI_KERNEL, "unknown 3" },
870-
{ do_bad, SIGTRAP, TRAP_BRKPT, "aarch32 BKPT" },
871-
{ do_bad, SIGKILL, SI_KERNEL, "aarch32 vector catch" },
872-
{ early_brk64, SIGTRAP, TRAP_BRKPT, "aarch64 BRK" },
873-
{ do_bad, SIGKILL, SI_KERNEL, "unknown 7" },
874-
};
875-
876-
void __init hook_debug_fault_code(int nr,
877-
int (*fn)(unsigned long, unsigned long, struct pt_regs *),
878-
int sig, int code, const char *name)
879-
{
880-
BUG_ON(nr < 0 || nr >= ARRAY_SIZE(debug_fault_info));
881-
882-
debug_fault_info[nr].fn = fn;
883-
debug_fault_info[nr].sig = sig;
884-
debug_fault_info[nr].code = code;
885-
debug_fault_info[nr].name = name;
886-
}
887-
888-
void do_debug_exception(unsigned long addr_if_watchpoint, unsigned long esr,
889-
struct pt_regs *regs)
890-
{
891-
const struct fault_info *inf = esr_to_debug_fault_info(esr);
892-
unsigned long pc = instruction_pointer(regs);
893-
894-
debug_exception_enter(regs);
895-
896-
if (user_mode(regs) && !is_ttbr0_addr(pc))
897-
arm64_apply_bp_hardening();
898-
899-
if (inf->fn(addr_if_watchpoint, esr, regs)) {
900-
arm64_notify_die(inf->name, regs, inf->sig, inf->code, pc, esr);
901-
}
902-
903-
debug_exception_exit(regs);
904-
}
905-
NOKPROBE_SYMBOL(do_debug_exception);
906-
907854
/*
908855
* Used during anonymous page fault handling.
909856
*/

0 commit comments

Comments
 (0)