Skip to content

Commit a444083

Browse files
spievnievlenb
authored andcommitted
tools/power/turbostat: Fix microcode patch level output for AMD/Hygon
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: 3e40484 ("tools/power turbostat: Add --no-msr option") Signed-off-by: Serhii Pievniev <spevnev16@gmail.com> Signed-off-by: Len Brown <len.brown@intel.com>
1 parent 99b38fa commit a444083

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

tools/power/x86/turbostat/turbostat.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9121,10 +9121,13 @@ void process_cpuid()
91219121
cpuid_has_hv = ecx_flags & (1 << 31);
91229122

91239123
if (!no_msr) {
9124-
if (get_msr(sched_getcpu(), MSR_IA32_UCODE_REV, &ucode_patch))
9124+
if (get_msr(sched_getcpu(), MSR_IA32_UCODE_REV, &ucode_patch)) {
91259125
warnx("get_msr(UCODE)");
9126-
else
9126+
} else {
91279127
ucode_patch_valid = true;
9128+
if (!authentic_amd && !hygon_genuine)
9129+
ucode_patch >>= 32;
9130+
}
91289131
}
91299132

91309133
/*
@@ -9138,7 +9141,7 @@ void process_cpuid()
91389141
if (!quiet) {
91399142
fprintf(outf, "CPUID(1): family:model:stepping 0x%x:%x:%x (%d:%d:%d)", family, model, stepping, family, model, stepping);
91409143
if (ucode_patch_valid)
9141-
fprintf(outf, " microcode 0x%x", (unsigned int)((ucode_patch >> 32) & 0xFFFFFFFF));
9144+
fprintf(outf, " microcode 0x%x", (unsigned int)ucode_patch);
91429145
fputc('\n', outf);
91439146

91449147
fprintf(outf, "CPUID(0x80000000): max_extended_levels: 0x%x\n", max_extended_level);

0 commit comments

Comments
 (0)