• Douglas Anderson's avatar
    arm64: Call debug_traps_init() from trap_init() to help early kgdb · b322c65f
    Douglas Anderson authored
    A new kgdb feature will soon land (kgdb_earlycon) that lets us run
    kgdb much earlier.  In order for everything to work properly it's
    important that the break hook is setup by the time we process
    "kgdbwait".
    
    Right now the break hook is setup in debug_traps_init() and that's
    called from arch_initcall().  That's a bit too late since
    kgdb_earlycon really needs things to be setup by the time the system
    calls dbg_late_init().
    
    We could fix this by adding call_break_hook() into early_brk64() and
    that works fine.  However, it's a little ugly.  Instead, let's just
    add a call to debug_traps_init() straight from trap_init().  There's
    already a documented dependency between trap_init() and
    debug_traps_init() and this makes the dependency more obvious rather
    than just relying on a comment.
    
    NOTE: this solution isn't early enough to let us select the
    "ARCH_HAS_EARLY_DEBUG" KConfig option that is introduced by the
    kgdb_earlycon patch series.  That would only be set if we could do
    breakpoints when early params are parsed.  This patch only enables
    "late early" breakpoints, AKA breakpoints when dbg_late_init() is
    called.  It's expected that this should be fine for most people.
    
    It should also be noted that if you crash you can still end up in kgdb
    earlier than debug_traps_init().  Since you don't need breakpoints to
    debug a crash that's fine.
    Suggested-by: default avatarWill Deacon <will@kernel.org>
    Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
    Acked-by: default avatarWill Deacon <will@kernel.org>
    Cc: Catalin Marinas <catalin.marinas@arm.com>
    Cc: Will Deacon <will@kernel.org>
    Link: https://lore.kernel.org/r/20200513160501.1.I0b5edf030cc6ebef6ab4829f8867cdaea42485d8@changeidSigned-off-by: default avatarWill Deacon <will@kernel.org>
    b322c65f
traps.c 25.9 KB