[Bug 262933] cpucontrol: incorrect detection of Intel CPU revision - wrong microcode file selected

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 30 Mar 2022 09:19:37 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=262933

            Bug ID: 262933
           Summary: cpucontrol: incorrect detection of Intel CPU revision
                    - wrong microcode file selected
           Product: Base System
           Version: 13.0-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Many People
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: moon300web@gmx.net

This report is likely related to:
Bug 192487 - cpucontrol uses unsafe procedure to detect current microcode
version, which status' was set to Closed - fixed.
(Note that I took over the "Severity/Hardware/OS" entries from that bug.)

I'm updating my laptop's microcode as follows
pkg install devcpu-data-intel
vi /etc/loader.conf
  cpu_microcode_load="YES"
  cpu_microcode_name="/boot/firmware/06-8e-0c"
(06-8e-0c downloaded from
https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files/tree/main/intel-ucode)

This seems to work:
dmesg | grep -C 4 microcode
    VT-x: PAT,HLT,MTF,PAUSE,EPT,UG,VPID
    TSC: P-state invariant, performance statistics
  real memory  = 8589934592 (8192 MB)
  avail memory = 7844245504 (7480 MB)
  CPU microcode: updated from 0xea to 0xec    <---- System runs BIOS version
1.75, version 0xea, which is updated
  Event timer "LAPIC" quality 600
  ACPI APIC Table: <LENOVO TP-N2I  >
  FreeBSD/SMP: Multiprocessor System Detected: 8 CPUs
  FreeBSD/SMP: 1 package(s) x 4 core(s) x 2 hardware threads

cpupdate -i 
  Found CPU(s) from Intel
  Core 0 to 7: CPUID: 806ec  Fam 06  Mod 8e  Step 0c  Flag 80 uCode 000000ec

If cpucontrol is run manually it seems to try and load an incorrect microcode
file:
cpucontrol -vv -u /dev/cpuctl0 
  cpucontrol: found cpu type 0 family 0x6 model 0xe stepping 0xc.
  ..
  /usr/local/share/cpucontrol/06-86-05.01: updating cpu /dev/cpuctl0 from rev
0xec to rev 0xb00000f... failed.  <---- incorrect file!
  cpucontrol: ioctl(): File exists
  ..
  cpucontrol: skipping /usr/local/share/cpucontrol/06-8e-0c.94 of rev 0xea: up
to date
  ..
  cpucontrol: skipping /usr/local/share/cpucontrol/06-8e-0c of rev 0xec: up to
date

There still seems to be something wrong in the detection of Intel CPU revision
on FreeBSD 13.0. Unclear why 06-86-05.01 would qualify as a valid update for
this CPU revision (06-8e-0c)

Running:
FreeBSD 13.0-RELEASE-p10
on Lenovo T590
kernel: CPU: Intel(R) Core(TM) i5-8365U CPU @ 1.60GHz (1896.11-MHz K8-class
CPU)
kernel:   Origin="GenuineIntel"  Id=0x806ec  Family=0x6  Model=0x8e 
Stepping=12

-- 
You are receiving this mail because:
You are the assignee for the bug.