How to enable automatic microcode updates

Started by meyergru, September 25, 2023, 12:28:17 PM

Previous topic - Next topic
Quote from: hushcoden on June 04, 2024, 12:15:52 PM
I've just installed that according to the guide, and if I understood correctly, it can be done in three steps:

1. From a shell: echo y | pkg install cpu-microcode

2. Use the web UI to create these two tuneables in /boot/loader.conf:

     cpu_microcode_load="YES"

     cpu_microcode_name="/boot/firmware/intel-ucode.bin"   -> for Intel CPUs

     or

     cpu_microcode_name="/boot/firmware/amd-ucode.bin"   -> for AMD CPUs

3. Reboot

Is that right?

Tia.
No.

I explained this in detail. You cannot load AMD microcode in the early stage.

Also, you mixed up /etc/rc.loader.conf and /boot/loader.conf, as well as the syntax of what must be in there.

Just follow the instructions.
Intel N100, 4 x I226-V, 16 GByte, 256 GByte NVME, ZTE F6005

1100 down / 800 up, Bufferbloat A+

Wouldn't having this in a plugin improve the security of OPNsense?

I don't like having to venture into the repos of non-hardened BSD to install microcode updates. But, definitely running on bare metal those updates could have security and performance benefits. Is there any means of including this in an official plugin since we do not need this for VMs.

There is no need for the FreeBSD repos as the Package is in OpnSense already.

Other than that, open a feature request on GitHub.
Intel N100, 4 x I226-V, 16 GByte, 256 GByte NVME, ZTE F6005

1100 down / 800 up, Bufferbloat A+

I'm totally new to opnsense and having trouble with step 2.

a)
b)

Which is the right way to do it? I don't understand how to point the values "cpu_microcode_load="YES"" and "cpu_microcode_name="/boot/firmware/intel-ucode.bin"" to "/boot/loader.conf" specifically. Just dont want to mess things up.

I'd appreciate some guidance.

Tunable: cpu_microcode_load
Value: YES
Description: whatever

All without quotes, = signs or similar.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

It looks like in the future AMD variant can also be "early loaded" according to recent cpu-microcode message on OpnSense 24.7_9:

Quote1. Early loading.
   This method does not use the RC script included here.
   This is the preferred method, because it ensures that any CPU features
   added or removed by a microcode update are visible to the kernel by
   applying the update before the kernel performs CPU feature detection.

   To enable updates using early loading, add the following lines to
   /boot/loader.conf:

   cpu_microcode_load="YES"

   and the appropriate one of these lines:

   cpu_microcode_name="/boot/firmware/intel-ucode.bin"
   cpu_microcode_name="/boot/firmware/amd-ucode.bin"

   The microcode update will be loaded when the system is rebooted.

   AMD systems running FreeBSD prior to 2024-02-22 snapshot
   34467bd76 only support late loading.

Now I don't know what exact Frisbee version OpnSense currently happens to have, but definitely looks promising overall for the future <3
Deciso DEC750 x2
Deciso DEC2752 x1

Interesting find, but it does not apply to the current OpnSense version yet, since it is based on FreeBSD 14.1, released on 2023-06-04, so it does not include the neccessary changes (unless Franco includes the patches).
Intel N100, 4 x I226-V, 16 GByte, 256 GByte NVME, ZTE F6005

1100 down / 800 up, Bufferbloat A+

I do understand that, hencewhy such future prospecting wording :)
Deciso DEC750 x2
Deciso DEC2752 x1

The issue with https://cgit.freebsd.org/src/commit/?id=34467bd76 as I see it is that there is no intention of bringing it to older FreeBSD releases than what is to be 15.0 some day (no MFC annotation and not on stable/14).

It also doesn't cleanly apply to FreeBSD 14.1 as a single commit. This means there is no exposure on FreeBSD 14 and therefore also no intentional bugfixing if there are problems with it.

So I'm not saying this won't ever be in OPNsense based on FreeBSD 14, but I am saying it's not because we don't want it. ;)


Cheers,
Franco

Translation from franco's text:

This will be natural part of OPNsense when FreeBSD 15 major update hits OPNsense in the future.  8)
Deciso DEC750 x2
Deciso DEC2752 x1

Yes, but also have fun trying it out:

# opnsense-update -zkr 24.7-amd

It's on a separate branch and will stay there for a bit in any case.


Cheers,
Franco

August 06, 2024, 10:48:03 AM #26 Last Edit: August 06, 2024, 11:16:11 AM by olmari
Hmm, what's in there? or is there an place to see? =) I mean I'd love to take na peek before I commit to something, but in general I could ;D

Quote from: franco on August 05, 2024, 08:26:42 PM
Yes, but also have fun trying it out:

# opnsense-update -zkr 24.7-amd

It's on a separate branch and will stay there for a bit in any case.


Cheers,
Franco
Deciso DEC750 x2
Deciso DEC2752 x1

That kernel contains among other improvements the patches to enable early microcode loading for AMD processors. I cannot test it because my boxes all have Intel CPUs.
Intel N100, 4 x I226-V, 16 GByte, 256 GByte NVME, ZTE F6005

1100 down / 800 up, Bufferbloat A+

August 06, 2024, 12:15:28 PM #28 Last Edit: August 06, 2024, 12:35:33 PM by olmari
Quote from: franco on August 05, 2024, 08:26:42 PM
Yes, but also have fun trying it out:

# opnsense-update -zkr 24.7-amd

It's on a separate branch and will stay there for a bit in any case.


Cheers,
Franco

Allright, I am testing this with DEC2752, 24.7_9 as "base",

olmari@router:~ $ uname -a
FreeBSD router.huutoniemi 14.1-RELEASE-p2 FreeBSD 14.1-RELEASE-p2 amd_early-n267771-478b7ed2f02d SMP amd64


I put early loading into tunables, which produced these in /boot/loader.conf:

# dynamically generated tunables settings follow
cpu_microcode_load="YES"
cpu_microcode_name="/boot/firmware/amd-ucode.bin"


/etc/rc.conf.d/cpu_microcode has the

microcode_update_enable="YES"

At least microcode still loads, No idea is it early or late stage =)

root@router:~ # kldload -q cpuctl; x86info -a | fgrep -i microcode
Microcode patch level: 0x810100b
Deciso DEC750 x2
Deciso DEC2752 x1

The branch is https://github.com/opnsense/src/tree/amd_early

Might be worth defanging the late loading code to verify the early load works now...


Cheeers,
Franco