Re: [patch V3 25/30] x86/microcode: Rendezvous and load in NMI

From: Borislav Petkov
Date: Wed Sep 27 2023 - 13:17:11 EST


On Tue, Sep 12, 2023 at 09:58:23AM +0200, Thomas Gleixner wrote:
> From: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
>
> stop_machine() does not prevent the spin-waiting sibling from handling an
> NMI, which is obviously violating the whole concept of rendezvous.
>
> Implement a static branch right in the beginning of the NMI handler which
> is NOOPed except when enabled by the late loading mechanism.
>
> The later loader enables the static branch before stop_machine() is

s/later/late/

> invoked. Each CPU has an nmi_enable in its control structure which
> indicates whether the CPU should go into the update routine.
>
> This is required to bridge the gap between enabling the branch and actually
> being at the point where it makes sense.

Huh? "where it makes sense"?

> -static int ucode_load_cpus_stopped(void *unused)
> +static bool microcode_update_handler(void)
> {
> unsigned int cpu = smp_processor_id();
>
> @@ -430,7 +436,29 @@ static int ucode_load_cpus_stopped(void
> else
> ucode_load_secondary(cpu);
>
> - /* No point to wait here. The CPUs will all wait in stop_machine(). */
> + touch_nmi_watchdog();

AFAICT, you're touching the NMI watchdog even in the !use_nmi case.

> + return true;
> +}

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette