From: Douglas Anderson <dianders@chromium.org>
To: jason.wessel@windriver.com, daniel.thompson@linaro.org,
gregkh@linuxfoundation.org
Cc: hpa@zytor.com, kgdb-bugreport@lists.sourceforge.net,
corbet@lwn.net, frowand.list@gmail.com, tglx@linutronix.de,
jslaby@suse.com, linux-serial@vger.kernel.org, mingo@redhat.com,
will@kernel.org, bjorn.andersson@linaro.org, agross@kernel.org,
bp@alien8.de, catalin.marinas@arm.com,
Douglas Anderson <dianders@chromium.org>,
Alexios Zavras <alexios.zavras@intel.com>,
Allison Randal <allison@lohutok.net>,
Dave Martin <Dave.Martin@arm.com>,
Enrico Weigelt <info@metux.net>,
"Eric W. Biederman" <ebiederm@xmission.com>,
James Morse <james.morse@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Masami Hiramatsu <mhiramat@kernel.org>,
jinho lim <jordan.lim@samsung.com>,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: [PATCH 3/7] arm64: Add call_break_hook() to early_brk64() for early kgdb
Date: Fri, 10 Apr 2020 15:17:22 -0700 [thread overview]
Message-ID: <20200410151632.3.I22067ad43e77ddfd4b64c2d49030628480f9e8d9@changeid> (raw)
In-Reply-To: <20200410221726.36442-1-dianders@chromium.org>
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(-)
diff --git a/arch/arm64/include/asm/debug-monitors.h b/arch/arm64/include/asm/debug-monitors.h
index 7619f473155f..2d82a0314d29 100644
--- a/arch/arm64/include/asm/debug-monitors.h
+++ b/arch/arm64/include/asm/debug-monitors.h
@@ -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 {
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/kgdb.c b/arch/arm64/kernel/kgdb.c
index 43119922341f..96a47af870bc 100644
--- a/arch/arm64/kernel/kgdb.c
+++ b/arch/arm64/kernel/kgdb.c
@@ -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
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;
+
return bug_handler(regs, esr) != DBG_HOOK_HANDLED;
}
--
2.26.0.110.g2183baf09c-goog
next prev parent reply other threads:[~2020-04-10 22:18 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-10 22:17 [PATCH 0/7] kgdb: Support late serial drivers; enable early debug w/ boot consoles Douglas Anderson
2020-04-10 22:17 ` [PATCH 1/7] kgdboc: Use a platform device to handle tty drivers showing up late Douglas Anderson
2020-04-10 22:17 ` [PATCH 2/7] kgdb: Delay "kgdbwait" to dbg_late_init() by default Douglas Anderson
2020-04-10 22:17 ` Douglas Anderson [this message]
2020-04-10 22:17 ` [PATCH 4/7] kgdboc: Add earlycon_kgdboc to support early kgdb using boot consoles Douglas Anderson
2020-04-10 23:56 ` kbuild test robot
2020-04-13 21:59 ` Doug Anderson
2020-04-11 1:44 ` kbuild test robot
2020-04-10 22:17 ` [PATCH 5/7] Documentation: kgdboc: Document new earlycon_kgdboc parameter Douglas Anderson
2020-04-10 22:17 ` [PATCH 6/7] serial: qcom_geni_serial: Support earlycon_kgdboc Douglas Anderson
2020-04-10 22:17 ` [PATCH 7/7] serial: 8250_early: " Douglas Anderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200410151632.3.I22067ad43e77ddfd4b64c2d49030628480f9e8d9@changeid \
--to=dianders@chromium.org \
--cc=Dave.Martin@arm.com \
--cc=agross@kernel.org \
--cc=alexios.zavras@intel.com \
--cc=allison@lohutok.net \
--cc=bjorn.andersson@linaro.org \
--cc=bp@alien8.de \
--cc=catalin.marinas@arm.com \
--cc=corbet@lwn.net \
--cc=daniel.thompson@linaro.org \
--cc=ebiederm@xmission.com \
--cc=frowand.list@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=hpa@zytor.com \
--cc=info@metux.net \
--cc=james.morse@arm.com \
--cc=jason.wessel@windriver.com \
--cc=jordan.lim@samsung.com \
--cc=jslaby@suse.com \
--cc=kgdb-bugreport@lists.sourceforge.net \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).