[RFC PATCH 3/3] x86/microcode: Taint and warn on late loading

From: Borislav Petkov
Date: Tue May 24 2022 - 14:53:59 EST


From: Borislav Petkov <bp@xxxxxxx>

Warn when done and taint the kernel.

Signed-off-by: Borislav Petkov <bp@xxxxxxx>
---
arch/x86/kernel/cpu/microcode/core.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c
index c717db6b6856..f7ded2facaa0 100644
--- a/arch/x86/kernel/cpu/microcode/core.c
+++ b/arch/x86/kernel/cpu/microcode/core.c
@@ -501,6 +501,8 @@ static int microcode_reload_late(void)
microcode_check();

pr_info("Reload completed, microcode revision: 0x%x\n", boot_cpu_data.microcode);
+ pr_err("However, late loading is dangerous and it taints the kernel.\n"
+ "You should switch to early loading, if possible.\n");

return ret;
}
@@ -541,6 +543,8 @@ static ssize_t reload_store(struct device *dev,
if (ret == 0)
ret = size;

+ add_taint(TAINT_CPU_OUT_OF_SPEC, LOCKDEP_STILL_OK);
+
return ret;
}

--
2.35.1