arm64: entry: move bad_mode() to entry-common.c
authorMark Rutland <mark.rutland@arm.com>
Mon, 7 Jun 2021 09:46:15 +0000 (10:46 +0100)
committerWill Deacon <will@kernel.org>
Mon, 7 Jun 2021 10:35:55 +0000 (11:35 +0100)
In subsequent patches we'll rework the way bad_mode() is called by
exception entry code. In preparation for this, let's move bad_mode()
itself into entry-common.c.

Let's also mark it as noinstr (e.g. to prevent it being kprobed), and
let's also make the `handler` array a local variable, as this is only
use by bad_mode(), and will be removed entirely in a subsequent patch.

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
Acked-by: Marc Zyngier <maz@kernel.org>
Reviewed-by: Joey Gouly <joey.gouly@arm.com>
Cc: James Morse <james.morse@arm.com>
Cc: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20210607094624.34689-12-mark.rutland@arm.com
Signed-off-by: Will Deacon <will@kernel.org>
arch/arm64/kernel/entry-common.c
arch/arm64/kernel/traps.c

index ae1b6d7c00e1b0403a79c88f61ce3d78afc7c2b9..74d09fd3dafafbcc1886969946d9d7dc1ef04058 100644 (file)
@@ -22,6 +22,7 @@
 #include <asm/processor.h>
 #include <asm/stacktrace.h>
 #include <asm/sysreg.h>
+#include <asm/system_misc.h>
 
 /*
  * This is intended to match the logic in irqentry_enter(), handling the kernel
@@ -156,6 +157,32 @@ static void do_interrupt_handler(struct pt_regs *regs,
 extern void (*handle_arch_irq)(struct pt_regs *);
 extern void (*handle_arch_fiq)(struct pt_regs *);
 
+/*
+ * bad_mode handles the impossible case in the exception vector. This is always
+ * fatal.
+ */
+asmlinkage void noinstr bad_mode(struct pt_regs *regs, int reason, unsigned int esr)
+{
+       const char *handler[] = {
+               "Synchronous Abort",
+               "IRQ",
+               "FIQ",
+               "Error"
+       };
+
+       arm64_enter_nmi(regs);
+
+       console_verbose();
+
+       pr_crit("Bad mode in %s handler detected on CPU%d, code 0x%08x -- %s\n",
+               handler[reason], smp_processor_id(), esr,
+               esr_get_class_string(esr));
+
+       __show_regs(regs);
+       panic("bad mode");
+}
+
+
 #ifdef CONFIG_ARM64_ERRATUM_1463225
 static DEFINE_PER_CPU(int, __in_cortex_a76_erratum_1463225_wa);
 
index 5fd12d19ef4be1ac0d4b915e744fc7592f82833c..7def18ff02e2535497cdaf086c21e896284b5754 100644 (file)
 #include <asm/system_misc.h>
 #include <asm/sysreg.h>
 
-static const char *handler[] = {
-       "Synchronous Abort",
-       "IRQ",
-       "FIQ",
-       "Error"
-};
-
 int show_unhandled_signals = 0;
 
 static void dump_kernel_instr(const char *lvl, struct pt_regs *regs)
@@ -750,24 +743,6 @@ const char *esr_get_class_string(u32 esr)
        return esr_class_str[ESR_ELx_EC(esr)];
 }
 
-/*
- * bad_mode handles the impossible case in the exception vector. This is always
- * fatal.
- */
-asmlinkage void notrace bad_mode(struct pt_regs *regs, int reason, unsigned int esr)
-{
-       arm64_enter_nmi(regs);
-
-       console_verbose();
-
-       pr_crit("Bad mode in %s handler detected on CPU%d, code 0x%08x -- %s\n",
-               handler[reason], smp_processor_id(), esr,
-               esr_get_class_string(esr));
-
-       __show_regs(regs);
-       panic("bad mode");
-}
-
 /*
  * bad_el0_sync handles unexpected, but potentially recoverable synchronous
  * exceptions taken from EL0. Unlike bad_mode, this returns.