Skip to content

Commit a9531a5

Browse files
committed
add infrastructure for x86 CPU microcode updates
This change adds the infrastructure to enable early application of CPU microcodes for the generic-x86_64 platform once the BR2_PACKAGE_INTEL_MICROCODE or BR2_PACKAGE_LINUX_FIRMWARE_AMD_UCODE options are enabled. Once enabled a kconfig fragment will be generated which will then dynamically add CONFIG_EXTRA_FIRMWARE option to the kernel config for embedding all microcode files accordingly. This should help to get CPU microcode fixes in place once HAos is directly installed on a x86-64 system using the generic-x86_64 platform images.
1 parent 92cb987 commit a9531a5

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

buildroot-external/configs/generic_x86_64_defconfig

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ BR2_PACKAGE_LINUX_FIRMWARE_BNX2X=y
102102
BR2_PACKAGE_LINUX_FIRMWARE_RTL_815X=y
103103
BR2_PACKAGE_LINUX_FIRMWARE_RTL_8169=y
104104
BR2_PACKAGE_LINUX_FIRMWARE_USB_SERIAL_TI=y
105+
BR2_PACKAGE_LINUX_FIRMWARE_AMD_UCODE=y
106+
BR2_PACKAGE_INTEL_MICROCODE=y
105107
BR2_PACKAGE_DBUS_BROKER=y
106108
BR2_PACKAGE_GPTFDISK=y
107109
BR2_PACKAGE_GPTFDISK_SGDISK=y

buildroot-external/external.mk

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,26 @@ linux-check-dotconfig: linux-check-configuration-done
1010
--src-kconfig $(LINUX_SRCDIR)Kconfig \
1111
--actual-config $(LINUX_SRCDIR).config \
1212
$(shell echo $(BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE) $(BR2_LINUX_KERNEL_CONFIG_FRAGMENT_FILES))
13+
14+
# if cpu microcode is required we embed it into the kernel build
15+
ifeq ($(or $(BR2_PACKAGE_INTEL_MICROCODE),$(BR2_PACKAGE_LINUX_FIRMWARE_AMD_UCODE)),y)
16+
17+
UCODE_FRAG := $(BINARIES_DIR)/linux-ucode.fragment
18+
19+
# Hook: Generate fragment before kernel configuration
20+
define GEN_UCODE_FRAGMENT
21+
@echo ">> Generating $(UCODE_FRAG)"
22+
@mkdir -p $(BINARIES_DIR)
23+
@{ \
24+
echo 'CONFIG_EXTRA_FIRMWARE_DIR="$(BINARIES_DIR)"'; \
25+
printf 'CONFIG_EXTRA_FIRMWARE="'; \
26+
( cd $(BINARIES_DIR) 2>/dev/null && \
27+
find intel-ucode amd-ucode -type f \! -name "*README*" \! -name "*.asc" -printf '%p ' 2>/dev/null || true ); \
28+
echo '"'; \
29+
} > $(UCODE_FRAG)
30+
endef
31+
32+
LINUX_PRE_PATCH_HOOKS += GEN_UCODE_FRAGMENT
33+
LINUX_KCONFIG_FRAGMENT_FILES += $(UCODE_FRAG)
34+
35+
endif

buildroot-external/scripts/rootfs-layer.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ function fix_rootfs() {
3939
find "${TARGET_DIR}/share/locale" -name "grub.mo" -delete
4040
find "${TARGET_DIR}/share/locale" -type d -empty -delete
4141
fi
42+
43+
# Remove unnecessary microcodes in /lib/firmware
44+
rm -rf "${TARGET_DIR}/lib/firmware/intel-ucode"
45+
rm -rf "${TARGET_DIR}/lib/firmware/amd-ucode"
4246
}
4347

4448

0 commit comments

Comments
 (0)