From 2efe4df5227a1d7b6bf32b2f6611a1ef125c4b25 Mon Sep 17 00:00:00 2001 From: Maximilian Brune Date: Sun, 9 Mar 2025 00:02:00 +0100 Subject: [PATCH] treewide: Assume FMAP_SECTION_FLASH_START = 0 Now that we require the FMAP to start at offset 0 in the flash, we can assume this across the entire codebase and therefore simplify it on several ends. Signed-off-by: Maximilian Brune Change-Id: Ieb1a23f9c0ae8c0e1c91287d7eb6f7f0abbf0c2c Reviewed-on: https://review.coreboot.org/c/coreboot/+/86771 Reviewed-by: Erik van den Bogaert Reviewed-by: Frans Hendriks Tested-by: build bot (Jenkins) Reviewed-by: Shuo Liu --- src/arch/x86/walkcbfs.S | 4 ---- src/lib/cbfs_master_header.c | 5 ++--- src/lib/master_header_pointer.c | 4 ---- src/soc/amd/common/Makefile.mk | 4 +--- src/soc/intel/common/block/fast_spi/Makefile.mk | 2 -- src/southbridge/amd/pi/hudson/Makefile.mk | 4 ++-- .../eltan/security/verified_boot/vboot_check.c | 4 ---- tests/lib/fmap-test.c | 2 +- util/amdfwtool/opts.c | 10 ---------- 9 files changed, 6 insertions(+), 33 deletions(-) diff --git a/src/arch/x86/walkcbfs.S b/src/arch/x86/walkcbfs.S index a017ee1e5c..37eab33161 100644 --- a/src/arch/x86/walkcbfs.S +++ b/src/arch/x86/walkcbfs.S @@ -17,11 +17,7 @@ #define CBFS_FILE_STRUCTSIZE (CBFS_FILE_OFFSET + 4) -#if FMAP_SECTION_COREBOOT_START < (0xffffffff - CONFIG_ROM_SIZE + 1) #define COREBOOT_CBFS_START (0xffffffff - CONFIG_ROM_SIZE + 1 + FMAP_SECTION_COREBOOT_START) -#else -#define COREBOOT_CBFS_START FMAP_SECTION_COREBOOT_START -#endif .code32 .section .init diff --git a/src/lib/cbfs_master_header.c b/src/lib/cbfs_master_header.c index d358d1a37d..41bba01353 100644 --- a/src/lib/cbfs_master_header.c +++ b/src/lib/cbfs_master_header.c @@ -14,8 +14,7 @@ struct cbfs_header header = { * representing the CBFS region's size is added to the offset of * the region within a larger image. */ - .romsize = cpu_to_be32(FMAP_SECTION_COREBOOT_START + FMAP_SECTION_COREBOOT_SIZE - - FMAP_SECTION_FLASH_START), + .romsize = cpu_to_be32(FMAP_SECTION_COREBOOT_START + FMAP_SECTION_COREBOOT_SIZE), /* * The 4 bytes are left out for two reasons: * 1. the cbfs master header pointer resides there @@ -25,6 +24,6 @@ struct cbfs_header header = { */ .bootblocksize = cpu_to_be32(4), .align = cpu_to_be32(CBFS_ALIGNMENT), - .offset = cpu_to_be32(FMAP_SECTION_COREBOOT_START - FMAP_SECTION_FLASH_START), + .offset = cpu_to_be32(FMAP_SECTION_COREBOOT_START), .architecture = cpu_to_be32(CBFS_ARCHITECTURE_UNKNOWN), }; diff --git a/src/lib/master_header_pointer.c b/src/lib/master_header_pointer.c index b2c3fe64ef..f73cc2997e 100644 --- a/src/lib/master_header_pointer.c +++ b/src/lib/master_header_pointer.c @@ -9,11 +9,7 @@ __attribute__((used, __section__(".header_pointer"))) #endif -#if FMAP_SECTION_COREBOOT_START < (0xffffffff - CONFIG_ROM_SIZE + 1) #define COREBOOT_CBFS_START (0xffffffff - CONFIG_ROM_SIZE + 1 + FMAP_SECTION_COREBOOT_START) -#else -#define COREBOOT_CBFS_START FMAP_SECTION_COREBOOT_START -#endif uint32_t header_pointer = cpu_to_le32(COREBOOT_CBFS_START + ALIGN_UP(sizeof(struct cbfs_file) diff --git a/src/soc/amd/common/Makefile.mk b/src/soc/amd/common/Makefile.mk index a030687817..db60c01b87 100644 --- a/src/soc/amd/common/Makefile.mk +++ b/src/soc/amd/common/Makefile.mk @@ -45,9 +45,7 @@ $(objcbfs)/bootblock.bin: $(obj)/amdfw.rom $(obj)/fmap_config.h amdfw_region_start=$(subst $(spc),,FMAP_SECTION_$(call regions-for-file,apu/amdfw)_START) amdfw_offset=$(call int-subtract, \ $(CONFIG_AMD_FWM_POSITION) \ - $(call int-subtract, \ - $(call get_fmap_value,$(amdfw_region_start)) \ - $(call get_fmap_value,FMAP_SECTION_FLASH_START))) + $(call get_fmap_value,$(amdfw_region_start))) add_bootblock = \ $(CBFSTOOL) $(1) add -f $(2) -n apu/amdfw -t amdfw \ diff --git a/src/soc/intel/common/block/fast_spi/Makefile.mk b/src/soc/intel/common/block/fast_spi/Makefile.mk index ddf15748ae..6e274df69f 100644 --- a/src/soc/intel/common/block/fast_spi/Makefile.mk +++ b/src/soc/intel/common/block/fast_spi/Makefile.mk @@ -45,7 +45,6 @@ smm-y += mmap_boot.c $(call add_intermediate, check-fmap-16mib-crossing, $(obj)/fmap_config.h) fmap_get() { awk "/$$1/ { print \$$NF }" < $<; }; \ \ - flash_offset=$$(fmap_get FMAP_SECTION_FLASH_START); \ flash_size=$$(fmap_get FMAP_SECTION_FLASH_SIZE); \ if [ $$((flash_size)) -le $$((0x1000000)) ]; then \ exit; \ @@ -55,7 +54,6 @@ $(call add_intermediate, check-fmap-16mib-crossing, $(obj)/fmap_config.h) do \ start=$$(fmap_get "FMAP_SECTION_$${x}_START"); \ size=$$(fmap_get "FMAP_SECTION_$${x}_SIZE"); \ - start=$$((start-flash_offset)); \ end=$$((start+size-1)); \ if [ $$((start)) -lt $$((bios_16M_boundary)) ] && \ [ $$((end)) -ge $$((bios_16M_boundary)) ]; \ diff --git a/src/southbridge/amd/pi/hudson/Makefile.mk b/src/southbridge/amd/pi/hudson/Makefile.mk index e7ec1b73ec..9d71df5efc 100644 --- a/src/southbridge/amd/pi/hudson/Makefile.mk +++ b/src/southbridge/amd/pi/hudson/Makefile.mk @@ -48,9 +48,9 @@ CPPFLAGS_common += -I$(src)/southbridge/amd/pi/hudson/include # EC ROM should be 64K aligned. ifeq ($(CONFIG_AMDFW_OUTSIDE_CBFS),y) -HUDSON_FWM_POSITION=$(call int-add, $(call int-subtract, 0xffffffff $(CONFIG_ROM_SIZE)) 0x20000 1) +HUDSON_FWM_POSITION=0x20000 else -HUDSON_FWM_POSITION=0xfff20000 +HUDSON_FWM_POSITION=0x720000 endif ifeq ($(CONFIG_HUDSON_PSP), y) diff --git a/src/vendorcode/eltan/security/verified_boot/vboot_check.c b/src/vendorcode/eltan/security/verified_boot/vboot_check.c index 62c60f7b5d..5ac002c6b1 100644 --- a/src/vendorcode/eltan/security/verified_boot/vboot_check.c +++ b/src/vendorcode/eltan/security/verified_boot/vboot_check.c @@ -184,11 +184,7 @@ static void verified_boot_check_buffer(const char *name, void *start, size_t siz } } -#if FMAP_SECTION_COREBOOT_START < (0xffffffff - CONFIG_ROM_SIZE + 1) #define COREBOOT_CBFS_START (0xffffffff - CONFIG_ROM_SIZE + 1 + FMAP_SECTION_COREBOOT_START) -#else -#define COREBOOT_CBFS_START FMAP_SECTION_COREBOOT_START -#endif void verified_boot_check_cbfsfile(const char *name, uint32_t type, uint32_t hash_index, void **buffer, uint32_t *filesize, int32_t pcr) diff --git a/tests/lib/fmap-test.c b/tests/lib/fmap-test.c index 1cc8246b4b..d6dcd67bed 100644 --- a/tests/lib/fmap-test.c +++ b/tests/lib/fmap-test.c @@ -204,7 +204,7 @@ static void test_fmap_find_region_name(void **state) assert_int_equal(-1, fmap_find_region_name(NULL, found_area_name)); /* Try to find area outside of flash region */ - ar.offset = FMAP_SECTION_FLASH_START + FMAP_SECTION_FLASH_SIZE + 0x100; + ar.offset = FMAP_SECTION_FLASH_SIZE + 0x100; ar.size = 0x1000; assert_int_equal(-1, fmap_find_region_name(&ar, found_area_name)); diff --git a/util/amdfwtool/opts.c b/util/amdfwtool/opts.c index 5d1ee6754d..15bc7ca3a5 100644 --- a/util/amdfwtool/opts.c +++ b/util/amdfwtool/opts.c @@ -639,16 +639,6 @@ int amdfwtool_getopt(int argc, char *argv[], amd_cb_config *cb_config, context * printf(" AMDFWTOOL Using ROM size of %dKB\n", ctx->rom_size / 1024); - if (ctx->rom_size <= MAX_MAPPED_WINDOW) { - uint32_t rom_base_address; - - rom_base_address = 0xFFFFFFFF - ctx->rom_size + 1; - if (cb_config->efs_location & ~MAX_MAPPED_WINDOW_MASK) - cb_config->efs_location = cb_config->efs_location - rom_base_address; - if (cb_config->body_location & ~MAX_MAPPED_WINDOW_MASK) - cb_config->body_location = cb_config->body_location - rom_base_address; - } - /* If the flash size is larger than 16M, we assume the given addresses are already relative ones. Otherwise we print error.*/ if (cb_config->efs_location && cb_config->efs_location > ctx->rom_size) {