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]
Message-ID:
 <DS7PR12MB8201D8E3014326007846AC499482A@DS7PR12MB8201.namprd12.prod.outlook.com>
Date: Fri, 9 Jan 2026 22:19:19 +0000
From: "Kaplan, David" <David.Kaplan@....com>
To: "Chang S. Bae" <chang.seok.bae@...el.com>, Thomas Gleixner
	<tglx@...utronix.de>, Borislav Petkov <bp@...en8.de>, Peter Zijlstra
	<peterz@...radead.org>, Josh Poimboeuf <jpoimboe@...nel.org>, Pawan Gupta
	<pawan.kumar.gupta@...ux.intel.com>, Ingo Molnar <mingo@...hat.com>, Dave
 Hansen <dave.hansen@...ux.intel.com>, "x86@...nel.org" <x86@...nel.org>, "H .
 Peter Anvin" <hpa@...or.com>
CC: Alexander Graf <graf@...zon.com>, Boris Ostrovsky
	<boris.ostrovsky@...cle.com>, "linux-kernel@...r.kernel.org"
	<linux-kernel@...r.kernel.org>
Subject: RE: [RFC PATCH 28/56] stop_machine: Add stop_machine_nmi()

[AMD Official Use Only - AMD Internal Distribution Only]

> -----Original Message-----
> From: Chang S. Bae <chang.seok.bae@...el.com>
> Sent: Friday, January 9, 2026 4:16 PM
> To: Kaplan, David <David.Kaplan@....com>; Thomas Gleixner
> <tglx@...utronix.de>; Borislav Petkov <bp@...en8.de>; Peter Zijlstra
> <peterz@...radead.org>; Josh Poimboeuf <jpoimboe@...nel.org>; Pawan
> Gupta <pawan.kumar.gupta@...ux.intel.com>; Ingo Molnar
> <mingo@...hat.com>; Dave Hansen <dave.hansen@...ux.intel.com>;
> x86@...nel.org; H . Peter Anvin <hpa@...or.com>
> Cc: Alexander Graf <graf@...zon.com>; Boris Ostrovsky
> <boris.ostrovsky@...cle.com>; linux-kernel@...r.kernel.org
> Subject: Re: [RFC PATCH 28/56] stop_machine: Add stop_machine_nmi()
>
> Caution: This message originated from an External Source. Use proper
> caution when opening attachments, clicking links, or responding.
>
>
> On 10/13/2025 7:34 AM, David Kaplan wrote:
> >
> > +/**
> > + * stop_machine_nmi: freeze the machine and run this function in NMI
> context
> > + * @fn: the function to run
> > + * @data: the data ptr for the @fn()
> > + * @cpus: the cpus to run the @fn() on (NULL = any online cpu)
> > + *
> > + * Like stop_machine() but runs the function in NMI context to avoid any
> risk of
> > + * interruption due to NMIs.
> > + *
> > + * Protects against CPU hotplug.
> > + */
> > +int stop_machine_nmi(cpu_stop_fn_t fn, void *data, const struct cpumask
> *cpus);
> > +
> > +/**
> > + * stop_machine_cpuslocked_nmi: freeze and run this function in NMI
> context
> > + * @fn: the function to run
> > + * @data: the data ptr for the @fn()
> > + * @cpus: the cpus to run the @fn() on (NULL = any online cpu)
> > + *
> > + * Same as above. Must be called from within a cpus_read_lock()
> protected
> > + * region. Avoids nested calls to cpus_read_lock().
> > + */
> > +int stop_machine_cpuslocked_nmi(cpu_stop_fn_t fn, void *data, const
> struct cpumask *cpus);
>
> <snip>
>
> > +int stop_machine_cpuslocked_nmi(cpu_stop_fn_t fn, void *data,
> > +                             const struct cpumask *cpus)
> > +{
> > +     return __stop_machine_cpuslocked(fn, data, cpus, true);
> > +}
> > +
>
> It looks like this is readily missing the static key switching which is
> handled below. I think the body could be something like:
>    ...
>    static_branch_enable_cpuslocked(&stop_machine_nmi_handler_enable);
>    ret = __stop_machine_cpuslocked(fn, data, cpus, true);
>    static_branch_disable_cpuslocked(&stop_machine_nmi_handler_enable);
>    ...
>
> > +int stop_machine_nmi(cpu_stop_fn_t fn, void *data, const struct cpumask
> *cpus)
> > +{
> > +     int ret;
> > +
> > +     cpus_read_lock();
> > +
> static_branch_enable_cpuslocked(&stop_machine_nmi_handler_enable);
> > +     ret = stop_machine_cpuslocked_nmi(fn, data, cpus);
> > +
> static_branch_disable_cpuslocked(&stop_machine_nmi_handler_enable);
> > +     cpus_read_unlock();
> > +     return ret;
> > +}
>
> With that, here __stop_machine_cpuslocked() can be invoked instead.
>

Ah, yeah I agree that doing the static key switching is better done in stop_machine_cpuslocked_nmi instead.  That's a good point.

Thanks --David Kaplan

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ