Patrick Georgi | 11f0079 | 2020-03-04 15:10:45 +0100 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
Aaron Durbin | 956c4f2 | 2015-09-05 13:31:14 -0500 | [diff] [blame] | 2 | |
Kyösti Mälkki | ed318f2 | 2019-01-11 21:07:36 +0200 | [diff] [blame] | 3 | /* CACHE_ROM_SIZE defined here. */ |
| 4 | #include <cpu/x86/mtrr.h> |
| 5 | |
Aaron Durbin | 956c4f2 | 2015-09-05 13:31:14 -0500 | [diff] [blame] | 6 | /* This file is included inside a SECTIONS block */ |
| 7 | . = CONFIG_DCACHE_RAM_BASE; |
| 8 | .car.data . (NOLOAD) : { |
Andrey Petrov | dd56de9 | 2016-02-25 17:22:17 -0800 | [diff] [blame] | 9 | _car_region_start = . ; |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 10 | #if CONFIG(PAGING_IN_CACHE_AS_RAM) |
Aaron Durbin | 0f35af8f | 2018-04-18 01:00:27 -0600 | [diff] [blame] | 11 | /* Page table pre-allocation. CONFIG_DCACHE_RAM_BASE should be 4KiB |
| 12 | * aligned when using this option. */ |
| 13 | _pagetables = . ; |
Frans Hendriks | d42154a | 2020-11-13 11:57:23 +0100 | [diff] [blame] | 14 | . += 4096 * CONFIG_NUM_CAR_PAGE_TABLE_PAGES; |
Aaron Durbin | 0f35af8f | 2018-04-18 01:00:27 -0600 | [diff] [blame] | 15 | _epagetables = . ; |
| 16 | #endif |
Frans Hendriks | d42154a | 2020-11-13 11:57:23 +0100 | [diff] [blame] | 17 | #if CONFIG(VBOOT_STARTS_IN_BOOTBLOCK) |
Joel Kitching | d6f71d0 | 2019-02-21 12:37:55 +0800 | [diff] [blame] | 18 | /* Vboot work buffer only needs to be available when verified boot |
| 19 | * starts in bootblock. */ |
Joel Kitching | 0097f55 | 2019-02-21 12:36:55 +0800 | [diff] [blame] | 20 | VBOOT2_WORK(., 12K) |
Aaron Durbin | 75c51d9 | 2015-09-29 16:31:20 -0500 | [diff] [blame] | 21 | #endif |
Bill XIE | c79e96b | 2019-08-22 20:28:36 +0800 | [diff] [blame] | 22 | #if CONFIG(TPM_MEASURED_BOOT) |
Frans Hendriks | d42154a | 2020-11-13 11:57:23 +0100 | [diff] [blame] | 23 | /* Vboot measured boot TCPA log measurements. |
| 24 | * Needs to be transferred until CBMEM is available */ |
Bill XIE | c79e96b | 2019-08-22 20:28:36 +0800 | [diff] [blame] | 25 | TPM_TCPA_LOG(., 2K) |
Arthur Heymans | 3c61304 | 2019-04-21 23:59:47 +0200 | [diff] [blame] | 26 | #endif |
Andrey Petrov | ee9e4ae | 2016-02-08 17:17:05 -0800 | [diff] [blame] | 27 | /* Stack for CAR stages. Since it persists across all stages that |
| 28 | * use CAR it can be reused. The chipset/SoC is expected to provide |
| 29 | * the stack size. */ |
Arthur Heymans | df9cdcf | 2019-11-09 06:50:20 +0100 | [diff] [blame] | 30 | _car_stack = .; |
Andrey Petrov | ee9e4ae | 2016-02-08 17:17:05 -0800 | [diff] [blame] | 31 | . += CONFIG_DCACHE_BSP_STACK_SIZE; |
Arthur Heymans | df9cdcf | 2019-11-09 06:50:20 +0100 | [diff] [blame] | 32 | _ecar_stack = .; |
Aaron Durbin | dd6fa93 | 2015-09-24 12:18:07 -0500 | [diff] [blame] | 33 | /* The pre-ram cbmem console as well as the timestamp region are fixed |
Arthur Heymans | 4cc9b6c | 2018-12-28 17:53:36 +0100 | [diff] [blame] | 34 | * in size. Therefore place them above the car global section so that |
Frans Hendriks | d42154a | 2020-11-13 11:57:23 +0100 | [diff] [blame] | 35 | * multiple stages (romstage and verstage) have a consistent |
| 36 | * link address of these shared objects. */ |
Kyösti Mälkki | 513a1a8 | 2018-06-03 12:29:50 +0300 | [diff] [blame] | 37 | PRERAM_CBMEM_CONSOLE(., CONFIG_PRERAM_CBMEM_CONSOLE_SIZE) |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 38 | #if CONFIG(PAGING_IN_CACHE_AS_RAM) |
Aaron Durbin | 0f35af8f | 2018-04-18 01:00:27 -0600 | [diff] [blame] | 39 | . = ALIGN(32); |
| 40 | /* Page directory pointer table resides here. There are 4 8-byte entries |
| 41 | * totalling 32 bytes that need to be 32-byte aligned. The reason the |
| 42 | * pdpt are not colocated with the rest of the page tables is to reduce |
| 43 | * fragmentation of the CAR space that persists across stages. */ |
| 44 | _pdpt = .; |
| 45 | . += 32; |
| 46 | _epdpt = .; |
| 47 | #endif |
Kyösti Mälkki | 3dd23a5 | 2019-08-22 15:06:50 +0300 | [diff] [blame] | 48 | |
Furquan Shaikh | 549080b | 2018-05-17 23:30:28 -0700 | [diff] [blame] | 49 | TIMESTAMP(., 0x200) |
Julius Werner | 7fc9286 | 2019-11-18 13:01:06 -0800 | [diff] [blame] | 50 | |
| 51 | #if !CONFIG(NO_FMAP_CACHE) |
Julius Werner | cefe89e | 2019-11-06 19:29:44 -0800 | [diff] [blame] | 52 | FMAP_CACHE(., FMAP_SIZE) |
Julius Werner | 7fc9286 | 2019-11-18 13:01:06 -0800 | [diff] [blame] | 53 | #endif |
Kyösti Mälkki | 3dd23a5 | 2019-08-22 15:06:50 +0300 | [diff] [blame] | 54 | |
Arthur Heymans | df9cdcf | 2019-11-09 06:50:20 +0100 | [diff] [blame] | 55 | _car_ehci_dbg_info = .; |
Kyösti Mälkki | f88208e | 2019-01-31 08:29:32 +0200 | [diff] [blame] | 56 | /* Reserve sizeof(struct ehci_dbg_info). */ |
Frans Hendriks | d42154a | 2020-11-13 11:57:23 +0100 | [diff] [blame] | 57 | . += 80; |
| 58 | _ecar_ehci_dbg_info = .; |
Kyösti Mälkki | 3dd23a5 | 2019-08-22 15:06:50 +0300 | [diff] [blame] | 59 | |
Kyösti Mälkki | 910490f | 2019-08-22 12:56:22 +0300 | [diff] [blame] | 60 | /* _bss and _ebss provide symbols to per-stage |
Aaron Durbin | dd6fa93 | 2015-09-24 12:18:07 -0500 | [diff] [blame] | 61 | * variables that are not shared like the timestamp and the pre-ram |
| 62 | * cbmem console. This is useful for clearing this area on a per-stage |
Arthur Heymans | fdb8b13 | 2019-11-28 14:00:01 +0100 | [diff] [blame] | 63 | * basis when more than one stage uses cache-as-ram. */ |
Kyösti Mälkki | 910490f | 2019-08-22 12:56:22 +0300 | [diff] [blame] | 64 | |
| 65 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
| 66 | _bss = .; |
Kyösti Mälkki | a165c07 | 2019-08-22 09:44:44 +0300 | [diff] [blame] | 67 | /* Allow global uninitialized variables for stages without CAR teardown. */ |
Aaron Durbin | 76ab2b7 | 2018-10-30 12:15:10 -0600 | [diff] [blame] | 68 | *(.bss) |
| 69 | *(.bss.*) |
| 70 | *(.sbss) |
| 71 | *(.sbss.*) |
Aaron Durbin | 956c4f2 | 2015-09-05 13:31:14 -0500 | [diff] [blame] | 72 | . = ALIGN(ARCH_POINTER_ALIGN_SIZE); |
Kyösti Mälkki | 910490f | 2019-08-22 12:56:22 +0300 | [diff] [blame] | 73 | _ebss = .; |
Andrey Petrov | dd56de9 | 2016-02-25 17:22:17 -0800 | [diff] [blame] | 74 | |
Harshit Sharma | a6ebe08 | 2020-07-20 00:21:05 -0700 | [diff] [blame] | 75 | #if ENV_ROMSTAGE && CONFIG(ASAN_IN_ROMSTAGE) |
| 76 | _shadow_size = (_ebss - _car_region_start) >> 3; |
| 77 | REGION(asan_shadow, ., _shadow_size, ARCH_POINTER_ALIGN_SIZE) |
| 78 | #endif |
| 79 | _car_unallocated_start = .; |
Andrey Petrov | dd56de9 | 2016-02-25 17:22:17 -0800 | [diff] [blame] | 80 | _car_region_end = . + CONFIG_DCACHE_RAM_SIZE - (. - _car_region_start); |
Aaron Durbin | 956c4f2 | 2015-09-05 13:31:14 -0500 | [diff] [blame] | 81 | } |
Kyösti Mälkki | ed318f2 | 2019-01-11 21:07:36 +0200 | [diff] [blame] | 82 | . = _car_region_end; |
| 83 | .car.mrc_var . (NOLOAD) : { |
| 84 | . += CONFIG_DCACHE_RAM_MRC_VAR_SIZE; |
| 85 | } |
| 86 | |
| 87 | #if ENV_BOOTBLOCK |
| 88 | _car_mtrr_end = .; |
| 89 | _car_mtrr_start = _car_region_start; |
| 90 | |
| 91 | _car_mtrr_size = _car_mtrr_end - _car_mtrr_start; |
| 92 | _car_mtrr_sz_log2 = 1 << LOG2CEIL(_car_mtrr_size); |
| 93 | _car_mtrr_mask = ~(MAX(4096, _car_mtrr_sz_log2) - 1); |
| 94 | |
| 95 | #if !CONFIG(NO_XIP_EARLY_STAGES) |
| 96 | _xip_program_sz_log2 = 1 << LOG2CEIL(_ebootblock - _bootblock); |
| 97 | _xip_mtrr_mask = ~(MAX(4096, _xip_program_sz_log2) - 1); |
| 98 | #endif |
| 99 | |
| 100 | _rom_mtrr_mask = ~(CACHE_ROM_SIZE - 1); |
| 101 | _rom_mtrr_base = _rom_mtrr_mask; |
| 102 | #endif |
Aaron Durbin | 956c4f2 | 2015-09-05 13:31:14 -0500 | [diff] [blame] | 103 | |
| 104 | /* Global variables are not allowed in romstage |
| 105 | * This section is checked during stage creation to ensure |
| 106 | * that there are no global variables present |
| 107 | */ |
| 108 | |
| 109 | . = 0xffffff00; |
| 110 | .illegal_globals . : { |
Nico Huber | 98fc426 | 2016-01-23 01:24:33 +0100 | [diff] [blame] | 111 | *(EXCLUDE_FILE ("*/libagesa.*.a:" "*/romstage*/buildOpts.o" "*/romstage*/agesawrapper.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data) |
Frans Hendriks | d42154a | 2020-11-13 11:57:23 +0100 | [diff] [blame] | 112 | *(EXCLUDE_FILE ("*/libagesa.*.a:" "*/romstage*/buildOpts.o" "*/romstage*/agesawrapper.o" "*/vendorcode/amd/agesa/*" "*/vendorcode/amd/cimx/*") .data.*) |
Aaron Durbin | 956c4f2 | 2015-09-05 13:31:14 -0500 | [diff] [blame] | 113 | } |
| 114 | |
Aaron Durbin | dd6fa93 | 2015-09-24 12:18:07 -0500 | [diff] [blame] | 115 | _bogus = ASSERT((CONFIG_DCACHE_RAM_SIZE == 0) || (SIZEOF(.car.data) <= CONFIG_DCACHE_RAM_SIZE), "Cache as RAM area is too full"); |
Julius Werner | cd49cce | 2019-03-05 16:53:33 -0800 | [diff] [blame] | 116 | #if CONFIG(PAGING_IN_CACHE_AS_RAM) |
Aaron Durbin | 0f35af8f | 2018-04-18 01:00:27 -0600 | [diff] [blame] | 117 | _bogus2 = ASSERT(_pagetables == ALIGN(_pagetables, 4096), "_pagetables aren't 4KiB aligned"); |
| 118 | #endif |
Patrick Rudolph | d72d52a | 2018-11-12 19:26:54 +0100 | [diff] [blame] | 119 | _bogus3 = ASSERT(CONFIG_DCACHE_BSP_STACK_SIZE > 0x0, "BSP stack size not configured"); |
Arthur Heymans | c27628e | 2019-11-05 00:46:01 +0100 | [diff] [blame^] | 120 | #if CONFIG(NO_XIP_EARLY_STAGES) && (ENV_ROMSTAGE || ENV_VERSTAGE) |
| 121 | _bogus4 = ASSERT(_eprogram <= _car_region_end, "Stage end too high !"); |
| 122 | _bogus5 = ASSERT(_program >= _car_unallocated_start, "Stage start too low!"); |
| 123 | #endif |