[PATCH 2/2] x86/panic: Use safe_halt() for CPU halt after panic

carlos.bilbao@kernel.org posted 2 patches 8 months, 3 weeks ago
[PATCH 2/2] x86/panic: Use safe_halt() for CPU halt after panic
Posted by carlos.bilbao@kernel.org 8 months, 3 weeks ago
From: Carlos Bilbao <carlos.bilbao@kernel.org>

Include an arch/x86-specific function to halt CPU once the kernel has
finished handling a panic, by defining the weak function
cpu_halt_after_panic().

Signed-off-by: Carlos Bilbao (DigitalOcean) <carlos.bilbao@kernel.org>
Reviewed-by: Jan Glauber (DigitalOcean) <jan.glauber@gmail.com>
---
 arch/x86/kernel/Makefile | 1 +
 arch/x86/kernel/panic.c  | 9 +++++++++
 2 files changed, 10 insertions(+)
 create mode 100644 arch/x86/kernel/panic.c

diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index f7918980667a..0e4d87596f5d 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -85,6 +85,7 @@ obj-y				+= stacktrace.o
 obj-y				+= cpu/
 obj-y				+= acpi/
 obj-y				+= reboot.o
+obj-y				+= panic.o
 obj-$(CONFIG_X86_MSR)		+= msr.o
 obj-$(CONFIG_X86_CPUID)		+= cpuid.o
 obj-$(CONFIG_PCI)		+= early-quirks.o
diff --git a/arch/x86/kernel/panic.c b/arch/x86/kernel/panic.c
new file mode 100644
index 000000000000..0838bb7cf9a9
--- /dev/null
+++ b/arch/x86/kernel/panic.c
@@ -0,0 +1,9 @@
+// SPDX-License-Identifier: GPL-2.0
+// Author Carlos Bilbao <carlos.bilbao@kernel.org>
+#include <linux/kernel.h>
+#include <asm/processor.h>
+
+void cpu_halt_after_panic(void)
+{
+	safe_halt();
+}
-- 
2.47.1