From 7158a1746c7bf62e57265dedd0170f93824258a0 Mon Sep 17 00:00:00 2001 From: Maximilian Brune Date: Sat, 29 Nov 2025 04:41:24 +0100 Subject: [PATCH] treewide: Move check-ramstage-overlap variables Moves the variables to more appropriate locations to save some lines and make it more readable. For x86 it now also adds the intermediate, but since x86 doesn't define any regions (e.g. ramstage) to check against, the intermediate is effectively skipped. Signed-off-by: Maximilian Brune Change-Id: I28371ae3416040243f238271ba45238ceccfcf0b Reviewed-on: https://review.coreboot.org/c/coreboot/+/90816 Reviewed-by: Matt DeVillier Reviewed-by: Julius Werner Tested-by: build bot (Jenkins) --- Makefile.mk | 16 +++++++++------- src/arch/arm/Makefile.mk | 6 ++---- src/arch/arm64/Makefile.mk | 10 ++-------- src/arch/ppc64/Makefile.mk | 2 ++ src/arch/riscv/Makefile.mk | 6 ++---- src/arch/x86/Makefile.mk | 4 ++++ 6 files changed, 21 insertions(+), 23 deletions(-) diff --git a/Makefile.mk b/Makefile.mk index 14f9b835d7..5fccb4a52d 100644 --- a/Makefile.mk +++ b/Makefile.mk @@ -1447,11 +1447,6 @@ bootsplash$(BOOTSPLASH_SUFFIX)-file := $(call strip_quotes,$(CONFIG_BOOTSPLASH_F bootsplash$(BOOTSPLASH_SUFFIX)-type := bootsplash endif -# Ensure that no payload segment overlaps with memory regions used by ramstage -# (not for x86 since it can relocate itself in that case) -ifneq ($(CONFIG_ARCH_X86),y) -check-ramstage-overlap-regions := ramstage -check-ramstage-overlap-files := ifneq ($(CONFIG_PAYLOAD_NONE),y) check-ramstage-overlap-files += $(CONFIG_CBFS_PREFIX)/payload endif @@ -1464,6 +1459,15 @@ ramstage-symbol-addr-cmd = $(OBJDUMP_ramstage) -t $(objcbfs)/ramstage.elf | \ sed -n '/ $(1)$$/s/^\([0-9a-fA-F]*\) .*/0x\1/p' | \ uniq +# Ensures that no segments from files in check-ramstage-overlap-files overlap memory regions +# used by ramstage. By default the segments of the payload are checked against the ramstage +# segments, but there may be other executables in RAM (e.g. BL31, OPENSBI). So Architecture +# Makefiles may add relevant executables to `check-ramstage-overlap-files`. Architecture +# Makefiles need to initialize `check-ramstage-overlap-regions` to use this check. +# For example: +# Common regions to add are `ramstage`, `stack` or `postram_cbfs_cache`. Which means that the +# ramstage segments `ramstage`, `stack`, `postram_cbfs_cache` are checked to make sure they +# don't overlap with the segments of check-ramstage-overlap-files (e.g. payload). $(call add_intermediate, check-ramstage-overlaps) programs=$$($(foreach file,$(check-ramstage-overlap-files), \ $(call cbfs-get-segments-cmd,$(file)) ; )) ; \ @@ -1489,5 +1493,3 @@ $(call add_intermediate, check-ramstage-overlaps) done ; \ pstart= ; pend= ; \ done - -endif diff --git a/src/arch/arm/Makefile.mk b/src/arch/arm/Makefile.mk index ef87dcf14f..89cca2b793 100644 --- a/src/arch/arm/Makefile.mk +++ b/src/arch/arm/Makefile.mk @@ -4,10 +4,6 @@ # ARM specific options ############################################################################### -ifeq ($(CONFIG_ARCH_RAMSTAGE_ARM),y) -check-ramstage-overlap-regions += postram_cbfs_cache stack ttb -endif - ifeq ($(CONFIG_ARCH_ARM),y) subdirs-y += libgcc/ subdirs-y += armv4/ armv7/ @@ -99,6 +95,8 @@ endif # CONFIG_ARCH_ROMSTAGE_ARM ifeq ($(CONFIG_ARCH_RAMSTAGE_ARM),y) +check-ramstage-overlap-regions += postram_cbfs_cache stack ttb ramstage + ramstage-y += stages.c ramstage-y += div0.c ramstage-y += eabi_compat.c diff --git a/src/arch/arm64/Makefile.mk b/src/arch/arm64/Makefile.mk index 279d31fb47..efd628fee7 100644 --- a/src/arch/arm64/Makefile.mk +++ b/src/arch/arm64/Makefile.mk @@ -6,14 +6,6 @@ subdirs-y += armv8/ -################################################################################ -# ARM specific options -################################################################################ - -ifeq ($(CONFIG_ARCH_RAMSTAGE_ARM64),y) -check-ramstage-overlap-regions += postram_cbfs_cache stack ttb -endif - ################################################################################ # bootblock ################################################################################ @@ -106,6 +98,8 @@ endif # CONFIG_ARCH_ROMSTAGE_ARM64 ifeq ($(CONFIG_ARCH_RAMSTAGE_ARM64),y) +check-ramstage-overlap-regions += postram_cbfs_cache stack ttb ramstage + ramstage-y += div0.c ramstage-y += eabi_compat.c ramstage-y += boot.c diff --git a/src/arch/ppc64/Makefile.mk b/src/arch/ppc64/Makefile.mk index 4a118b638a..9a4a2b01e7 100644 --- a/src/arch/ppc64/Makefile.mk +++ b/src/arch/ppc64/Makefile.mk @@ -65,6 +65,8 @@ endif ################################################################################ ifeq ($(CONFIG_ARCH_RAMSTAGE_PPC64),y) +check-ramstage-overlap-regions += ramstage + ramstage-y += stages.c ramstage-y += arch_timer.c ramstage-y += boot.c diff --git a/src/arch/riscv/Makefile.mk b/src/arch/riscv/Makefile.mk index 95e439d5a9..cf393ba700 100644 --- a/src/arch/riscv/Makefile.mk +++ b/src/arch/riscv/Makefile.mk @@ -5,10 +5,6 @@ ################################################################################ ifeq ($(CONFIG_ARCH_RISCV),y) -ifeq ($(CONFIG_ARCH_RAMSTAGE_RISCV),y) -check-ramstage-overlap-regions += stack -endif - riscv_flags = -I$(src)/arch/riscv/ ifeq ($(CONFIG_ARCH_RISCV_RV64),y) @@ -134,6 +130,8 @@ endif #CONFIG_ARCH_ROMSTAGE_RISCV ################################################################################ ifeq ($(CONFIG_ARCH_RAMSTAGE_RISCV),y) +check-ramstage-overlap-regions += stack ramstage + ramstage-y = ramstage-y += ramstage.S ramstage-y += tables.c diff --git a/src/arch/x86/Makefile.mk b/src/arch/x86/Makefile.mk index 0aaa962cfa..785d35c0aa 100644 --- a/src/arch/x86/Makefile.mk +++ b/src/arch/x86/Makefile.mk @@ -224,6 +224,10 @@ $(CONFIG_CBFS_PREFIX)/postcar-compression := none ifeq ($(CONFIG_ARCH_RAMSTAGE_X86_32)$(CONFIG_ARCH_RAMSTAGE_X86_64),y) +# not adding a check-ramstage-overlap-regions here because x86 ramstage can automatically +# relocate itself to a free area (its build as a rmodule). Therefore no ramstage segments can +# overlap with other executables in RAM. + ramstage-y += acpi.c ramstage-$(CONFIG_HAVE_ACPI_RESUME) += acpi_s3.c ramstage-$(CONFIG_ACPI_BERT) += acpi_bert_storage.c