Skip to content

Commit eaff68b

Browse files
Ada Couprie Diazwilldeacon
authored andcommitted
arm64: entry: Add entry and exit functions for debug exceptions
Move the `debug_exception_enter()` and `debug_exception_exit()` functions from mm/fault.c, as they are needed to split the debug exceptions entry paths from the current unified one. Make them externally visible in include/asm/exception.h until the caller in mm/fault.c is cleaned up. Signed-off-by: Ada Couprie Diaz <[email protected]> Tested-by: Luis Claudio R. Goncalves <[email protected]> Reviewed-by: Anshuman Khandual <[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 d4e0b12 commit eaff68b

File tree

3 files changed

+26
-22
lines changed

3 files changed

+26
-22
lines changed

arch/arm64/include/asm/exception.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,8 @@ void do_serror(struct pt_regs *regs, unsigned long esr);
8080
void do_signal(struct pt_regs *regs);
8181

8282
void __noreturn panic_bad_stack(struct pt_regs *regs, unsigned long esr, unsigned long far);
83+
84+
void debug_exception_enter(struct pt_regs *regs);
85+
void debug_exception_exit(struct pt_regs *regs);
86+
8387
#endif /* __ASM_EXCEPTION_H */

arch/arm64/kernel/entry-common.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,28 @@ static __always_inline void fpsimd_syscall_exit(void)
441441
__this_cpu_write(fpsimd_last_state.to_save, FP_STATE_CURRENT);
442442
}
443443

444+
/*
445+
* In debug exception context, we explicitly disable preemption despite
446+
* having interrupts disabled.
447+
* This serves two purposes: it makes it much less likely that we would
448+
* accidentally schedule in exception context and it will force a warning
449+
* if we somehow manage to schedule by accident.
450+
*/
451+
void debug_exception_enter(struct pt_regs *regs)
452+
{
453+
preempt_disable();
454+
455+
/* This code is a bit fragile. Test it. */
456+
RCU_LOCKDEP_WARN(!rcu_is_watching(), "exception_enter didn't work");
457+
}
458+
NOKPROBE_SYMBOL(debug_exception_enter);
459+
460+
void debug_exception_exit(struct pt_regs *regs)
461+
{
462+
preempt_enable_no_resched();
463+
}
464+
NOKPROBE_SYMBOL(debug_exception_exit);
465+
444466
UNHANDLED(el1t, 64, sync)
445467
UNHANDLED(el1t, 64, irq)
446468
UNHANDLED(el1t, 64, fiq)

arch/arm64/mm/fault.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -966,28 +966,6 @@ void __init hook_debug_fault_code(int nr,
966966
debug_fault_info[nr].name = name;
967967
}
968968

969-
/*
970-
* In debug exception context, we explicitly disable preemption despite
971-
* having interrupts disabled.
972-
* This serves two purposes: it makes it much less likely that we would
973-
* accidentally schedule in exception context and it will force a warning
974-
* if we somehow manage to schedule by accident.
975-
*/
976-
static void debug_exception_enter(struct pt_regs *regs)
977-
{
978-
preempt_disable();
979-
980-
/* This code is a bit fragile. Test it. */
981-
RCU_LOCKDEP_WARN(!rcu_is_watching(), "exception_enter didn't work");
982-
}
983-
NOKPROBE_SYMBOL(debug_exception_enter);
984-
985-
static void debug_exception_exit(struct pt_regs *regs)
986-
{
987-
preempt_enable_no_resched();
988-
}
989-
NOKPROBE_SYMBOL(debug_exception_exit);
990-
991969
void do_debug_exception(unsigned long addr_if_watchpoint, unsigned long esr,
992970
struct pt_regs *regs)
993971
{

0 commit comments

Comments
 (0)