]> git.ipfire.org Git - thirdparty/linux.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)
committerLen Brown <len.brown@intel.com>
Wed, 18 Mar 2026 03:13:09 +0000 (23:13 -0400)
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>
tools/power/x86/turbostat/turbostat.c

index 14021a6ed717759fb576085e7a749b25aa1b7f99..b985bce69142f67464c0df33e2da9c28629ef842 100644 (file)
@@ -9121,10 +9121,13 @@ void process_cpuid()
        cpuid_has_hv = ecx_flags & (1 << 31);
 
        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;
+               }
        }
 
        /*
@@ -9138,7 +9141,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);