]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
tools/power/turbostat: Fix microcode patch level output for AMD/Hygon
authorSerhii Pievniev <spevnev16@gmail.com>
Wed, 25 Feb 2026 23:16:03 +0000 (18:16 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Apr 2026 11:30:34 +0000 (13:30 +0200)
[ Upstream commit a444083286434ec1fd127c5da11a3091e6013008 ]

turbostat always used the same logic to read the microcode patch level,
which is correct for Intel but not for AMD/Hygon.
While Intel stores the patch level in the upper 32 bits of MSR, AMD
stores it in the lower 32 bits, which causes turbostat to report the
microcode version as 0x0 on AMD/Hygon.

Fix by shifting right by 32 for non-AMD/Hygon, preserving the existing
behavior for Intel and unknown vendors.

Fixes: 3e4048466c39 ("tools/power turbostat: Add --no-msr option")
Signed-off-by: Serhii Pievniev <spevnev16@gmail.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/power/x86/turbostat/turbostat.c

index 903943d30f7131e15be62893c01d84f03acd4dba..83a90f413f97680905cadb11a72c40acb67cb928 100644 (file)
@@ -8812,10 +8812,13 @@ void process_cpuid()
        edx_flags = edx;
 
        if (!no_msr) {
-               if (get_msr(sched_getcpu(), MSR_IA32_UCODE_REV, &ucode_patch))
+               if (get_msr(sched_getcpu(), MSR_IA32_UCODE_REV, &ucode_patch)) {
                        warnx("get_msr(UCODE)");
-               else
+               } else {
                        ucode_patch_valid = true;
+                       if (!authentic_amd && !hygon_genuine)
+                               ucode_patch >>= 32;
+               }
        }
 
        /*
@@ -8829,7 +8832,7 @@ void process_cpuid()
        if (!quiet) {
                fprintf(outf, "CPUID(1): family:model:stepping 0x%x:%x:%x (%d:%d:%d)", family, model, stepping, family, model, stepping);
                if (ucode_patch_valid)
-                       fprintf(outf, " microcode 0x%x", (unsigned int)((ucode_patch >> 32) & 0xFFFFFFFF));
+                       fprintf(outf, " microcode 0x%x", (unsigned int)ucode_patch);
                fputc('\n', outf);
 
                fprintf(outf, "CPUID(0x80000000): max_extended_levels: 0x%x\n", max_extended_level);