From fa3da49c84a26255510c18f293f25257bd0692d2 Mon Sep 17 00:00:00 2001 From: Adam Joseph Date: Wed, 5 Jul 2023 00:05:34 -0700 Subject: [PATCH] coreboot: update patch to add master header in both images Prior to this commit, ownerboot had to manually add the cbfs-master-header to the NORMAL image, because the part of coreboot's build machinery which adds it had not been updated to understand ownerboot-style dual-CBFS images. This commit updates the coreboot patch so that it does that job, and removes the manual update from ownerboot. As an added benefit, the NORMAL and FALLBACK images now have identical layouts, except for the (top-aligned) bootblock on x86. --- src/coreboot/default.nix | 5 --- ...e_fallback-platform-independent-part.patch | 38 ++++++++++++------- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/coreboot/default.nix b/src/coreboot/default.nix index 5c3b226..0172221 100644 --- a/src/coreboot/default.nix +++ b/src/coreboot/default.nix @@ -191,11 +191,6 @@ stdenv.mkDerivation { #] ++ [ "V=1" ]; - # see https://review.coreboot.org/c/coreboot/+/12825/ for why this is needed - postBuild = '' - build/util/cbfstool/cbfstool build/coreboot.rom add-master-header -r NORMAL - ''; - dontPatchELF = true; installPhase = '' diff --git a/src/coreboot/patches/0017-use_fallback-platform-independent-part.patch b/src/coreboot/patches/0017-use_fallback-platform-independent-part.patch index c0c521c..bb4befe 100644 --- a/src/coreboot/patches/0017-use_fallback-platform-independent-part.patch +++ b/src/coreboot/patches/0017-use_fallback-platform-independent-part.patch @@ -1,5 +1,7 @@ -From 5956108606151925c6a0709e7dac08981c0d8990 Mon Sep 17 00:00:00 2001 -Subject: [PATCH 17/22] use_fallback(): platform-independent part +From db4da17916cbeed002e4fa8422ed2cdd82b3b26f Mon Sep 17 00:00:00 2001 +From: Your Name +Date: Thu, 2 Dec 2021 23:39:00 -0800 +Subject: [PATCH] use_fallback(): platform-independent part This commit implements the platform-independent part of a two-image fallback system. @@ -22,7 +24,7 @@ since the romcc version of the CBFS-walking routine does not understand FMAP partitions. This means that the `cmos.layout` from the FALLBACK region is used for the majority of the boot process. --- - Makefile.inc | 2 +- + Makefile.inc | 5 +++-- src/drivers/pc80/rtc/mc146818rtc.c | 9 +++++++-- src/include/bootblock_common.h | 4 ++++ src/lib/bootblock.c | 1 + @@ -30,10 +32,10 @@ the FALLBACK region is used for the majority of the boot process. src/lib/prog_loaders.c | 6 +++++- util/cbfstool/cbfs_sections.h | 2 +- util/scripts/dts-to-fmd.sh | 6 +++--- - 8 files changed, 29 insertions(+), 10 deletions(-) + 8 files changed, 31 insertions(+), 11 deletions(-) diff --git a/Makefile.inc b/Makefile.inc -index 44c58be5b7..29b348d158 100644 +index 44c58be5b78..fde7511ee82 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -727,7 +727,7 @@ extract_nth=$(subst *,$(spc),$(patsubst -%-,%,$(word $(1), $(subst |,- -,-$(2)-) @@ -45,8 +47,18 @@ index 44c58be5b7..29b348d158 100644 ifeq ($(CONFIG_CBFS_AUTOGEN_ATTRIBUTES),y) cbfs-autogen-attributes=-g +@@ -999,7 +999,8 @@ else # ifeq ($(CONFIG_ARCH_X86),y) + -b -4 + rm -f $@.tmp.2 + endif # ifeq ($(CONFIG_ARCH_X86),y) +- $(CBFSTOOL) $@.tmp add-master-header $(TS_OPTIONS) ++ $(CBFSTOOL) $@.tmp add-master-header -rNORMAL $(TS_OPTIONS) ++ $(CBFSTOOL) $@.tmp add-master-header -rFALLBACK $(TS_OPTIONS) + $(prebuild-files) true + mv $@.tmp $@ + else # ifneq ($(CONFIG_UPDATE_IMAGE),y) diff --git a/src/drivers/pc80/rtc/mc146818rtc.c b/src/drivers/pc80/rtc/mc146818rtc.c -index 3b22a46298..ef1ef7a275 100644 +index 3b22a46298b..ef1ef7a275b 100644 --- a/src/drivers/pc80/rtc/mc146818rtc.c +++ b/src/drivers/pc80/rtc/mc146818rtc.c @@ -250,9 +250,14 @@ static enum cb_err locate_cmos_layout(struct region_device *rdev) @@ -67,7 +79,7 @@ index 3b22a46298..ef1ef7a275 100644 printk(BIOS_ERR, "RTC: cmos_layout.bin could not be found. " "Options are disabled\n"); diff --git a/src/include/bootblock_common.h b/src/include/bootblock_common.h -index 7af0cebe63..21a5efee90 100644 +index 7af0cebe633..21a5efee901 100644 --- a/src/include/bootblock_common.h +++ b/src/include/bootblock_common.h @@ -21,6 +21,9 @@ @@ -89,7 +101,7 @@ index 7af0cebe63..21a5efee90 100644 /* * C code entry point for the boot block. diff --git a/src/lib/bootblock.c b/src/lib/bootblock.c -index f2ada522eb..890c19f316 100644 +index f2ada522eb5..890c19f3160 100644 --- a/src/lib/bootblock.c +++ b/src/lib/bootblock.c @@ -28,6 +28,7 @@ __weak void bootblock_mainboard_early_init(void) { /* no-op */ } @@ -101,7 +113,7 @@ index f2ada522eb..890c19f316 100644 asmlinkage void bootblock_main_with_timestamp(uint64_t base_timestamp, struct timestamp_entry *timestamps, size_t num_timestamps) diff --git a/src/lib/cbfs.c b/src/lib/cbfs.c -index a5c9f85238..076ff1a8a9 100644 +index a5c9f852386..076ff1a8a97 100644 --- a/src/lib/cbfs.c +++ b/src/lib/cbfs.c @@ -26,6 +26,7 @@ @@ -135,7 +147,7 @@ index a5c9f85238..076ff1a8a9 100644 /* Find location of header using signed 32-bit offset from * end of CBFS region. */ diff --git a/src/lib/prog_loaders.c b/src/lib/prog_loaders.c -index a9c9addbc6..10b5746e38 100644 +index a9c9addbc60..10b5746e384 100644 --- a/src/lib/prog_loaders.c +++ b/src/lib/prog_loaders.c @@ -30,6 +30,7 @@ @@ -159,7 +171,7 @@ index a9c9addbc6..10b5746e38 100644 cbfsf_file_type(&file, &prog->cbfs_type); diff --git a/util/cbfstool/cbfs_sections.h b/util/cbfstool/cbfs_sections.h -index 3526f8d94c..fe2011cbb3 100644 +index 3526f8d94c3..fe2011cbb34 100644 --- a/util/cbfstool/cbfs_sections.h +++ b/util/cbfstool/cbfs_sections.h @@ -21,7 +21,7 @@ @@ -172,7 +184,7 @@ index 3526f8d94c..fe2011cbb3 100644 #define SECTION_ANNOTATION_CBFS "CBFS" diff --git a/util/scripts/dts-to-fmd.sh b/util/scripts/dts-to-fmd.sh -index b468b35bcd..6a02293302 100755 +index b468b35bcd7..6a022933022 100755 --- a/util/scripts/dts-to-fmd.sh +++ b/util/scripts/dts-to-fmd.sh @@ -91,9 +91,9 @@ for region in $FMAP_REGIONS; do @@ -197,5 +209,5 @@ index b468b35bcd..6a02293302 100755 printf "\n${PREFIX}BOOTBLOCK@0 128K" LOCAL_REGION_START=$(( ${LOCAL_REGION_START} + 128*1024 )) -- -2.36.1 +2.39.1