During jumping to the new kernel, on the crashed cpu, the memory mapping
switches from an old one to an identity one. It had better disable PMU to
suppress NMI, which can be delivered using the old mapping.
Also on x86_64, idt_invalidate() to clear idt as on 32 bits.
Signed-off-by: Pingfan Liu <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: "H. Peter Anvin" <[email protected]>
Cc: Omar Sandoval <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Mike Rapoport <[email protected]>
To: [email protected]
Cc: [email protected]
---
arch/x86/kernel/machine_kexec_32.c | 1 +
arch/x86/kernel/machine_kexec_64.c | 3 +++
2 files changed, 4 insertions(+)
diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
index 64b00b0..72c6100 100644
--- a/arch/x86/kernel/machine_kexec_32.c
+++ b/arch/x86/kernel/machine_kexec_32.c
@@ -191,6 +191,7 @@ void machine_kexec(struct kimage *image)
/* Interrupts aren't acceptable while we reboot */
local_irq_disable();
hw_breakpoint_disable();
+ perf_pmu_disable_all();
if (image->preserve_context) {
#ifdef CONFIG_X86_IO_APIC
diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
index a29a44a..238893e 100644
--- a/arch/x86/kernel/machine_kexec_64.c
+++ b/arch/x86/kernel/machine_kexec_64.c
@@ -17,6 +17,7 @@
#include <linux/suspend.h>
#include <linux/vmalloc.h>
#include <linux/efi.h>
+#include <linux/perf_event.h>
#include <asm/init.h>
#include <asm/tlbflush.h>
@@ -338,6 +339,8 @@ void machine_kexec(struct kimage *image)
/* Interrupts aren't acceptable while we reboot */
local_irq_disable();
hw_breakpoint_disable();
+ perf_pmu_disable_all();
+ idt_invalidate(phys_to_virt(0));
if (image->preserve_context) {
#ifdef CONFIG_X86_IO_APIC
--
2.7.5
Sorry that I had made a misunderstanding of the code.
Nacked it
On Mon, Nov 23, 2020 at 1:37 PM Pingfan Liu <[email protected]> wrote:
>
> During jumping to the new kernel, on the crashed cpu, the memory mapping
> switches from an old one to an identity one. It had better disable PMU to
> suppress NMI, which can be delivered using the old mapping.
>
> Also on x86_64, idt_invalidate() to clear idt as on 32 bits.
>
> Signed-off-by: Pingfan Liu <[email protected]>
> Cc: Peter Zijlstra <[email protected]>
> Cc: Ingo Molnar <[email protected]>
> Cc: Arnaldo Carvalho de Melo <[email protected]>
> Cc: Mark Rutland <[email protected]>
> Cc: Alexander Shishkin <[email protected]>
> Cc: Jiri Olsa <[email protected]>
> Cc: Namhyung Kim <[email protected]>
> Cc: Thomas Gleixner <[email protected]>
> Cc: Borislav Petkov <[email protected]>
> Cc: "H. Peter Anvin" <[email protected]>
> Cc: Omar Sandoval <[email protected]>
> Cc: Andrew Morton <[email protected]>
> Cc: Mike Rapoport <[email protected]>
> To: [email protected]
> Cc: [email protected]
> ---
> arch/x86/kernel/machine_kexec_32.c | 1 +
> arch/x86/kernel/machine_kexec_64.c | 3 +++
> 2 files changed, 4 insertions(+)
>
> diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
> index 64b00b0..72c6100 100644
> --- a/arch/x86/kernel/machine_kexec_32.c
> +++ b/arch/x86/kernel/machine_kexec_32.c
> @@ -191,6 +191,7 @@ void machine_kexec(struct kimage *image)
> /* Interrupts aren't acceptable while we reboot */
> local_irq_disable();
> hw_breakpoint_disable();
> + perf_pmu_disable_all();
>
> if (image->preserve_context) {
> #ifdef CONFIG_X86_IO_APIC
> diff --git a/arch/x86/kernel/machine_kexec_64.c b/arch/x86/kernel/machine_kexec_64.c
> index a29a44a..238893e 100644
> --- a/arch/x86/kernel/machine_kexec_64.c
> +++ b/arch/x86/kernel/machine_kexec_64.c
> @@ -17,6 +17,7 @@
> #include <linux/suspend.h>
> #include <linux/vmalloc.h>
> #include <linux/efi.h>
> +#include <linux/perf_event.h>
>
> #include <asm/init.h>
> #include <asm/tlbflush.h>
> @@ -338,6 +339,8 @@ void machine_kexec(struct kimage *image)
> /* Interrupts aren't acceptable while we reboot */
> local_irq_disable();
> hw_breakpoint_disable();
> + perf_pmu_disable_all();
> + idt_invalidate(phys_to_virt(0));
>
> if (image->preserve_context) {
> #ifdef CONFIG_X86_IO_APIC
> --
> 2.7.5
>