lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Mon, 9 Jan 2023 08:59:42 -0800
From:   "Paul E. McKenney" <paulmck@...nel.org>
To:     Peter Zijlstra <peterz@...radead.org>
Cc:     linux-kernel@...r.kernel.org, kernel-team@...a.com,
        Thomas Gleixner <tglx@...utronix.de>,
        Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
        Dave Hansen <dave.hansen@...ux.intel.com>,
        "H. Peter Anvin" <hpa@...or.com>, x86@...nel.org
Subject: Re: [PATCH x86/nmi 1/2] x86/nmi: Accumulate NMI-progress evidence in
 exc_nmi()

On Mon, Jan 09, 2023 at 05:19:59PM +0100, Peter Zijlstra wrote:
> On Wed, Jan 04, 2023 at 05:15:36PM -0800, Paul E. McKenney wrote:
> 
> > diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
> > index cec0bfa3bc04f..4f1651dc65b3a 100644
> > --- a/arch/x86/kernel/nmi.c
> > +++ b/arch/x86/kernel/nmi.c
> > @@ -69,6 +69,15 @@ struct nmi_stats {
> >  	unsigned int unknown;
> >  	unsigned int external;
> >  	unsigned int swallow;
> > +	unsigned long recv_jiffies;
> > +	unsigned long idt_seq;
> > +	unsigned long idt_nmi_seq;
> > +	unsigned long idt_ignored;
> > +	atomic_long_t idt_calls;
> > +	unsigned long idt_seq_snap;
> > +	unsigned long idt_nmi_seq_snap;
> > +	unsigned long idt_ignored_snap;
> > +	long idt_calls_snap;
> >  };
> 
> Urgh, this is more than a whole cacheline of extra data :/ Can't we make
> this #ifdef CONFIG_NMI_CHECK_CPU ?

We can.  However, the new data is at the end of the structure.  Plus doing
that will also require converting the IS_ENABLED() checks to #ifdef or
to lots of tiny functions, neither of which will be at all pretty.

Another approach would be to have a #else that created a union of all
of these fields, thus reducing this unused space so that of a single
unsigned long, while still permitting IS_ENABLED() checks.  Thoughts?

> > @@ -509,8 +526,15 @@ DEFINE_IDTENTRY_RAW(exc_nmi)
> >  
> >  	inc_irq_stat(__nmi_count);
> >  
> > -	if (!ignore_nmis)
> > +	if (IS_ENABLED(CONFIG_NMI_CHECK_CPU) && ignore_nmis) {
> > +		WRITE_ONCE(nsp->idt_ignored, nsp->idt_ignored + 1);
> > +	} else if (!ignore_nmis) {
> > +		WRITE_ONCE(nsp->idt_nmi_seq, nsp->idt_nmi_seq + 1);
> > +		WARN_ON_ONCE(!(nsp->idt_nmi_seq & 0x1));
> >  		default_do_nmi(regs);
> > +		WRITE_ONCE(nsp->idt_nmi_seq, nsp->idt_nmi_seq + 1);
> > +		WARN_ON_ONCE(nsp->idt_nmi_seq & 0x1);
> > +	}
> >  
> >  	irqentry_nmi_exit(regs, irq_state);
> 
> That is not a NO-OP when !CONFIG_NMI_CHECK_CPU :/

Good catch, will fix!

							Thanx, Paul

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ