Page MenuHomeFreeBSD

Add support for microcode update on newer AMD CPUs (10h+)
ClosedPublic

Authored by avg on Oct 30 2016, 1:41 PM.
Tags
None
Referenced Files
Unknown Object (File)
Thu, Mar 28, 1:56 AM
Unknown Object (File)
Mar 1 2024, 3:35 PM
Unknown Object (File)
Feb 24 2024, 11:45 AM
Unknown Object (File)
Feb 13 2024, 9:56 AM
Unknown Object (File)
Jan 30 2024, 11:59 AM
Unknown Object (File)
Jan 30 2024, 11:59 AM
Unknown Object (File)
Jan 30 2024, 11:59 AM
Unknown Object (File)
Jan 30 2024, 11:54 AM
Subscribers

Details

Summary

This includes new code for parsing microcode files as well as
the kernel-side change to apply the update on all processors
at the same time.

Developed with help from Borislav Petkov, formerly bp@amd64.org.

Test Plan

Tested using Athlon II X2 processor on a system where BIOS does
not have the latest microcode version:
/boot/firmware/microcode_amd.bin: updating cpu /dev/cpuctl0 to revision 0x10000c7... done.

The microcode file is taken from here:
https://web.archive.org/web/20160528230514/http://www.amd64.org/microcode.html
(note that the site seems to be down at the moment)
It can also be found here:
https://git.kernel.org/cgit/linux/kernel/git/firmware/linux-firmware.git/tree/amd-ucode

Diff Detail

Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 5820
Build 6109: arc lint + arc unit

Event Timeline

avg retitled this revision from to Add support for microcode update on newer AMD CPUs (10h+).
avg updated this object.
avg edited the test plan for this revision. (Show Details)
avg added reviewers: kib, stas.
sys/dev/cpuctl/cpuctl.c
60

This is unrelated, commit separately (now ?).

396

Why is this required ? I do not see any harm from allowing the update to run from arbitrary /dev/cpuctlN.

419

Check for ptr != NULL is not needed. Use plain free(9).

usr.sbin/cpucontrol/amd10h.c
2 ↗(On Diff #21806)

Copyright line should be updated.

stas edited edge metadata.

Looks good besides what kib@ already mentioned.

Thanks!

sys/dev/cpuctl/cpuctl.c
396

I agree. Unless there are restrictions on which cores the update can be performed on... But in that case the check will have to be a bit more sophisticated to account for multi-socket configurations.

usr.sbin/cpucontrol/amd10h.c
174 ↗(On Diff #21806)

Double space.

This revision is now accepted and ready to land.Oct 31 2016, 8:07 AM
avg edited edge metadata.

address comments from kib

This revision now requires review to proceed.Oct 31 2016, 10:15 AM
kib edited edge metadata.
kib added inline comments.
usr.sbin/cpucontrol/amd10h.c
37 ↗(On Diff #21828)

sys/ headers should come before the usermode headers.

299 ↗(On Diff #21828)

space after if

This revision is now accepted and ready to land.Oct 31 2016, 12:21 PM
avg edited edge metadata.

really address kib's comment and replace contigfree with free

This revision now requires review to proceed.Nov 2 2016, 3:16 PM
sys/dev/cpuctl/cpuctl.c
396

There is really no restriction. I just wanted to skip unnecessary writes to the update MSR in the default configuration with microcode_cpus="ALL". But that was not needed anyway, because the first invocation of cpucontrol would update all CPUs and subsequent invocations would see that the CPUs have the latest version.

avg edited edge metadata.

address comments from stas

add comments about the AMD update MSR being undocumented

This revision was automatically updated to reflect the committed changes.

Just as a data point:

$ cpucontrol -vvv -d /boot/firmware -u /dev/cpuctl0
cpucontrol: skipping /boot/firmware/.: is a directory
cpucontrol: skipping /boot/firmware/..: is a directory
cpucontrol: found cpu family 0xf model 0x6 stepping 0x2 extfamily 0x1 extmodel 0.
cpucontrol: microcode revision 0x1000098
cpucontrol: equiv_id: 1062
cpucontrol: selecting revision: 10000c7
cpucontrol: selected ucode size is 960
/boot/firmware/microcode_amd.bin: updating cpu /dev/cpuctl0 to revision 0x10000c7... done.
$ cpucontrol -vvv -d /boot/firmware -u /dev/cpuctl1
cpucontrol: skipping /boot/firmware/.: is a directory
cpucontrol: skipping /boot/firmware/..: is a directory
cpucontrol: found cpu family 0xf model 0x6 stepping 0x2 extfamily 0x1 extmodel 0.
cpucontrol: microcode revision 0x10000c7
cpucontrol: equiv_id: 1062