mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH tip] x86/microcode/AMD: Read from MSR_AMD64_PATCH_LEVEL to get base_rev if not defined
@ 2025-11-17 19:15 Waiman Long
  2025-11-17 19:37 ` Borislav Petkov
  0 siblings, 1 reply; 5+ messages in thread
From: Waiman Long @ 2025-11-17 19:15 UTC (permalink / raw)
  To: Borislav Petkov, Thomas Gleixner, Ingo Molnar, Dave Hansen,
	H. Peter Anvin
  Cc: x86, linux-kernel, Waiman Long

AMD microcode is being handled inconsistenly depending on whether the
CONFIG_MICROCODE_DBG is on or off. Currently, the MSR_AMD64_PATCH_LEVEL
MSR is being read in get_patch_level() to retrieve microcode revision
when CONFIG_MICROCODE_DBG is off, but cpuid_to_ucode_rev(bsp_cpuid_1_eax)
is used to get the revision with CONFIG_MICROCODE_DBG on if
microcode_rev[cpu] hasn't been defined yet.

On a test Genoa system with a relatively new BIOS/firmware,
get_patch_level() returns 0xa101100 with cpuid_to_ucode_rev(), but
0x0a101158 when reading from MSR_AMD64_PATCH_LEVEL. It does look
like bsp_cpuid_1_eax doesn't contain the right microcode revision
for microcode embedded in the BIOS/firmware. This is problematic as
need_sha_check() may return an incorrect result.

To fix the inconsistency and provide a more correct result, always read
from the MSR in get_patch_level() to get the microcode revision number.

Fixes: 43181a47263d ("x86/microcode: Add microcode loader debugging functionality")
Signed-off-by: Waiman Long <longman@redhat.com>
---
 arch/x86/kernel/cpu/microcode/amd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c
index 3821a985f4ff..561630c017e2 100644
--- a/arch/x86/kernel/cpu/microcode/amd.c
+++ b/arch/x86/kernel/cpu/microcode/amd.c
@@ -327,7 +327,7 @@ static u32 get_patch_level(void)
 
 		if (!microcode_rev[cpu]) {
 			if (!base_rev)
-				base_rev = cpuid_to_ucode_rev(bsp_cpuid_1_eax);
+				native_rdmsr(MSR_AMD64_PATCH_LEVEL, base_rev, dummy);
 
 			microcode_rev[cpu] = base_rev;
 
-- 
2.51.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-11-18  0:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-17 19:15 [PATCH tip] x86/microcode/AMD: Read from MSR_AMD64_PATCH_LEVEL to get base_rev if not defined Waiman Long
2025-11-17 19:37 ` Borislav Petkov
2025-11-17 19:58   ` Waiman Long
2025-11-17 21:11     ` Borislav Petkov
2025-11-18  0:28       ` Waiman Long

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®