x86/microcode: Taint and warn on late loading

Warn before it is attempted and taint the kernel. Late loading microcode
can lead to malfunction of the kernel when the microcode update changes
behaviour. There is no way for the kernel to determine whether its safe or
not.

Signed-off-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20220525161232.14924-4-bp@alien8.de

authored by Borislav Petkov and committed by Thomas Gleixner d23d33ea a77a94f8

+5
+5
arch/x86/kernel/cpu/microcode/core.c
··· 493 { 494 int ret; 495 496 atomic_set(&late_cpus_in, 0); 497 atomic_set(&late_cpus_out, 0); 498 ··· 543 544 if (ret == 0) 545 ret = size; 546 547 return ret; 548 }
··· 493 { 494 int ret; 495 496 + pr_err("Attempting late microcode loading - it is dangerous and taints the kernel.\n"); 497 + pr_err("You should switch to early loading, if possible.\n"); 498 + 499 atomic_set(&late_cpus_in, 0); 500 atomic_set(&late_cpus_out, 0); 501 ··· 540 541 if (ret == 0) 542 ret = size; 543 + 544 + add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK); 545 546 return ret; 547 }