On Mon, May 11, 2020 at 03:45:02PM -0700, Doug Anderson wrote: > On Mon, May 11, 2020 at 7:59 AM Will Deacon <w...@kernel.org> wrote: > > On Tue, Apr 28, 2020 at 02:13:45PM -0700, Douglas Anderson wrote: > > > diff --git a/arch/arm64/kernel/debug-monitors.c > > > b/arch/arm64/kernel/debug-monitors.c > > > index 48222a4760c2..59c353dfc8e9 100644 > > > --- a/arch/arm64/kernel/debug-monitors.c > > > +++ b/arch/arm64/kernel/debug-monitors.c > > > @@ -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; > > > diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c > > > index cf402be5c573..a8173f0c1774 100644 > > > --- a/arch/arm64/kernel/traps.c > > > +++ b/arch/arm64/kernel/traps.c > > > @@ -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; > > > > I think this just means we're not running debug_traps_init() early enough, > > and actually the KASAN early handler is unnecessary too. > > > > If we call debug_traps_init() directly from setup_arch() and drop the > > arch_initcall(), can we then drop early_brk64 entirely? > > It seems to work in my testing. ...but the worry I have is the > comment right before trap_init(). It says: > > /* This registration must happen early, before debug_traps_init(). */
I /think/ the reason for this is because debug_traps_init() replaces the BRK vector, so if that runs before the break hooks have been registered for e.g. BUG() then BUG() won't work during that window. Hmm, so dropping early_brk64 is problematic after all. Damn. Is trap_init() early enough for you? If so, we could call debug_traps_init() from traps_init() after registering the break hooks. Will