Skip to content

Commit 1641b9b

Browse files
committed
Merge tag 'x86-irq-2023-10-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 irq fix from Ingo Molnar: "Fix out-of-order NMI nesting checks resulting in false positive warnings" * tag 'x86-irq-2023-10-28' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/nmi: Fix out-of-order NMI nesting checks & false positive warning
2 parents ed766c2 + f44075e commit 1641b9b

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

arch/x86/kernel/nmi.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -507,12 +507,13 @@ DEFINE_IDTENTRY_RAW(exc_nmi)
507507
}
508508
this_cpu_write(nmi_state, NMI_EXECUTING);
509509
this_cpu_write(nmi_cr2, read_cr2());
510+
511+
nmi_restart:
510512
if (IS_ENABLED(CONFIG_NMI_CHECK_CPU)) {
511513
WRITE_ONCE(nsp->idt_seq, nsp->idt_seq + 1);
512514
WARN_ON_ONCE(!(nsp->idt_seq & 0x1));
513515
WRITE_ONCE(nsp->recv_jiffies, jiffies);
514516
}
515-
nmi_restart:
516517

517518
/*
518519
* Needs to happen before DR7 is accessed, because the hypervisor can
@@ -548,16 +549,16 @@ DEFINE_IDTENTRY_RAW(exc_nmi)
548549

549550
if (unlikely(this_cpu_read(nmi_cr2) != read_cr2()))
550551
write_cr2(this_cpu_read(nmi_cr2));
551-
if (this_cpu_dec_return(nmi_state))
552-
goto nmi_restart;
553-
554-
if (user_mode(regs))
555-
mds_user_clear_cpu_buffers();
556552
if (IS_ENABLED(CONFIG_NMI_CHECK_CPU)) {
557553
WRITE_ONCE(nsp->idt_seq, nsp->idt_seq + 1);
558554
WARN_ON_ONCE(nsp->idt_seq & 0x1);
559555
WRITE_ONCE(nsp->recv_jiffies, jiffies);
560556
}
557+
if (this_cpu_dec_return(nmi_state))
558+
goto nmi_restart;
559+
560+
if (user_mode(regs))
561+
mds_user_clear_cpu_buffers();
561562
}
562563

563564
#if IS_ENABLED(CONFIG_KVM_INTEL)

0 commit comments

Comments
 (0)