fix: bsd: use proper MSR for AMD in ucode version read fallback

This commit is contained in:
Stéphane Lesimple
2026-04-06 00:38:39 +02:00
parent 96c696e313
commit e2eba83ce8

View File

@@ -130,16 +130,20 @@ parse_cpu_details() {
if [ -z "$cpu_ucode" ] && [ "$g_os" != Linux ]; then if [ -z "$cpu_ucode" ] && [ "$g_os" != Linux ]; then
load_cpuid load_cpuid
if [ -e ${BSD_CPUCTL_DEV_BASE}0 ]; then if [ -e ${BSD_CPUCTL_DEV_BASE}0 ]; then
# init MSR with NULLs if [ "$cpu_vendor" = AuthenticAMD ]; then
cpucontrol -m 0x8b=0 ${BSD_CPUCTL_DEV_BASE}0 # AMD: read MSR_PATCHLEVEL (0xC0010058) directly
# call CPUID cpu_ucode=$(cpucontrol -m 0xC0010058 ${BSD_CPUCTL_DEV_BASE}0 2>/dev/null | awk '{print $3}')
cpucontrol -i 1 ${BSD_CPUCTL_DEV_BASE}0 >/dev/null elif [ "$cpu_vendor" = GenuineIntel ]; then
# read MSR # Intel: write 0 to IA32_BIOS_SIGN_ID, execute CPUID, then read back
cpu_ucode=$(cpucontrol -m 0x8b ${BSD_CPUCTL_DEV_BASE}0 | awk '{print $3}') cpucontrol -m 0x8b=0 ${BSD_CPUCTL_DEV_BASE}0 2>/dev/null
# convert to decimal cpucontrol -i 1 ${BSD_CPUCTL_DEV_BASE}0 >/dev/null 2>&1
cpu_ucode=$((cpu_ucode)) cpu_ucode=$(cpucontrol -m 0x8b ${BSD_CPUCTL_DEV_BASE}0 2>/dev/null | awk '{print $3}')
# convert back to hex fi
cpu_ucode=$(printf "0x%x" "$cpu_ucode") if [ -n "$cpu_ucode" ]; then
# convert to decimal then back to hex
cpu_ucode=$((cpu_ucode))
cpu_ucode=$(printf "0x%x" "$cpu_ucode")
fi
fi fi
fi fi