From: Ben Wolsieffer <benwolsieffer@gmail.com>
To: linux-arm-kernel@lists.infradead.org
Cc: Ben Wolsieffer <benwolsieffer@gmail.com>,
Russell King <linux@armlinux.org.uk>,
Ard Biesheuvel <ardb@kernel.org>, Marc Zyngier <maz@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Vladimir Murzin <vladimir.murzin@arm.com>,
"Russell King (Oracle)" <rmk+kernel@armlinux.org.uk>,
Nick Desaulniers <ndesaulniers@google.com>,
"Steven Rostedt (Google)" <rostedt@goodmis.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Nicolas Pitre <nico@fluxnic.net>, Arnd Bergmann <arnd@arndb.de>,
linux-kernel@vger.kernel.org
Subject: [PATCH RESEND 2/2] ARM: v7m: support undefined instruction hooks
Date: Sat, 17 Sep 2022 00:13:52 -0400 [thread overview]
Message-ID: <20220917041403.4191780-3-benwolsieffer@gmail.com> (raw)
In-Reply-To: <20220917041403.4191780-1-benwolsieffer@gmail.com>
Call the common ARM undefined instruction handler, which handles running
hooks to enable ptrace breakpoints and other features.
Signed-off-by: Ben Wolsieffer <benwolsieffer@gmail.com>
---
arch/arm/include/asm/traps.h | 2 ++
arch/arm/kernel/traps-v7m.c | 8 +++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/arch/arm/include/asm/traps.h b/arch/arm/include/asm/traps.h
index 987fefb0a4db..e4253f4a86e1 100644
--- a/arch/arm/include/asm/traps.h
+++ b/arch/arm/include/asm/traps.h
@@ -19,6 +19,8 @@ struct undef_hook {
void register_undef_hook(struct undef_hook *hook);
void unregister_undef_hook(struct undef_hook *hook);
+void do_undefinstr(struct pt_regs *regs);
+
static inline int __in_irqentry_text(unsigned long ptr)
{
extern char __irqentry_text_start[];
diff --git a/arch/arm/kernel/traps-v7m.c b/arch/arm/kernel/traps-v7m.c
index 5fd9943448e9..b324499e1010 100644
--- a/arch/arm/kernel/traps-v7m.c
+++ b/arch/arm/kernel/traps-v7m.c
@@ -20,6 +20,7 @@
#include <asm/linkage.h>
#include <asm/ptrace.h>
#include <asm/system_misc.h>
+#include <asm/traps.h>
#include <asm/v7m.h>
enum fault {
@@ -49,7 +50,6 @@ static const struct exception exceptions[] = {
{"no coprocessor", FAULT_USAGEFAULT, V7M_SCB_CFSR_NOCP, SIGILL, ILL_COPROC, UDBG_UNDEFINED},
{"return to invalid PC", FAULT_USAGEFAULT, V7M_SCB_CFSR_INVPC, SIGSEGV, SEGV_MAPERR, UDBG_SEGV},
{"invalid ISA state", FAULT_USAGEFAULT, V7M_SCB_CFSR_INVSTATE, SIGSEGV, SEGV_MAPERR, UDBG_SEGV},
- {"undefined instruction", FAULT_USAGEFAULT, V7M_SCB_CFSR_UNDEFINSTR, SIGILL, ILL_ILLOPC, UDBG_UNDEFINED},
{"floating point state error", FAULT_BUSFAULT, V7M_SCB_CFSR_LSPERR, SIGBUS, BUS_ADRERR, UDBG_BUS},
{"exception stack push error", FAULT_BUSFAULT, V7M_SCB_CFSR_STKERR, SIGBUS, BUS_ADRERR, UDBG_BUS},
{"exception stack pop error", FAULT_BUSFAULT, V7M_SCB_CFSR_UNSTKERR, SIGBUS, BUS_ADRERR, UDBG_BUS},
@@ -95,6 +95,12 @@ static void traps_v7m_common(struct pt_regs *regs, int fault)
writel(hstatus, BASEADDR_V7M_SCB + V7M_SCB_HFSR);
writel(cstatus, BASEADDR_V7M_SCB + V7M_SCB_CFSR);
+ if (fault == FAULT_USAGEFAULT && cstatus & V7M_SCB_CFSR_UNDEFINSTR) {
+ /* Handle undefined instruction hooks */
+ do_undefinstr(regs);
+ return;
+ }
+
for (i = 0; exceptions[i].name != NULL; ++i) {
if (fault != exceptions[i].fault)
continue;
--
2.37.2
next prev parent reply other threads:[~2022-09-17 4:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-17 4:13 [PATCH RESEND 0/2] ARM: v7m: handle faults and enable debugging Ben Wolsieffer
2022-09-17 4:13 ` [PATCH RESEND 1/2] ARM: v7m: handle faults Ben Wolsieffer
2022-09-17 4:13 ` Ben Wolsieffer [this message]
2022-09-18 14:59 ` [PATCH RESEND 0/2] ARM: v7m: handle faults and enable debugging Linus Walleij
2022-12-09 21:48 Ben Wolsieffer
2022-12-09 21:48 ` [PATCH RESEND 2/2] ARM: v7m: support undefined instruction hooks Ben Wolsieffer
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=20220917041403.4191780-3-benwolsieffer@gmail.com \
--to=benwolsieffer@gmail.com \
--cc=ardb@kernel.org \
--cc=arnd@arndb.de \
--cc=catalin.marinas@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=mark.rutland@arm.com \
--cc=maz@kernel.org \
--cc=ndesaulniers@google.com \
--cc=nico@fluxnic.net \
--cc=rmk+kernel@armlinux.org.uk \
--cc=rostedt@goodmis.org \
--cc=vladimir.murzin@arm.com \
/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
all inboxes | Powered by JetHome®