clear-pkgs-linux-iot-lts2018/0689-Debug-Add-register-dum...

69 lines
2.0 KiB
Diff
Raw Permalink Normal View History

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2018-10-30 05:21:52 +08:00
From: "Duan, YayongX" <yayongx.duan@intel.com>
Date: Wed, 27 Dec 2017 12:26:06 +0800
Subject: [PATCH] Debug: Add register dump
2018-10-30 05:21:52 +08:00
Store CPU registers during cpu stop in order to get them with ramdump.
Signed-off-by: Emmanuel Berthier <emmanuel.berthier@intel.com>
Signed-off-by: Duan, YayongX
---
arch/x86/kernel/smp.c | 18 +++++++++++++++++-
1 file changed, 17 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
2020-10-27 02:14:06 +08:00
index b2b87b91f336..5e8ebdfd4456 100644
2018-10-30 05:21:52 +08:00
--- a/arch/x86/kernel/smp.c
+++ b/arch/x86/kernel/smp.c
@@ -117,6 +117,19 @@
static atomic_t stopping_cpu = ATOMIC_INIT(-1);
static bool smp_no_nmi_ipi = false;
+static DEFINE_PER_CPU(struct pt_regs, cpu_regs);
+
+/* Store regs of this CPU for RAM dump decoding help */
+static inline void store_regs(struct pt_regs *regs)
+{
+ struct pt_regs *print_regs;
+ print_regs = &get_cpu_var(cpu_regs);
+ crash_setup_regs(print_regs, regs);
+
+ /* Flush CPU cache */
+ wbinvd();
+}
+
/*
* this function sends a 'reschedule' IPI to another CPU.
* it goes straight through and wastes no time serializing
@@ -163,6 +176,7 @@ static int smp_stop_nmi_callback(unsigned int val, struct pt_regs *regs)
if (raw_smp_processor_id() == atomic_read(&stopping_cpu))
return NMI_HANDLED;
+ store_regs(regs);
cpu_emergency_vmxoff();
stop_this_cpu(NULL);
@@ -173,9 +187,10 @@ static int smp_stop_nmi_callback(unsigned int val, struct pt_regs *regs)
* this function calls the 'stop' function on all other CPUs in the system.
*/
-asmlinkage __visible void smp_reboot_interrupt(void)
+__visible void smp_reboot_interrupt(struct pt_regs *regs)
{
ipi_entering_ack_irq();
+ store_regs(regs);
cpu_emergency_vmxoff();
stop_this_cpu(NULL);
irq_exit();
@@ -255,6 +270,7 @@ static void native_stop_other_cpus(int wait)
udelay(1);
2018-10-30 05:21:52 +08:00
}
+ store_regs(NULL);
local_irq_save(flags);
disable_local_APIC();
mcheck_cpu_clear(this_cpu_ptr(&cpu_info));
--
https://clearlinux.org
2018-10-30 05:21:52 +08:00