From 76ab2b7a8a62e80b0ccdad60f15113fa6d73187f Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Tue, 30 Oct 2018 12:15:10 -0600 Subject: arch/x86: allow global .bss objects without CAR_GLOBAL For platforms utilizing CONFIG_NO_CAR_GLOBAL_MIGRATION there's no need to automatically migrate globals. Because of this it's possible to automatically allow for uninitialized global variables which reside in the .bss section without needing to decorate those objects with CAR_GLOBAL. Change-Id: Icae806fecd936ed2ebf0c13d30ffa07c77a95150 Signed-off-by: Aaron Durbin Reviewed-on: https://review.coreboot.org/29359 Reviewed-by: Furquan Shaikh Reviewed-by: Nico Huber Tested-by: build bot (Jenkins) --- src/arch/x86/car.ld | 15 +++++++++++++++ src/arch/x86/include/arch/early_variables.h | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src/arch') diff --git a/src/arch/x86/car.ld b/src/arch/x86/car.ld index 7122776068..33fb5c926c 100644 --- a/src/arch/x86/car.ld +++ b/src/arch/x86/car.ld @@ -71,7 +71,17 @@ * cbmem console. This is useful for clearing this area on a per-stage * basis when more than one stage uses cache-as-ram for CAR_GLOBALs. */ _car_global_start = .; +#if IS_ENABLED(CONFIG_NO_CAR_GLOBAL_MIGRATION) + /* Allow global unitialized variables when CAR_GLOBALs are not used. */ + *(.bss) + *(.bss.*) + *(.sbss) + *(.sbss.*) +#else + /* .car.global_data objects only around when + * !CONFIG_NO_CAR_GLOBAL_MIGRATION is employed. */ *(.car.global_data); +#endif . = ALIGN(ARCH_POINTER_ALIGN_SIZE); _car_global_end = .; _car_relocatable_data_end = .; @@ -88,10 +98,15 @@ .illegal_globals . : { *(EXCLUDE_FILE ("*/libagesa.*.a:" "*/romstage*/buildOpts.o" "*/romstage*/agesawrapper.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data) *(EXCLUDE_FILE ("*/libagesa.*.a:" "*/romstage*/buildOpts.o" "*/romstage*/agesawrapper.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data.*) +#if !IS_ENABLED(CONFIG_NO_CAR_GLOBAL_MIGRATION) *(.bss) *(.bss.*) *(.sbss) *(.sbss.*) +#else + /* In case something sneaks through when it shouldn't. */ + *(.car.global_data); +#endif } _bogus = ASSERT((CONFIG_DCACHE_RAM_SIZE == 0) || (SIZEOF(.car.data) <= CONFIG_DCACHE_RAM_SIZE), "Cache as RAM area is too full"); diff --git a/src/arch/x86/include/arch/early_variables.h b/src/arch/x86/include/arch/early_variables.h index 1b6810de86..d215e47bc0 100644 --- a/src/arch/x86/include/arch/early_variables.h +++ b/src/arch/x86/include/arch/early_variables.h @@ -20,7 +20,7 @@ #include #include -#if ENV_CACHE_AS_RAM +#if ENV_CACHE_AS_RAM && !IS_ENABLED(CONFIG_NO_CAR_GLOBAL_MIGRATION) asm(".section .car.global_data,\"w\",@nobits"); asm(".previous"); #ifdef __clang__ @@ -34,7 +34,7 @@ asm(".previous"); * accessed unconditionally because cbmem is never initialized until romstage * when dram comes up. */ -#if ENV_VERSTAGE || ENV_BOOTBLOCK || IS_ENABLED(CONFIG_NO_CAR_GLOBAL_MIGRATION) +#if ENV_VERSTAGE || ENV_BOOTBLOCK static inline void *car_get_var_ptr(void *var) { return var; -- cgit v1.2.3