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