summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKyösti Mälkki <kyosti.malkki@gmail.com>2019-12-21 10:17:56 +0200
committerKyösti Mälkki <kyosti.malkki@gmail.com>2021-01-28 08:54:21 +0000
commit2289a70b6f5fa14f3e008bc6041d8a8bd4ef956b (patch)
tree6ad1858a4f11d0a05a3afb71c33c8a4396648ff9 /src
parent6c7441f5e6e667b6602aa12832a52894cf06dd89 (diff)
arch/x86: Top-align .init in bootblock
Link .init section near the end of bootblock program. It contains _start16bit, gdtptr and gdt that must be addressable from realmode, thus within top 64 KiB. Change-Id: If7b9737650362ac7cd82685cfdfaf18bd2429238 Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/47970 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Diffstat (limited to 'src')
-rw-r--r--src/arch/x86/bootblock.ld32
-rw-r--r--src/arch/x86/memlayout.ld2
-rw-r--r--src/cpu/x86/entry16.S1
-rw-r--r--src/lib/program.ld2
-rw-r--r--src/soc/amd/common/block/cpu/noncar/memlayout_x86.ld16
5 files changed, 48 insertions, 5 deletions
diff --git a/src/arch/x86/bootblock.ld b/src/arch/x86/bootblock.ld
index 479259fcbe..65952621d9 100644
--- a/src/arch/x86/bootblock.ld
+++ b/src/arch/x86/bootblock.ld
@@ -12,8 +12,27 @@ ap_sipi_vector_in_rom = (_start16bit >> 12) & 0xff;
#endif
SECTIONS {
- /* Trigger an error if I have an unusable start address */
- _bogus = ASSERT(_start16bit >= 0xffff0000, "_start16bit too low. Please report.");
+ . = _ebootblock - CONFIG_C_ENV_BOOTBLOCK_SIZE;
+
+ _bootblock = .;
+
+ INCLUDE "bootblock/lib/program.ld"
+
+ . = MIN(_ID_SECTION, _FIT_POINTER) - EARLYASM_SZ;
+ . = CONFIG(SIPI_VECTOR_IN_ROM) ? ALIGN(4096) : ALIGN(16);
+ BOOTBLOCK_TOP = .;
+ .init (.) : {
+ *(.init._start);
+ *(.init);
+ *(.init.*);
+ }
+
+ /*
+ * Allocation reserves extra space here. Alignment requirements
+ * may cause the total size of a section to change when the start
+ * address gets applied.
+ */
+ EARLYASM_SZ = SIZEOF(.init) + (CONFIG(SIPI_VECTOR_IN_ROM) ? 4096 : 16);
. = _ID_SECTION;
.id (.): {
@@ -37,4 +56,13 @@ SECTIONS {
. = 15;
BYTE(0x00);
}
+ _ebootblock = .;
}
+
+/*
+ * Tests _bogus1 and _bogus2 are here to detect case of symbol addresses truncated
+ * to 32 bits and intermediate files reaching size of close to 4 GiB.
+ */
+_bogus1 = ASSERT(_bootblock & 0x80000000, "_bootblock too low, invalid ld script");
+_bogus2 = ASSERT(_start16bit & 0x80000000, "_start16bit too low, invalid ld script");
+_bogus3 = ASSERT(_start16bit >= 0xffff0000, "_start16bit too low. Please report.");
diff --git a/src/arch/x86/memlayout.ld b/src/arch/x86/memlayout.ld
index 52694fa360..a0b0f536ff 100644
--- a/src/arch/x86/memlayout.ld
+++ b/src/arch/x86/memlayout.ld
@@ -28,8 +28,6 @@ SECTIONS
#include "car.ld"
#elif ENV_BOOTBLOCK
- BOOTBLOCK(0xffffffff - CONFIG_C_ENV_BOOTBLOCK_SIZE + 1,
- CONFIG_C_ENV_BOOTBLOCK_SIZE)
#include "car.ld"
diff --git a/src/cpu/x86/entry16.S b/src/cpu/x86/entry16.S
index 501d01d3e4..e1bfbf145d 100644
--- a/src/cpu/x86/entry16.S
+++ b/src/cpu/x86/entry16.S
@@ -35,7 +35,6 @@
/* Symbol _start16bit must reachable from the reset vector, and be aligned to
* 4kB to start AP CPUs with Startup IPI message without RAM.
*/
-.align 4096
.code16
.globl _start16bit
.type _start16bit, @function
diff --git a/src/lib/program.ld b/src/lib/program.ld
index 3eebd6cc22..7027747bd5 100644
--- a/src/lib/program.ld
+++ b/src/lib/program.ld
@@ -13,9 +13,11 @@
.text . : {
_program = .;
_text = .;
+#if !(ENV_X86 && ENV_BOOTBLOCK)
*(.init._start);
*(.init);
*(.init.*);
+#endif
*(.text._start);
*(.text.stage_entry);
KEEP(*(.metadata_hash_anchor));
diff --git a/src/soc/amd/common/block/cpu/noncar/memlayout_x86.ld b/src/soc/amd/common/block/cpu/noncar/memlayout_x86.ld
index 352472e18b..e1f2765ebb 100644
--- a/src/soc/amd/common/block/cpu/noncar/memlayout_x86.ld
+++ b/src/soc/amd/common/block/cpu/noncar/memlayout_x86.ld
@@ -110,6 +110,22 @@ SECTIONS {
_TOO_LOW = _X86_RESET_VECTOR - 0xfff0;
_bogus = ASSERT(_start16bit >= _TOO_LOW, "_start16bit too low. Please report.");
+ . = _X86_RESET_VECTOR - EARLYASM_SZ;
+ . = ALIGN(16);
+ BOOTBLOCK_TOP = .;
+ .init (.) : {
+ *(.init._start);
+ *(.init);
+ *(.init.*);
+ }
+
+ /*
+ * Allocation reserves extra space here. Alignment requirements
+ * may cause the total size of a section to change when the start
+ * address gets applied.
+ */
+ EARLYASM_SZ = SIZEOF(.init) + 16;
+
. = BOOTBLOCK_END - 0x10;
_X86_RESET_VECTOR = .;
.reset . : {