Skip to content

Commit 7f04921

Browse files
committed
imx95_a55: assert the stage 1 stack top clears the OCRAM image region
1 parent a503b7b commit 7f04921

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

‎hal/imx95_a55_stage1.ld‎

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
MEMORY
55
{
66
/* The boot ROM loads this image here and enters it at EL3. LENGTH is the
7-
* same 192 KiB budget U-Boot gives SPL, so growth is a link error rather
8-
* than a silent overrun into the stack below. Both come from
9-
* WOLFBOOT_STAGE1_BASE_ADDR / WOLFBOOT_STAGE1_SIZE, so the same sources
10-
* can also be linked somewhere else for bring-up. */
7+
* same 192 KiB budget U-Boot gives SPL, so growth past it is a link error
8+
* rather than a silent overrun. Both come from WOLFBOOT_STAGE1_BASE_ADDR /
9+
* WOLFBOOT_STAGE1_SIZE, so the same sources can also be linked somewhere
10+
* else for bring-up. The stack is NOT inside this region; see END_STACK. */
1111
OCRAM(rwx): ORIGIN = @WOLFBOOT_STAGE1_BASE_ADDR@, LENGTH = @WOLFBOOT_STAGE1_SIZE@
1212
}
1313
ENTRY(_boot);
@@ -45,7 +45,13 @@ SECTIONS
4545
} > OCRAM
4646
}
4747

48-
/* Stack top, above the loaded image and below the end of the region. At the
49-
* OCRAM base this is 0x204D6000, the same address U-Boot SPL uses, so it is
50-
* known to be clear of anything the ROM or the OEI left behind. */
48+
/* Stack top. This deliberately sits ABOVE the region declared in MEMORY, in the
49+
* part of OCRAM that extends past this image's budget: at the OCRAM base it is
50+
* 0x204D6000, the same address U-Boot SPL uses, so it is known both to exist and
51+
* to be clear of anything the ROM or the OEI left behind. Being a bare symbol
52+
* assignment it is not placed in OCRAM and gets no bounds check, so the assert
53+
* below stands in for one - the stack grows down towards the image, and the gap
54+
* between the end of the region and this address is all the headroom there is. */
5155
END_STACK = @WOLFBOOT_STAGE1_BASE_ADDR@ + 0x56000;
56+
ASSERT(END_STACK > @WOLFBOOT_STAGE1_BASE_ADDR@ + @WOLFBOOT_STAGE1_SIZE@,
57+
"stage 1 stack top must stay above the OCRAM image region")

0 commit comments

Comments
 (0)