perf, x86: Stop Intel PT before kdump starts
authorTakao Indoh <[email protected]>
Wed, 4 Nov 2015 05:22:33 +0000 (14:22 +0900)
committerIngo Molnar <[email protected]>
Mon, 23 Nov 2015 08:58:26 +0000 (09:58 +0100)
This patch stops Intel PT logging and saves its registers in memory
before kdump is started. This feature is needed to prevent Intel PT from
overwriting its log buffer after panic, and saved registers are needed to
find the last position where Intel PT wrote data.

After the crash dump is captured by kdump, users can retrieve the log buffer
from the vmcore and use it to investigate bad kernel behavior.

Signed-off-by: Takao Indoh <[email protected]>
Signed-off-by: Peter Zijlstra (Intel) <[email protected]>
Cc: Alexander Shishkin<[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: H.Peter Anvin <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Vince Weaver <[email protected]>
Cc: Vivek Goyal <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
arch/x86/kernel/crash.c

index 2c1910f6717ed5278fc6d85d25c92360664feb68..58f34319b29ab64aee4bd21e6ff30367d478c262 100644 (file)
@@ -35,6 +35,7 @@
 #include <asm/cpu.h>
 #include <asm/reboot.h>
 #include <asm/virtext.h>
+#include <asm/intel_pt.h>
 
 /* Alignment required for elf header segment */
 #define ELF_CORE_HEADER_ALIGN   4096
@@ -125,6 +126,11 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
        cpu_emergency_vmxoff();
        cpu_emergency_svm_disable();
 
+       /*
+        * Disable Intel PT to stop its logging
+        */
+       cpu_emergency_stop_pt();
+
        disable_local_APIC();
 }
 
@@ -169,6 +175,11 @@ void native_machine_crash_shutdown(struct pt_regs *regs)
        cpu_emergency_vmxoff();
        cpu_emergency_svm_disable();
 
+       /*
+        * Disable Intel PT to stop its logging
+        */
+       cpu_emergency_stop_pt();
+
 #ifdef CONFIG_X86_IO_APIC
        /* Prevent crash_kexec() from deadlocking on ioapic_lock. */
        ioapic_zap_locks();