File tree Expand file tree Collapse file tree 2 files changed +12
-3
lines changed
Expand file tree Collapse file tree 2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,15 @@ const uint8_t __attribute__((section(".sig_wolfboot_raw")))
8888#define PCI_DEVICE_CONTROLLER_TO_PEX 0x6
8989#define PCIE_TRAINING_TIMEOUT_MS (100)
9090
91+ /* compile time alignment checks */
92+ #define ALIGN_CHECK (value , alignment ) ((value) & ((alignment)-1)) == 0
93+ #if !ALIGN_CHECK (FSP_S_LOAD_BASE - IMAGE_HEADER_SIZE , 16 )
94+ #error "FSP_S_LOAD_BASE must be aligned on a 16 bytes boundary"
95+ #endif
96+ #if !ALIGN_CHECK (WOLFBOOT_LOAD_BASE - IMAGE_HEADER_SIZE , 16 )
97+ #error "WOLFBOOT_LOAD_BASE must be aligned on a 16 bytes boundary"
98+ #endif
99+
91100typedef uint32_t (* memory_init_cb )(void * udp , struct efi_hob * * HobList );
92101typedef uint32_t (* temp_ram_exit_cb )(void * udp );
93102typedef uint32_t (* silicon_init_cb )(void * udp );
Original file line number Diff line number Diff line change @@ -79,9 +79,9 @@ extern uint8_t _end_wb[];
7979 */
8080void RAMFUNCTION wolfBoot_start (void )
8181{
82+ uint8_t p_hdr [IMAGE_HEADER_SIZE ] __attribute__((aligned (16 )));
8283 struct stage2_parameter * stage2_params ;
8384 struct wolfBoot_image os_image ;
84- uint8_t p_hdr [IMAGE_HEADER_SIZE ];
8585 int pA_ver = 0 , pB_ver = 0 ;
8686 uint32_t cur_part = 0 ;
8787 int ret = -1 ;
@@ -135,8 +135,8 @@ void RAMFUNCTION wolfBoot_start(void)
135135 selected = 0 ;
136136
137137 stage2_params = stage2_get_parameters ();
138- /* load the image just after wolfboot */
139- load_address = (uint32_t * )(_end_wb );
138+ /* load the image just after wolfboot, 16 bytes aligned */
139+ load_address = (uint32_t * )(((( uintptr_t ) _end_wb ) + 0xf ) & ~ 0xf );
140140 wolfBoot_printf ("Load address 0x%x\r\n" , load_address );
141141 do {
142142 failures ++ ;
You can’t perform that action at this time.
0 commit comments