Skip to content

Commit

Permalink
sysutils/cpu-microcode*: support early loading of AMD ucode
Browse files Browse the repository at this point in the history
Install the AMD ucode in /boot/firmware for early loading just like
is done for intel.  Update the instructions for early loading to
reflect that AMD is now supported too.

Sponsored By:	Netflix
Reviewed by:	jrm
Differential Revision:	https://reviews.freebsd.org/D44025
  • Loading branch information
Chuck Silvers authored and Chuck Silvers committed Feb 23, 2024
1 parent 54e4e7d commit 8972ab3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 10 deletions.
11 changes: 10 additions & 1 deletion sysutils/cpu-microcode-amd/Makefile
@@ -1,5 +1,6 @@
PORTNAME= microcode
PORTVERSION= 20231019
PORTREVISION= 1
CATEGORIES= sysutils
MASTER_SITES= https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git/plain/amd-ucode/
PKGNAMEPREFIX= cpu-
Expand All @@ -24,19 +25,27 @@ ONLY_FOR_ARCHS= amd64 i386
RUN_DEPENDS= ${LOCALBASE}/etc/rc.d/microcode_update:sysutils/cpu-microcode-rc

DATADIR= ${PREFIX}/share/cpucontrol
FWDIR= /boot/firmware

EXTRACT_CMD= ${CP}
EXTRACT_BEFORE_ARGS= # empty
EXTRACT_AFTER_ARGS= .
NO_ARCH= yes
NO_BUILD= yes

NO_WRKSUBDIR= yes
PLIST_FILES= ${DISTFILES:S/^/${DATADIR}\//g:C/\?.*//}
PLIST_FILES= ${DISTFILES:S/^/${DATADIR}\//g:C/\?.*//} \
${FWDIR}/amd-ucode.bin

_REV= 06afd7f939c5b245b2af9e0fee13026f2aaf77fa

post-extract:
${CAT} ${WRKSRC}/microcode_amd* > ${WRKSRC}/amd-ucode.bin

do-install:
${MKDIR} ${STAGEDIR}${DATADIR}/
${MKDIR} ${STAGEDIR}${FWDIR}
${INSTALL_DATA} ${WRKSRC}/amd-ucode.bin ${STAGEDIR}${FWDIR}/
.for f in ${DISTFILES}
${INSTALL_DATA} ${WRKSRC}/${f} ${STAGEDIR}${DATADIR}/${f:C/\?.*//}
.endfor
Expand Down
21 changes: 13 additions & 8 deletions sysutils/cpu-microcode-rc/files/pkg-message.in
Expand Up @@ -4,23 +4,28 @@
This port includes an RC script, which is one of two methods to update
the CPU microcode on a FreeBSD system.

1. The first method does not require the RC script included here and is
only supported with Intel processors. It is the preferred method,
because it ensures that any CPU features introduced by a microcode
update are visible to the kernel by applying the update before the
kernel performs CPU feature detection.
1. 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 the first method, add the following lines to
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.


2. The second method, which uses the RC script included here, can be
enabled by adding the following line to /etc/rc.conf:
2. Late loading.
This method, which does use the RC script included here, is enabled by
adding the following line to /etc/rc.conf:

microcode_update_enable="YES"

Expand Down
3 changes: 2 additions & 1 deletion sysutils/cpu-microcode/Makefile
@@ -1,5 +1,6 @@
PORTNAME= microcode
PORTVERSION= 1.0
PORTREVISION= 1
CATEGORIES= sysutils
PKGNAMEPREFIX= cpu-

Expand All @@ -8,7 +9,7 @@ COMMENT= Meta-package for CPU microcode updates

ONLY_FOR_ARCHS= amd64 i386

RUN_DEPENDS= ${LOCALBASE}/share/cpucontrol/microcode_amd.bin:sysutils/cpu-microcode-amd \
RUN_DEPENDS= /boot/firmware/amd-ucode.bin:sysutils/cpu-microcode-amd \
/boot/firmware/intel-ucode.bin:sysutils/cpu-microcode-intel

USES= metaport
Expand Down

0 comments on commit 8972ab3

Please sign in to comment.