x86/microcode: Sanitize __wait_for_cpus()
authorThomas Gleixner <tglx@linutronix.de>
Mon, 2 Oct 2023 11:59:59 +0000 (13:59 +0200)
committerBorislav Petkov (AMD) <bp@alien8.de>
Tue, 24 Oct 2023 13:05:54 +0000 (15:05 +0200)
commit0772b9aa1a8f7322dce8588c231cff8b57298a53
tree635b14036ad5f1d2d4590d19b083d860cabed888
parent6f059e634dcd0d725854514c94c114bbdd83950d
x86/microcode: Sanitize __wait_for_cpus()

The code is too complicated for no reason:

 - The return value is pointless as this is a strict boolean.

 - It's way simpler to count down from num_online_cpus() and check for
   zero.

  - The timeout argument is pointless as this is always one second.

  - Touching the NMI watchdog every 100ns does not make any sense, neither
    does checking every 100ns. This is really not a hotpath operation.

Preload the atomic counter with the number of online CPUs and simplify the
whole timeout logic. Delay for one microsecond and touch the NMI watchdog
once per millisecond.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Link: https://lore.kernel.org/r/20231002115903.204251527@linutronix.de
arch/x86/kernel/cpu/microcode/core.c