Kyösti Mälkki has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/34882 )
Change subject: arch/x86: Move stack with CAR_GLOBAL_MIGRATION ......................................................................
arch/x86: Move stack with CAR_GLOBAL_MIGRATION
With the combination of CAR_GLOBAL_MIGRATION=n and POSTCAR_STAGE=n it is expected that ramstage decompression will run in romstage. Due the way MAYBE_STATIC was defined the scratchpad of ulzman() would remain on the stack. This would conflict with the small allocation made for the stack when we have C_ENVIRONMENT_BOOTBLOCK=y.
Expand the definition of MAYBE_STATIC to cover the cases that have zero-initialisation or no initialisation. These can be located in .bss. As the large stack requirement now only applies to CAR_GLOBAL_MIGRATION=y case, stack location within CAR region can be based on that instead.
Change-Id: I58d50c6f8f922c9e8664698d77836cac2c13b126 Signed-off-by: Kyösti Mälkki kyosti.malkki@gmail.com --- M src/arch/x86/car.ld M src/cpu/Kconfig M src/cpu/intel/socket_FCBGA559/Kconfig M src/cpu/intel/socket_mPGA604/Kconfig M src/device/device_const.c M src/include/stddef.h M src/lib/lzma.c M src/lib/timestamp.c M src/northbridge/intel/haswell/Kconfig M src/security/tpm/tspi/log.c M src/soc/amd/picasso/Kconfig M src/soc/amd/stoneyridge/Kconfig M src/soc/intel/braswell/Kconfig M src/soc/intel/broadwell/Kconfig 14 files changed, 20 insertions(+), 41 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/82/34882/1
diff --git a/src/arch/x86/car.ld b/src/arch/x86/car.ld index 5351fc7..6911505 100644 --- a/src/arch/x86/car.ld +++ b/src/arch/x86/car.ld @@ -40,7 +40,7 @@ /* Stack for CAR stages. Since it persists across all stages that * use CAR it can be reused. The chipset/SoC is expected to provide * the stack size. */ -#if CONFIG(C_ENVIRONMENT_BOOTBLOCK) +#if !CONFIG(CAR_GLOBAL_MIGRATION) _car_stack_start = .; . += CONFIG_DCACHE_BSP_STACK_SIZE; _car_stack_end = .; @@ -91,7 +91,7 @@ _car_global_end = .; _car_relocatable_data_end = .;
-#if !CONFIG(C_ENVIRONMENT_BOOTBLOCK) +#if CONFIG(CAR_GLOBAL_MIGRATION) _car_stack_start = .; _car_stack_end = _car_region_end; #endif diff --git a/src/cpu/Kconfig b/src/cpu/Kconfig index 3c0bf89..7982569 100644 --- a/src/cpu/Kconfig +++ b/src/cpu/Kconfig @@ -21,7 +21,12 @@ hex
config DCACHE_BSP_STACK_SIZE + depends on !CAR_GLOBAL_MIGRATION hex + default 0x2000 + help + The amount of anticipated stack usage by bootblock and + other pre-ram stages.
config SMP bool diff --git a/src/cpu/intel/socket_FCBGA559/Kconfig b/src/cpu/intel/socket_FCBGA559/Kconfig index d3af4ca..b1b310d 100644 --- a/src/cpu/intel/socket_FCBGA559/Kconfig +++ b/src/cpu/intel/socket_FCBGA559/Kconfig @@ -21,11 +21,4 @@ hex default 0x4000
-config DCACHE_BSP_STACK_SIZE - hex - default 0x2000 - help - The amount of anticipated stack usage in CAR by bootblock and - other stages. - endif diff --git a/src/cpu/intel/socket_mPGA604/Kconfig b/src/cpu/intel/socket_mPGA604/Kconfig index 1453f99..65ac777 100644 --- a/src/cpu/intel/socket_mPGA604/Kconfig +++ b/src/cpu/intel/socket_mPGA604/Kconfig @@ -28,8 +28,4 @@ hex default 0x4000
-config DCACHE_BSP_STACK_SIZE - hex - default 0x2000 - endif # CPU_INTEL_SOCKET_MPGA604 diff --git a/src/device/device_const.c b/src/device/device_const.c index c472aea..ef16d4b 100644 --- a/src/device/device_const.c +++ b/src/device/device_const.c @@ -204,7 +204,7 @@ DEVTREE_CONST struct bus *pci_root_bus(void) { DEVTREE_CONST struct device *pci_domain; - MAYBE_STATIC DEVTREE_CONST struct bus *pci_root = NULL; + DECLARE_MAYBE_STATIC_ZERO(DEVTREE_CONST struct bus *pci_root);
if (pci_root) return pci_root; diff --git a/src/include/stddef.h b/src/include/stddef.h index 7cae2e6..26b9ef6 100644 --- a/src/include/stddef.h +++ b/src/include/stddef.h @@ -42,6 +42,14 @@ #define MAYBE_STATIC static #endif
+#if defined(__PRE_RAM__) && CONFIG(CAR_GLOBAL_MIGRATION) +#define MAYBE_STATIC_NOINIT +#define DECLARE_MAYBE_STATIC_ZERO(x) x = 0 +#else +#define MAYBE_STATIC_NOINIT static +#define DECLARE_MAYBE_STATIC_ZERO(x) static x +#endif + #ifndef __ROMCC__ /* Provide a pointer to address 0 that thwarts any "accessing this is * undefined behaviour and do whatever" trickery in compilers. diff --git a/src/lib/lzma.c b/src/lib/lzma.c index eecbb26..7700380 100644 --- a/src/lib/lzma.c +++ b/src/lib/lzma.c @@ -26,7 +26,7 @@ int res; CLzmaDecoderState state; SizeT mallocneeds; - MAYBE_STATIC unsigned char scratchpad[15980]; + MAYBE_STATIC_NOINIT unsigned char scratchpad[15980]; const unsigned char *cp;
memcpy(properties, src, LZMA_PROPERTIES_SIZE); diff --git a/src/lib/timestamp.c b/src/lib/timestamp.c index 1319b86..931da3f 100644 --- a/src/lib/timestamp.c +++ b/src/lib/timestamp.c @@ -128,7 +128,7 @@
static struct timestamp_table *timestamp_table_get(void) { - MAYBE_STATIC struct timestamp_table *ts_table = NULL; + DECLARE_MAYBE_STATIC_ZERO(struct timestamp_table *ts_table); struct timestamp_cache *ts_cache;
if (ts_table != NULL) diff --git a/src/northbridge/intel/haswell/Kconfig b/src/northbridge/intel/haswell/Kconfig index aad2674..847cc69 100644 --- a/src/northbridge/intel/haswell/Kconfig +++ b/src/northbridge/intel/haswell/Kconfig @@ -70,13 +70,6 @@ help The amount of cache-as-ram region required by the reference code.
-config DCACHE_BSP_STACK_SIZE - hex - default 0x2000 - help - The amount of anticipated stack usage in CAR by bootblock and - other stages. - config HAVE_MRC bool "Add a System Agent binary" help diff --git a/src/security/tpm/tspi/log.c b/src/security/tpm/tspi/log.c index 4019962..a513860 100644 --- a/src/security/tpm/tspi/log.c +++ b/src/security/tpm/tspi/log.c @@ -26,7 +26,7 @@
static struct tcpa_table *tcpa_cbmem_init(void) { - MAYBE_STATIC struct tcpa_table *tclt = NULL; + DECLARE_MAYBE_STATIC_ZERO(struct tcpa_table *tclt); if (tclt) return tclt;
@@ -47,7 +47,7 @@
static struct tcpa_table *tcpa_log_init(void) { - MAYBE_STATIC struct tcpa_table *tclt = NULL; + DECLARE_MAYBE_STATIC_ZERO(struct tcpa_table *tclt);
/* We are dealing here with pre CBMEM environment. * If cbmem isn't available use CAR or SRAM */ diff --git a/src/soc/amd/picasso/Kconfig b/src/soc/amd/picasso/Kconfig index 26b2ec4..9f2bc06 100644 --- a/src/soc/amd/picasso/Kconfig +++ b/src/soc/amd/picasso/Kconfig @@ -87,7 +87,6 @@ default 0x10000
config DCACHE_BSP_STACK_SIZE - depends on C_ENVIRONMENT_BOOTBLOCK hex default 0x4000 help diff --git a/src/soc/amd/stoneyridge/Kconfig b/src/soc/amd/stoneyridge/Kconfig index f1d08c0..b494166 100644 --- a/src/soc/amd/stoneyridge/Kconfig +++ b/src/soc/amd/stoneyridge/Kconfig @@ -103,7 +103,6 @@ default 0x10000
config DCACHE_BSP_STACK_SIZE - depends on C_ENVIRONMENT_BOOTBLOCK hex default 0x4000 help diff --git a/src/soc/intel/braswell/Kconfig b/src/soc/intel/braswell/Kconfig index 5d6438f..7b41f0c 100644 --- a/src/soc/intel/braswell/Kconfig +++ b/src/soc/intel/braswell/Kconfig @@ -50,13 +50,6 @@ select SOUTHBRIDGE_INTEL_COMMON_SMBUS select C_ENVIRONMENT_BOOTBLOCK
-config DCACHE_BSP_STACK_SIZE - hex - default 0x2000 - help - The amount of anticipated stack usage in CAR by bootblock and - other stages. - config C_ENV_BOOTBLOCK_SIZE hex default 0x8000 diff --git a/src/soc/intel/broadwell/Kconfig b/src/soc/intel/broadwell/Kconfig index 5856ef1..dc4dd44 100644 --- a/src/soc/intel/broadwell/Kconfig +++ b/src/soc/intel/broadwell/Kconfig @@ -119,13 +119,6 @@ help The amount of cache-as-ram region required by the reference code.
-config DCACHE_BSP_STACK_SIZE - hex - default 0x2000 - help - The amount of anticipated stack usage in CAR by bootblock and - other stages. - config HAVE_MRC bool "Add a Memory Reference Code binary" help