Skip to content

Commit a8b8cce

Browse files
Ada Couprie Diazwilldeacon
authored andcommitted
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 <[email protected]> Tested-by: Luis Claudio R. Goncalves <[email protected]> Reviewed-by: Will Deacon <[email protected]> Acked-by: Mark Rutland <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent fc5e5d0 commit a8b8cce

File tree

7 files changed

+2
-97
lines changed

7 files changed

+2
-97
lines changed

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

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

9595
bool try_handle_aarch32_break(struct pt_regs *regs);
9696

97-
void debug_traps_init(void);
98-
9997
#endif /* __ASSEMBLY */
10098
#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
@@ -59,8 +59,6 @@ void do_el0_bti(struct pt_regs *regs);
5959
void do_el1_bti(struct pt_regs *regs, unsigned long esr);
6060
void do_el0_gcs(struct pt_regs *regs, unsigned long esr);
6161
void do_el1_gcs(struct pt_regs *regs, unsigned long esr);
62-
void do_debug_exception(unsigned long addr_if_watchpoint, unsigned long esr,
63-
struct pt_regs *regs);
6462
#ifdef CONFIG_HAVE_HW_BREAKPOINT
6563
void do_breakpoint(unsigned long esr, struct pt_regs *regs);
6664
void do_watchpoint(unsigned long addr, unsigned long esr,
@@ -94,8 +92,4 @@ void do_serror(struct pt_regs *regs, unsigned long esr);
9492
void do_signal(struct pt_regs *regs);
9593

9694
void __noreturn panic_bad_stack(struct pt_regs *regs, unsigned long esr, unsigned long far);
97-
98-
void debug_exception_enter(struct pt_regs *regs);
99-
void debug_exception_exit(struct pt_regs *regs);
100-
10195
#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
@@ -316,9 +316,6 @@ bool try_handle_aarch32_break(struct pt_regs *regs)
316316
}
317317
NOKPROBE_SYMBOL(try_handle_aarch32_break);
318318

319-
void __init debug_traps_init(void)
320-
{}
321-
322319
/* Re-enable single step for syscall restarting. */
323320
void user_rewind_single_step(struct task_struct *task)
324321
{

arch/arm64/kernel/entry-common.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ static __always_inline void fpsimd_syscall_exit(void)
448448
* accidentally schedule in exception context and it will force a warning
449449
* if we somehow manage to schedule by accident.
450450
*/
451-
void debug_exception_enter(struct pt_regs *regs)
451+
static void debug_exception_enter(struct pt_regs *regs)
452452
{
453453
preempt_disable();
454454

@@ -457,7 +457,7 @@ void debug_exception_enter(struct pt_regs *regs)
457457
}
458458
NOKPROBE_SYMBOL(debug_exception_enter);
459459

460-
void debug_exception_exit(struct pt_regs *regs)
460+
static void debug_exception_exit(struct pt_regs *regs)
461461
{
462462
preempt_enable_no_resched();
463463
}

arch/arm64/kernel/traps.c

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,30 +1100,3 @@ int ubsan_brk_handler(struct pt_regs *regs, unsigned long esr)
11001100
return DBG_HOOK_HANDLED;
11011101
}
11021102
#endif
1103-
1104-
/*
1105-
* Initial handler for AArch64 BRK exceptions
1106-
* This handler only used until debug_traps_init().
1107-
*/
1108-
int __init early_brk64(unsigned long addr, unsigned long esr,
1109-
struct pt_regs *regs)
1110-
{
1111-
#ifdef CONFIG_CFI_CLANG
1112-
if (esr_is_cfi_brk(esr))
1113-
return cfi_brk_handler(regs, esr) != DBG_HOOK_HANDLED;
1114-
#endif
1115-
#ifdef CONFIG_KASAN_SW_TAGS
1116-
if ((esr_brk_comment(esr) & ~KASAN_BRK_MASK) == KASAN_BRK_IMM)
1117-
return kasan_brk_handler(regs, esr) != DBG_HOOK_HANDLED;
1118-
#endif
1119-
#ifdef CONFIG_UBSAN_TRAP
1120-
if (esr_is_ubsan_brk(esr))
1121-
return ubsan_brk_handler(regs, esr) != DBG_HOOK_HANDLED;
1122-
#endif
1123-
return bug_brk_handler(regs, esr) != DBG_HOOK_HANDLED;
1124-
}
1125-
1126-
void __init trap_init(void)
1127-
{
1128-
debug_traps_init();
1129-
}

arch/arm64/mm/fault.c

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

5555
static const struct fault_info fault_info[];
56-
static struct fault_info debug_fault_info[];
5756

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

63-
static inline const struct fault_info *esr_to_debug_fault_info(unsigned long esr)
64-
{
65-
return debug_fault_info + DBG_ESR_EVT(esr);
66-
}
67-
6862
static void data_abort_decode(unsigned long esr)
6963
{
7064
unsigned long iss2 = ESR_ELx_ISS2(esr);
@@ -938,53 +932,6 @@ void do_sp_pc_abort(unsigned long addr, unsigned long esr, struct pt_regs *regs)
938932
}
939933
NOKPROBE_SYMBOL(do_sp_pc_abort);
940934

941-
/*
942-
* __refdata because early_brk64 is __init, but the reference to it is
943-
* clobbered at arch_initcall time.
944-
* See traps.c and debug-monitors.c:debug_traps_init().
945-
*/
946-
static struct fault_info __refdata debug_fault_info[] = {
947-
{ do_bad, SIGTRAP, TRAP_HWBKPT, "hardware breakpoint" },
948-
{ do_bad, SIGTRAP, TRAP_HWBKPT, "hardware single-step" },
949-
{ do_bad, SIGTRAP, TRAP_HWBKPT, "hardware watchpoint" },
950-
{ do_bad, SIGKILL, SI_KERNEL, "unknown 3" },
951-
{ do_bad, SIGTRAP, TRAP_BRKPT, "aarch32 BKPT" },
952-
{ do_bad, SIGKILL, SI_KERNEL, "aarch32 vector catch" },
953-
{ early_brk64, SIGTRAP, TRAP_BRKPT, "aarch64 BRK" },
954-
{ do_bad, SIGKILL, SI_KERNEL, "unknown 7" },
955-
};
956-
957-
void __init hook_debug_fault_code(int nr,
958-
int (*fn)(unsigned long, unsigned long, struct pt_regs *),
959-
int sig, int code, const char *name)
960-
{
961-
BUG_ON(nr < 0 || nr >= ARRAY_SIZE(debug_fault_info));
962-
963-
debug_fault_info[nr].fn = fn;
964-
debug_fault_info[nr].sig = sig;
965-
debug_fault_info[nr].code = code;
966-
debug_fault_info[nr].name = name;
967-
}
968-
969-
void do_debug_exception(unsigned long addr_if_watchpoint, unsigned long esr,
970-
struct pt_regs *regs)
971-
{
972-
const struct fault_info *inf = esr_to_debug_fault_info(esr);
973-
unsigned long pc = instruction_pointer(regs);
974-
975-
debug_exception_enter(regs);
976-
977-
if (user_mode(regs) && !is_ttbr0_addr(pc))
978-
arm64_apply_bp_hardening();
979-
980-
if (inf->fn(addr_if_watchpoint, esr, regs)) {
981-
arm64_notify_die(inf->name, regs, inf->sig, inf->code, pc, esr);
982-
}
983-
984-
debug_exception_exit(regs);
985-
}
986-
NOKPROBE_SYMBOL(do_debug_exception);
987-
988935
/*
989936
* Used during anonymous page fault handling.
990937
*/

0 commit comments

Comments
 (0)