Skip to content

Commit 2b0ec56

Browse files
author
CKI KWF Bot
committed
Merge: arm64: debug: remove hook registration, split exception entry
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7265 JIRA: https://issues.redhat.com/browse/RHEL-65658 CONFLICTS: Minor context conflicts as RHEL-9 does not have the following commits: 25b8400 ("arm64: Support Clang UBSAN trap codes for better reporting") d683a85 ("ubsan: Remove regs from report_ubsan_failure()") 8ce71d2 ("arm64/traps: Handle GCS exceptions") 1384022 ("arm64: mops: Handle MOPS exceptions from EL1") 398edaa ("arm64/fpsimd: Do not discard modified SVE state") This series simplifies the debug exception entry path by removing handler registration mechanisms for the debug exception handlers, a holdover from the arm kernel, as well as the break and stepping handlers. This moves much of the code related to debug exceptions outside of `mm/fault.c` where it didn't make much sense. This allows us to split the debug exception entries: going from one common path per EL for all debug exceptions to a unique one per exception and EL. The result is a much simpler and fully static exception entry path, which we tailor to the different exceptions and their constraints. ... Original cover letter and testing procedure can be found here: arm64: debug: remove hook registration, split exception entry (v6) https://lore.kernel.org/linux-arm-kernel/20250707114109.35672-1-ada.coupriediaz@arm.com/ These are the upstream commits backported for this MR: ad8b226 arm64: debug: clean up single_step_handler logic b1e2d95 arm64: refactor aarch32_break_handler() 9a0e3b9 arm64: Return early when break handler is found on linked-list 3b84efc arm64: kprobes: Return DBG_HOOK_ERROR if kprobes can not handle a BRK 2537512 arm64: kretprobes: acquire the regs via a BRK exception 6adfdc5 arm64: debug: call software breakpoint handlers statically 403b48a arm64: debug: call step handlers statically d4e0b12 arm64: debug: remove break/step handler registration infrastructure eaff68b arm64: entry: Add entry and exit functions for debug exceptions 43e2ae7 arm64: debug: split hardware breakpoint exception entry 80691d3 arm64: debug: refactor reinstall_suspended_bps() 0ac7584 arm64: debug: split single stepping exception entry 413f0bb arm64: debug: split hardware watchpoint exception entry 31575e1 arm64: debug: split brk64 exception entry fc5e5d0 arm64: debug: split bkpt32 exception entry 8b09788 trap: cleanup trap_init() a8b8cce arm64: debug: remove debug exception registration infrastructure Special note goes for commits 9a0e3b9, 3b84efc, 2537512 and 8b09788 that were added to fix minor context conflicts. Also, commit Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com> Approved-by: Radu Rendec <rrendec@redhat.com> Approved-by: Alessandro Carminati <acarmina@redhat.com> Approved-by: Aristeu Rozanski <arozansk@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Approved-by: Audra Mitchell <aubaker@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents cbeec68 + e590879 commit 2b0ec56

File tree

29 files changed

+364
-601
lines changed

29 files changed

+364
-601
lines changed

arch/arc/kernel/traps.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,6 @@
2020
#include <asm/unaligned.h>
2121
#include <asm/kprobes.h>
2222

23-
void __init trap_init(void)
24-
{
25-
return;
26-
}
27-
2823
void die(const char *str, struct pt_regs *regs, unsigned long address)
2924
{
3025
show_kernel_fault_diag(str, regs, address);

arch/arm/kernel/traps.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -781,11 +781,6 @@ void abort(void)
781781
panic("Oops failed to kill thread");
782782
}
783783

784-
void __init trap_init(void)
785-
{
786-
return;
787-
}
788-
789784
#ifdef CONFIG_KUSER_HELPERS
790785
static void __init kuser_init(void *vectors)
791786
{

arch/arm64/include/asm/brk-imm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* 0x004: for installing kprobes
1212
* 0x005: for installing uprobes
1313
* 0x006: for kprobe software single-step
14+
* 0x007: for kretprobe return
1415
* Allowed values for kgdb are 0x400 - 0x7ff
1516
* 0x100: for triggering a fault on purpose (reserved)
1617
* 0x400: for dynamic BRK instruction
@@ -22,6 +23,7 @@
2223
#define KPROBES_BRK_IMM 0x004
2324
#define UPROBES_BRK_IMM 0x005
2425
#define KPROBES_BRK_SS_IMM 0x006
26+
#define KRETPROBES_BRK_IMM 0x007
2527
#define FAULT_BRK_IMM 0x100
2628
#define KGDB_DYN_DBG_BRK_IMM 0x400
2729
#define KGDB_COMPILED_DBG_BRK_IMM 0x401

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

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -62,30 +62,6 @@ struct task_struct;
6262
#define DBG_HOOK_HANDLED 0
6363
#define DBG_HOOK_ERROR 1
6464

65-
struct step_hook {
66-
struct list_head node;
67-
int (*fn)(struct pt_regs *regs, unsigned long esr);
68-
};
69-
70-
void register_user_step_hook(struct step_hook *hook);
71-
void unregister_user_step_hook(struct step_hook *hook);
72-
73-
void register_kernel_step_hook(struct step_hook *hook);
74-
void unregister_kernel_step_hook(struct step_hook *hook);
75-
76-
struct break_hook {
77-
struct list_head node;
78-
int (*fn)(struct pt_regs *regs, unsigned long esr);
79-
u16 imm;
80-
u16 mask; /* These bits are ignored when comparing with imm */
81-
};
82-
83-
void register_user_break_hook(struct break_hook *hook);
84-
void unregister_user_break_hook(struct break_hook *hook);
85-
86-
void register_kernel_break_hook(struct break_hook *hook);
87-
void unregister_kernel_break_hook(struct break_hook *hook);
88-
8965
u8 debug_monitors_arch(void);
9066

9167
enum dbg_active_el {
@@ -107,17 +83,15 @@ int kernel_active_single_step(void);
10783
void kernel_rewind_single_step(struct pt_regs *regs);
10884

10985
#ifdef CONFIG_HAVE_HW_BREAKPOINT
110-
int reinstall_suspended_bps(struct pt_regs *regs);
86+
bool try_step_suspended_breakpoints(struct pt_regs *regs);
11187
#else
112-
static inline int reinstall_suspended_bps(struct pt_regs *regs)
88+
static inline bool try_step_suspended_breakpoints(struct pt_regs *regs)
11389
{
114-
return -ENODEV;
90+
return false;
11591
}
11692
#endif
11793

118-
int aarch32_break_handler(struct pt_regs *regs);
119-
120-
void debug_traps_init(void);
94+
bool try_handle_aarch32_break(struct pt_regs *regs);
12195

12296
#endif /* __ASSEMBLY */
12397
#endif /* __ASM_DEBUG_MONITORS_H */

arch/arm64/include/asm/exception.h

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,20 @@ 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,
60+
#ifdef CONFIG_HAVE_HW_BREAKPOINT
61+
void do_breakpoint(unsigned long esr, struct pt_regs *regs);
62+
void do_watchpoint(unsigned long addr, unsigned long esr,
6163
struct pt_regs *regs);
64+
#else
65+
static inline void do_breakpoint(unsigned long esr, struct pt_regs *regs) {}
66+
static inline void do_watchpoint(unsigned long addr, unsigned long esr,
67+
struct pt_regs *regs) {}
68+
#endif /* CONFIG_HAVE_HW_BREAKPOINT */
69+
void do_el0_softstep(unsigned long esr, struct pt_regs *regs);
70+
void do_el1_softstep(unsigned long esr, struct pt_regs *regs);
71+
void do_el0_brk64(unsigned long esr, struct pt_regs *regs);
72+
void do_el1_brk64(unsigned long esr, struct pt_regs *regs);
73+
void do_bkpt32(unsigned long esr, struct pt_regs *regs);
6274
void do_fpsimd_acc(unsigned long esr, struct pt_regs *regs);
6375
void do_sve_acc(unsigned long esr, struct pt_regs *regs);
6476
void do_sme_acc(unsigned long esr, struct pt_regs *regs);

arch/arm64/include/asm/kgdb.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,18 @@ static inline void arch_kgdb_breakpoint(void)
2424
extern void kgdb_handle_bus_error(void);
2525
extern int kgdb_fault_expected;
2626

27+
int kgdb_brk_handler(struct pt_regs *regs, unsigned long esr);
28+
int kgdb_compiled_brk_handler(struct pt_regs *regs, unsigned long esr);
29+
#ifdef CONFIG_KGDB
30+
int kgdb_single_step_handler(struct pt_regs *regs, unsigned long esr);
31+
#else
32+
static inline int kgdb_single_step_handler(struct pt_regs *regs,
33+
unsigned long esr)
34+
{
35+
return DBG_HOOK_ERROR;
36+
}
37+
#endif
38+
2739
#endif /* !__ASSEMBLY__ */
2840

2941
/*

arch/arm64/include/asm/kprobes.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,12 @@ void __kretprobe_trampoline(void);
4343
void __kprobes *trampoline_probe_handler(struct pt_regs *regs);
4444

4545
#endif /* CONFIG_KPROBES */
46+
47+
int __kprobes kprobe_brk_handler(struct pt_regs *regs,
48+
unsigned long esr);
49+
int __kprobes kprobe_ss_brk_handler(struct pt_regs *regs,
50+
unsigned long esr);
51+
int __kprobes kretprobe_brk_handler(struct pt_regs *regs,
52+
unsigned long esr);
53+
4654
#endif /* _ARM_KPROBES_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/include/asm/traps.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@ void arm64_force_sig_fault(int signo, int code, unsigned long far, const char *s
2828
void arm64_force_sig_mceerr(int code, unsigned long far, short lsb, const char *str);
2929
void arm64_force_sig_ptrace_errno_trap(int errno, unsigned long far, const char *str);
3030

31+
int bug_brk_handler(struct pt_regs *regs, unsigned long esr);
32+
int cfi_brk_handler(struct pt_regs *regs, unsigned long esr);
33+
int reserved_fault_brk_handler(struct pt_regs *regs, unsigned long esr);
34+
int kasan_brk_handler(struct pt_regs *regs, unsigned long esr);
35+
int ubsan_brk_handler(struct pt_regs *regs, unsigned long esr);
36+
3137
int early_brk64(unsigned long addr, unsigned long esr, struct pt_regs *regs);
3238

3339
/*

arch/arm64/include/asm/uprobes.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,15 @@ struct arch_uprobe {
3030
bool simulate;
3131
};
3232

33+
int uprobe_brk_handler(struct pt_regs *regs, unsigned long esr);
34+
#ifdef CONFIG_UPROBES
35+
int uprobe_single_step_handler(struct pt_regs *regs, unsigned long esr);
36+
#else
37+
static inline int uprobe_single_step_handler(struct pt_regs *regs,
38+
unsigned long esr)
39+
{
40+
return DBG_HOOK_ERROR;
41+
}
42+
#endif
43+
3344
#endif

0 commit comments

Comments
 (0)