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
F103470957: D8384.id21947.diff
Mon, Nov 25, 11:14 AM
Unknown Object (File)
Sat, Nov 9, 4:30 PM
Unknown Object (File)
Oct 25 2024, 7:42 PM
Unknown Object (File)
Oct 16 2024, 2:59 PM
Unknown Object (File)
Oct 10 2024, 2:59 AM
Unknown Object (File)
Oct 7 2024, 12:53 PM
Unknown Object (File)
Oct 6 2024, 4:09 PM
Unknown Object (File)
Oct 1 2024, 8:13 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

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.

428

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

usr.sbin/cpucontrol/amd10h.c
2

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

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
38

sys/ headers should come before the usermode headers.

300

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