From f99719a69568760188529581b5cbe9c52185835b Mon Sep 17 00:00:00 2001 From: Marc Hartmayer Date: Thu, 21 Nov 2024 18:26:50 +0000 Subject: [PATCH] rust/pvimg/boot: Hard code location and size of the stage3a BSS section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Hardcode the location and size of the BSS section of stage3a to 0xc000 and 0x1000. This change is made in preparation for storing the Secure Execution image metadata at the address of the BSS section of stage3a. The idea behind this is that since there is no ELF loader involved, the stage3a loader will memset it's BSS section and therefore the Secure Execution image metadata to 0. This way, it's avoided having any leftover metadata after running the stage3a loader. In addition, add .bss.* as input sections for the .bss section. Reviewed-by: Steffen Eiden Signed-off-by: Marc Hartmayer Signed-off-by: Jan Höppner --- rust/pvimg/boot/stage3a.h | 2 ++ rust/pvimg/boot/stage3a.lds.S | 16 ++++++++++------ 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/rust/pvimg/boot/stage3a.h b/rust/pvimg/boot/stage3a.h index 538c876d..aae565b6 100644 --- a/rust/pvimg/boot/stage3a.h +++ b/rust/pvimg/boot/stage3a.h @@ -13,6 +13,8 @@ #include "lib/zt_common.h" #include "boot/loaders_layout.h" +#define STAGE3A_BSS_ADDRESS _AC(0xc000, UL) +#define STAGE3A_BSS_SIZE _AC(0x1000, UL) #define STAGE3A_INIT_ENTRY IMAGE_ENTRY #define STAGE3A_ENTRY (STAGE3A_INIT_ENTRY + _AC(0x1000, UL)) #define STAGE3A_LOAD_ADDRESS IMAGE_LOAD_ADDRESS diff --git a/rust/pvimg/boot/stage3a.lds.S b/rust/pvimg/boot/stage3a.lds.S index cc50948d..9b77c6ea 100644 --- a/rust/pvimg/boot/stage3a.lds.S +++ b/rust/pvimg/boot/stage3a.lds.S @@ -32,6 +32,16 @@ SECTIONS } __heap_stop = .; + . = STAGE3A_BSS_ADDRESS; + __bss_start = .; + .bss : { + *(.bss .bss.*) + . = ALIGN(4096); + ASSERT(__bss_stop - __bss_start == STAGE3A_BSS_SIZE, + "Stack section doesn't conform to the described memory layout"); + } + __bss_stop = .; + . = STACK_ADDRESS; __stack_start = .; .stack : { @@ -64,12 +74,6 @@ SECTIONS __ex_table_stop = .; } - .bss ALIGN(16) : { - __bss_start = .; - *(.bss) - __bss_stop = .; - } - .rodata ALIGN(16) : { *(.rodata) *(.rodata*)