From 04ea4724e2d06498b463c32365306c5f2286affe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Filip=20Lewi=C5=84ski?= Date: Fri, 17 Oct 2025 16:00:46 +0200 Subject: [PATCH] Makefile.mk: separate bootblocks into BOOTBLOCK and TOPSWAP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add Kconfig INTEL_TOP_SWAP_SEPARATE_REGIONS. When enabled, place the regular bootblock in BOOTBLOCK and the Top Swap bootblock in TOPSWAP to simplify A B updates. This lays groundwork for redundancy where one bootblock remains a read only golden copy and the other is replaceable. No swap control logic is added in this change. The option depends on INTEL_ADD_TOP_SWAP_BOOTBLOCK and defaults to n so existing builds are unchanged. A custom .fmd is required with BOOTBLOCK and TOPSWAP added at the end of the image. Background and update flow are described here: Link: https://mail.coreboot.org/archives/list/coreboot@coreboot.org/thread/C6JN2PB7K7D67EG7OIKB6BBERZU5Y V35/ TEST=Build and run Protectli VP6650 (ADL-P), boots successfully with correct microcode Change-Id: I489406dd8d08ad85bb46324d3d009acb49b6c52a Signed-off-by: Filip LewiƄski Reviewed-on: https://review.coreboot.org/c/coreboot/+/89570 Tested-by: build bot (Jenkins) Reviewed-by: Sergii Dmytruk --- Makefile.mk | 29 +++++++++++++++++++++++++++-- src/cpu/intel/fit/Makefile.mk | 16 +++++++++++----- src/soc/intel/common/Kconfig.common | 9 +++++++++ 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/Makefile.mk b/Makefile.mk index 62bce6f91c..93a26d0d95 100644 --- a/Makefile.mk +++ b/Makefile.mk @@ -1261,8 +1261,22 @@ $(obj)/fmap.fmap: $(obj)/fmap.fmd $(FMAPTOOL) $(FMAPTOOL) -h $(obj)/fmap_config.h -R $(obj)/fmap.desc $< $@ ifeq ($(CONFIG_INTEL_ADD_TOP_SWAP_BOOTBLOCK),y) +ifneq ($(CONFIG_INTEL_TOP_SWAP_SEPARATE_REGIONS),y) TS_OPTIONS := -j $(CONFIG_INTEL_TOP_SWAP_BOOTBLOCK_SIZE) endif +endif + +ifneq ($(CONFIG_INTEL_TOP_SWAP_SEPARATE_REGIONS),y) +BB_FIT_REGION = COREBOOT +TS_FIT_REGION = COREBOOT +else +BB_FIT_REGION = BOOTBLOCK +TS_FIT_REGION = TOPSWAP +bootblock_add_params = -f $(objcbfs)/bootblock.bin \ + -n bootblock -t bootblock \ + -b -$(call file-size,$(objcbfs)/bootblock.bin) \ + $(TXTIBB) $(cbfs-autogen-attributes) $(TS_OPTIONS) $(CBFSTOOL_ADD_CMD_OPTIONS) +endif ifneq ($(CONFIG_ARCH_X86),y) add_bootblock = $(CBFSTOOL) $(1) write -u -r BOOTBLOCK -f $(2) @@ -1276,7 +1290,9 @@ ifneq ($(CONFIG_UPDATE_IMAGE),y) $(obj)/coreboot.pre: $$(prebuilt-files) $(CBFSTOOL) $(obj)/fmap.fmap $(obj)/fmap.desc $(objcbfs)/bootblock.bin $(CBFSTOOL) $@.tmp create -M $(obj)/fmap.fmap -r $(shell cat $(obj)/fmap.desc) printf " BOOTBLOCK\n" +ifneq ($(CONFIG_INTEL_TOP_SWAP_SEPARATE_REGIONS),y) $(call add_bootblock,$@.tmp,$(objcbfs)/bootblock.bin) +endif # ifneq ($(CONFIG_INTEL_TOP_SWAP_SEPARATE_REGIONS),y) $(prebuild-files) true mv $@.tmp $@ else # ifneq ($(CONFIG_UPDATE_IMAGE),y) @@ -1306,6 +1322,15 @@ add_intermediate = \ $(1): $(obj)/coreboot.pre $(2) | $(INTERMEDIATE) \ $(eval INTERMEDIATE+=$(1)) $(eval PHONY+=$(1)) +ifeq ($(CONFIG_INTEL_TOP_SWAP_SEPARATE_REGIONS),y) +$(call add_intermediate, prep_bb_regions, $(CBFSTOOL)) + @printf " PREP place bootblocks in BOOTBLOCK and TOPSWAP\n" + @printf " BOOTBLOCK\n" + $(CBFSTOOL) $< add -r $(BB_FIT_REGION) $(bootblock_add_params) + @printf " TOPSWAP\n" + $(CBFSTOOL) $< add -r $(TS_FIT_REGION) $(bootblock_add_params) +endif + $(obj)/coreboot.rom: $(obj)/coreboot.pre $(CBFSTOOL) $(IFITTOOL) $$(INTERMEDIATE) @printf " CBFS $(subst $(obj)/,,$(@))\n" # The full ROM may be larger than the CBFS part, so create an empty @@ -1314,11 +1339,11 @@ $(obj)/coreboot.rom: $(obj)/coreboot.pre $(CBFSTOOL) $(IFITTOOL) $$(INTERMEDIATE dd if=$(obj)/coreboot.pre of=$@.tmp bs=8192 conv=notrunc 2> /dev/null ifeq ($(CONFIG_CPU_INTEL_FIRMWARE_INTERFACE_TABLE),y) # Print final FIT table - $(IFITTOOL) -f $@.tmp -D -r COREBOOT + $(IFITTOOL) -f $@.tmp -D -r $(BB_FIT_REGION) # Print final TS BOOTBLOCK FIT table ifeq ($(CONFIG_INTEL_ADD_TOP_SWAP_BOOTBLOCK),y) @printf " TOP SWAP FIT table\n" - $(IFITTOOL) -f $@.tmp -D $(TS_OPTIONS) -r COREBOOT + $(IFITTOOL) -f $@.tmp -D $(TS_OPTIONS) -r $(TS_FIT_REGION) endif # CONFIG_INTEL_ADD_TOP_SWAP_BOOTBLOCK endif # CONFIG_CPU_INTEL_FIRMWARE_INTERFACE_TABLE mv $@.tmp $@ diff --git a/src/cpu/intel/fit/Makefile.mk b/src/cpu/intel/fit/Makefile.mk index f405c57744..c8bb5bd26f 100644 --- a/src/cpu/intel/fit/Makefile.mk +++ b/src/cpu/intel/fit/Makefile.mk @@ -13,9 +13,14 @@ intel_fit-file := fit_table.c:struct intel_fit-type := intel_fit intel_fit-align := 16 +ifeq ($(CONFIG_INTEL_TOP_SWAP_SEPARATE_REGIONS),y) +regions-for-file-intel_fit = BOOTBLOCK +regions-for-file-intel_fit_ts = TOPSWAP +endif + $(call add_intermediate, set_fit_ptr, $(IFITTOOL)) @printf " UPDATE-FIT set FIT pointer to table\n" - $(IFITTOOL) -f $< -F -n intel_fit -r COREBOOT -c + $(IFITTOOL) -f $< -F -n intel_fit -r $(BB_FIT_REGION) -c FIT_ENTRY=$(call strip_quotes, $(CONFIG_INTEL_TOP_SWAP_FIT_ENTRY_FMAP_REG)) @@ -24,22 +29,23 @@ ifneq ($(CONFIG_UPDATE_IMAGE),y) # never update the bootblock ifneq ($(CONFIG_CPU_MICROCODE_CBFS_NONE)$(CONFIG_CPU_INTEL_MICROCODE_CBFS_SPLIT_BINS),y) $(call add_intermediate, add_mcu_fit, set_fit_ptr $(IFITTOOL)) + @printf "$(call regions-for-file,$(cpu_microcode_blob.bin))" @printf " UPDATE-FIT Microcode\n" - $(IFITTOOL) -f $< -a -n cpu_microcode_blob.bin -t 1 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) -r COREBOOT + $(IFITTOOL) -f $< -a -n cpu_microcode_blob.bin -t 1 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) -r $(BB_FIT_REGION) -R COREBOOT # Second FIT in TOP_SWAP bootblock ifeq ($(CONFIG_INTEL_ADD_TOP_SWAP_BOOTBLOCK),y) $(call add_intermediate, set_ts_fit_ptr, $(IFITTOOL)) @printf " UPDATE-FIT Top Swap: set FIT pointer to table\n" - $(IFITTOOL) -f $< -F -n intel_fit_ts -r COREBOOT $(TS_OPTIONS) + $(IFITTOOL) -f $< -F -n intel_fit_ts -r $(TS_FIT_REGION) $(TS_OPTIONS) $(call add_intermediate, add_ts_mcu_fit, set_ts_fit_ptr $(IFITTOOL)) @printf " UPDATE-FIT Top Swap: Microcode\n" ifneq ($(FIT_ENTRY),) - $(IFITTOOL) -f $< -A -n $(FIT_ENTRY) -t 1 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) $(TS_OPTIONS) -r COREBOOT + $(IFITTOOL) -f $< -A -n $(FIT_ENTRY) -t 1 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) $(TS_OPTIONS) -r $(TS_FIT_REGION) endif # FIT_ENTRY - $(IFITTOOL) -f $< -a -n cpu_microcode_blob.bin -t 1 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) $(TS_OPTIONS) -r COREBOOT + $(IFITTOOL) -f $< -a -n cpu_microcode_blob.bin -t 1 -s $(CONFIG_CPU_INTEL_NUM_FIT_ENTRIES) $(TS_OPTIONS) -r $(TS_FIT_REGION) -R COREBOOT cbfs-files-y += intel_fit_ts intel_fit_ts-file := fit_table.c:struct diff --git a/src/soc/intel/common/Kconfig.common b/src/soc/intel/common/Kconfig.common index d52bc1a0fa..be05c65315 100644 --- a/src/soc/intel/common/Kconfig.common +++ b/src/soc/intel/common/Kconfig.common @@ -48,6 +48,15 @@ config INTEL_TOP_SWAP_FIT_ENTRY_FMAP_REG onto ifittool (-A -n option). ifittool will not parse the region for MCU entries, and only locate the region and insert its address into FIT. +config INTEL_TOP_SWAP_SEPARATE_REGIONS + bool "Place the regular and Top Swap bootblocks in separate fmap regions" + depends on INTEL_ADD_TOP_SWAP_BOOTBLOCK && BOOTBLOCK_IN_CBFS + default n + help + Place the bootblocks in BOOTBLOCK and TOPSWAP regions for easy access, to + facilitate firmware updates using the Top Swap as Slot A/Slot B redundancy. + Requires a custom .fmd with the regions added at the end. + endif config SOC_INTEL_COMMON