@@ -97,6 +97,8 @@ void unregister_user_break_hook(struct break_hook *hook);
void register_kernel_break_hook(struct break_hook *hook);
void unregister_kernel_break_hook(struct break_hook *hook);
+int call_break_hook(struct pt_regs *regs, unsigned int esr);
+
u8 debug_monitors_arch(void);
enum dbg_active_el {
@@ -297,7 +297,7 @@ void unregister_kernel_break_hook(struct break_hook *hook)
unregister_debug_hook(&hook->node);
}
-static int call_break_hook(struct pt_regs *regs, unsigned int esr)
+int call_break_hook(struct pt_regs *regs, unsigned int esr)
{
struct break_hook *hook;
struct list_head *list;
@@ -301,6 +301,11 @@ static struct notifier_block kgdb_notifier = {
.priority = -INT_MAX,
};
+extern bool kgdb_arch_can_debug_early(void)
+{
+ return true;
+}
+
/*
* kgdb_arch_init - Perform any architecture specific initialization.
* This function will handle the initialization of any architecture
@@ -1044,6 +1044,9 @@ int __init early_brk64(unsigned long addr, unsigned int esr,
if ((comment & ~KASAN_BRK_MASK) == KASAN_BRK_IMM)
return kasan_handler(regs, esr) != DBG_HOOK_HANDLED;
#endif
+ if (call_break_hook(regs, esr) == DBG_HOOK_HANDLED)
+ return 0;
+
return bug_handler(regs, esr) != DBG_HOOK_HANDLED;
}
In order to make early kgdb work properly we need early_brk64() to be able to call into it. This is as easy as adding a call into call_break_hook() just like we do later in the normal brk_handler(). Once we do this we can let kgdb know that it can break into the debugger a little earlier (specifically when parsing early_param's). NOTE: without this patch it turns out that arm64 can't do breakpoints even at dbg_late_init(), so if we decide something about this patch is wrong we might need to move dbg_late_init() a little later. Signed-off-by: Douglas Anderson <dianders@chromium.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Will Deacon <will@kernel.org> --- arch/arm64/include/asm/debug-monitors.h | 2 ++ arch/arm64/kernel/debug-monitors.c | 2 +- arch/arm64/kernel/kgdb.c | 5 +++++ arch/arm64/kernel/traps.c | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-)