All of lore.kernel.org
 help / color / mirror / Atom feed
From: Breno Leitao <leitao@debian.org>
To: Xin Li <xin@zytor.com>
Cc: paulmck@kernel.org, Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	leit@meta.com, Mark Rutland <mark.rutland@arm.com>,
	Ingo Molnar <mingo@kernel.org>,
	"open list:X86 ARCHITECTURE (32-BIT AND 64-BIT)"
	<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] x86/nmi: Fix "in NMI handler" check
Date: Thu, 8 Feb 2024 06:59:25 -0800	[thread overview]
Message-ID: <ZcTqXjztgECvJSlW@gmail.com> (raw)
In-Reply-To: <0fabf792-3a9e-48c9-9f83-286905b5b2d3@zytor.com>

On Wed, Feb 07, 2024 at 10:44:57AM -0800, Xin Li wrote:
> On 2/7/2024 10:30 AM, Paul E. McKenney wrote:
> > On Wed, Feb 07, 2024 at 08:52:35AM -0800, Breno Leitao wrote:
> > > Commit 344da544f177 ("x86/nmi: Print reasons why backtrace NMIs are
> > > ignored") creates a super nice framework to diagnose NMIs.
> > > 
> > > Every time nmi_exc() is called, it increments a per_cpu counter
> > > (nsp->idt_nmi_seq). At its exit, it also increments the same counter.
> > > Looking at this counter, you can see how many times that function was
> > > called (dividing by 2), and, if the function is still being executed, by
> > > checking the idt_nmi_seq's last bit.
> > > 
> > > On the check side (nmi_backtrace_stall_check()), that variable is
> > > queried to check if the NMI is still being executed, but, there is a
> > > mistake in the bitwise operation. That code wants to check if the last
> > > bit of the idt_nmi_seq is set or not, but, does the opposite, and check
> > > for all the other bits, which will always be true after the first
> > > exc_nmi() executed successfully.
> > > 
> > > This appends the misleading string to the dump "(CPU currently in NMI
> > > handler function)"
> > > 
> > > Fix it by checking the last bit, and if it is set, append the string.
> > > 
> > > Fixes: 344da544f177 ("x86/nmi: Print reasons why backtrace NMIs are ignored")
> > > Signed-off-by: Breno Leitao <leitao@debian.org>
> > 
> > If someone else is taking this:
> > 
> > Reviewed-by: Paul E. McKenney <paulmck@kernel.org>
> > 
> > (I am queueing it for testing in any case.)
> 
> Does this fix need to be backported?
> 
> Commit 344da544f177 has a date on Dec 16 2022.

I would say so, if users are using this detection mechanism and want to
trust the messages being displayed by the kernel.

  reply	other threads:[~2024-02-08 14:59 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-07 16:52 [PATCH] x86/nmi: Fix "in NMI handler" check Breno Leitao
2024-02-07 18:30 ` Paul E. McKenney
2024-02-07 18:44   ` Xin Li
2024-02-08 14:59     ` Breno Leitao [this message]
2024-02-26 22:50 ` [tip: x86/misc] x86/nmi: Fix the inverse " tip-bot2 for Breno Leitao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZcTqXjztgECvJSlW@gmail.com \
    --to=leitao@debian.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=leit@meta.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=mingo@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    --cc=xin@zytor.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.