[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220917041403.4191780-3-benwolsieffer@gmail.com>
Date: Sat, 17 Sep 2022 00:13:52 -0400
From: Ben Wolsieffer <benwolsieffer@...il.com>
To: linux-arm-kernel@...ts.infradead.org
Cc: Ben Wolsieffer <benwolsieffer@...il.com>,
Russell King <linux@...linux.org.uk>,
Ard Biesheuvel <ardb@...nel.org>,
Marc Zyngier <maz@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Vladimir Murzin <vladimir.murzin@....com>,
"Russell King (Oracle)" <rmk+kernel@...linux.org.uk>,
Nick Desaulniers <ndesaulniers@...gle.com>,
"Steven Rostedt (Google)" <rostedt@...dmis.org>,
Catalin Marinas <catalin.marinas@....com>,
Nicolas Pitre <nico@...xnic.net>,
Arnd Bergmann <arnd@...db.de>, linux-kernel@...r.kernel.org
Subject: [PATCH RESEND 2/2] ARM: v7m: support undefined instruction hooks
Call the common ARM undefined instruction handler, which handles running
hooks to enable ptrace breakpoints and other features.
Signed-off-by: Ben Wolsieffer <benwolsieffer@...il.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
Powered by blists - more mailing lists