arch/x86: Restrict use of _car_global[start|end]

Restrict the use of symbol names _car_global_[start|end]
to be used exclusively with CAR_GLOBAL_MIGRATION=y.
They just alias the start and end of .bss section in CAR.

Change-Id: I36c858a4f181516d4c61f9fd1d5005c7d2c06057
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/35034
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
Reviewed-by: Marshall Dawson <marshalldawson3rd@gmail.com>
This commit is contained in:
Kyösti Mälkki 2019-08-22 12:56:22 +03:00
parent 1095bfafed
commit 910490f3f4
6 changed files with 25 additions and 21 deletions

View File

@ -32,11 +32,11 @@ _start:
/* reset stack pointer to CAR stack */ /* reset stack pointer to CAR stack */
mov $_car_stack_end, %esp mov $_car_stack_end, %esp
/* clear CAR_GLOBAL area as it is not shared */ /* clear .bss section as it is not shared */
cld cld
xor %eax, %eax xor %eax, %eax
movl $(_car_global_end), %ecx movl $(_ebss), %ecx
movl $(_car_global_start), %edi movl $(_bss), %edi
sub %edi, %ecx sub %edi, %ecx
shrl $2, %ecx shrl $2, %ecx
rep stosl rep stosl

View File

@ -64,11 +64,13 @@
. += 80; . += 80;
_car_ehci_dbg_info_end = .; _car_ehci_dbg_info_end = .;
/* _car_global_start and _car_global_end provide symbols to per-stage /* _bss and _ebss provide symbols to per-stage
* variables that are not shared like the timestamp and the pre-ram * variables that are not shared like the timestamp and the pre-ram
* cbmem console. This is useful for clearing this area on a per-stage * 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. */ * basis when more than one stage uses cache-as-ram for CAR_GLOBALs. */
_car_global_start = .;
. = ALIGN(ARCH_POINTER_ALIGN_SIZE);
_bss = .;
#if ENV_STAGE_HAS_BSS_SECTION #if ENV_STAGE_HAS_BSS_SECTION
/* Allow global uninitialized variables for stages without CAR teardown. */ /* Allow global uninitialized variables for stages without CAR teardown. */
*(.bss) *(.bss)
@ -76,10 +78,12 @@
*(.sbss) *(.sbss)
*(.sbss.*) *(.sbss.*)
#else #else
_car_global_start = .;
*(.car.global_data); *(.car.global_data);
_car_global_end = .;
#endif #endif
. = ALIGN(ARCH_POINTER_ALIGN_SIZE); . = ALIGN(ARCH_POINTER_ALIGN_SIZE);
_car_global_end = .; _ebss = .;
_car_unallocated_start = .; _car_unallocated_start = .;
#if !CONFIG(C_ENVIRONMENT_BOOTBLOCK) #if !CONFIG(C_ENVIRONMENT_BOOTBLOCK)

View File

@ -20,6 +20,15 @@
#if ENV_ROMSTAGE && CONFIG(CAR_GLOBAL_MIGRATION) #if ENV_ROMSTAGE && CONFIG(CAR_GLOBAL_MIGRATION)
/*
* The _car_global_[start|end]symbols cover CAR data which is relocatable
* once memory comes online. Variables with CAR_GLOBAL decoration
* reside within this region.
*/
extern char _car_global_start[];
extern char _car_global_end[];
#define _car_global_size (_car_global_end - _car_global_start)
asm(".section .car.global_data,\"w\",@nobits"); asm(".section .car.global_data,\"w\",@nobits");
asm(".previous"); asm(".previous");
#ifdef __clang__ #ifdef __clang__

View File

@ -24,8 +24,8 @@ extern char _car_region_end[];
#define _car_region_size (_car_region_end - _car_region_start) #define _car_region_size (_car_region_end - _car_region_start)
/* /*
* This is the stack used under CONFIG_C_ENVIRONMENT_BOOTBLOCK for * This is the stack area used for all stages that execute when cache-as-ram
* all stages that execute when cache-as-ram is up. * is up. Area is not cleared in between stages.
*/ */
extern char _car_stack_start[]; extern char _car_stack_start[];
extern char _car_stack_end[]; extern char _car_stack_end[];
@ -38,13 +38,4 @@ extern char _car_ehci_dbg_info_end[];
#define _car_ehci_dbg_info_size \ #define _car_ehci_dbg_info_size \
(_car_ehci_dbg_info_end - _car_ehci_dbg_info_start) (_car_ehci_dbg_info_end - _car_ehci_dbg_info_start)
/*
* The _car_global_[start|end]symbols cover CAR data which is relocatable
* once memory comes online. Variables with CAR_GLOBAL decoration
* reside within this region.
*/
extern char _car_global_start[];
extern char _car_global_end[];
#define _car_global_size (_car_global_end - _car_global_start)
#endif #endif

View File

@ -89,11 +89,11 @@ CAR_init_done:
/* Setup bootblock stack */ /* Setup bootblock stack */
mov %edx, %esp mov %edx, %esp
/* clear CAR_GLOBAL area as it is not shared */ /* clear .bss section as it is not shared */
cld cld
xor %eax, %eax xor %eax, %eax
movl $(_car_global_end), %ecx movl $(_ebss), %ecx
movl $(_car_global_start), %edi movl $(_bss), %edi
sub %edi, %ecx sub %edi, %ecx
shrl $2, %ecx shrl $2, %ecx
rep stosl rep stosl

View File

@ -115,7 +115,7 @@ void platform_fsp_memory_init_params_cb(FSPM_UPD *fspm_upd, uint32_t version)
aupd->StackBase); aupd->StackBase);
printk(BIOS_SPEW, "| |\n"); printk(BIOS_SPEW, "| |\n");
printk(BIOS_SPEW, "+-------------------+ 0x%p\n", printk(BIOS_SPEW, "+-------------------+ 0x%p\n",
_car_global_end); _car_unallocated_start);
printk(BIOS_SPEW, "| coreboot data |\n"); printk(BIOS_SPEW, "| coreboot data |\n");
printk(BIOS_SPEW, "+-------------------+ 0x%p\n", printk(BIOS_SPEW, "+-------------------+ 0x%p\n",
_car_stack_end); _car_stack_end);