File tree Expand file tree Collapse file tree 3 files changed +22
-9
lines changed
Expand file tree Collapse file tree 3 files changed +22
-9
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,13 @@ void arch_init(void)
7575 configure_gicv2 ();
7676#endif
7777
78+ /* Drop to correct EL before disabling MMU */
79+ int r = ensure_correct_el (0 );
80+ if (r != 0 ) {
81+ puts ("LDR|ERROR: failed to ensure correct EL\n" );
82+ fail ();
83+ }
84+
7885 /* Disable the MMU, as U-Boot will start in virtual memory on some platforms
7986 * (https://docs.u-boot.org/en/latest/arch/arm64.html), which means that
8087 * certain physical memory addresses contain page table information which
@@ -95,6 +102,7 @@ void arch_init(void)
95102 el2_mmu_disable ();
96103 } else {
97104 puts ("LDR|ERROR: unknown EL level for MMU disable\n" );
105+ fail ();
98106 }
99107
100108 // TODO: handle non-PSCI platforms better, see https://github.com/seL4/microkit/issues/401.
Original file line number Diff line number Diff line change @@ -138,6 +138,14 @@ void relocation_log(uint64_t reloc_addr, uint64_t curr_addr)
138138 puts ("\n" );
139139}
140140
141+ _Noreturn void fail (void )
142+ {
143+ /* IMPROVEMENT: use SMC SVC call to try and power-off / reboot system.
144+ * or at least go to a WFI loop
145+ */
146+ while (1 ) {}
147+ }
148+
141149int main (void )
142150{
143151 int r ;
@@ -153,7 +161,7 @@ int main(void)
153161 /* Check that the loader magic number is set correctly */
154162 if (loader_data -> magic != MAGIC ) {
155163 puts ("LDR|ERROR: mismatch on loader data structure magic number\n" );
156- goto fail ;
164+ fail () ;
157165 }
158166
159167 print_loader_data ();
@@ -174,7 +182,7 @@ int main(void)
174182 putdecimal (cpu );
175183 puts (" returned error: " );
176184 puthex32 (r );
177- goto fail ;
185+ fail () ;
178186 }
179187
180188#ifdef CONFIG_PRINTING
@@ -186,12 +194,6 @@ int main(void)
186194 }
187195
188196 start_kernel (0 );
189-
190- fail :
191197 /* Note: can't usefully return to U-Boot once we are here. */
192- /* IMPROVEMENT: use SMC SVC call to try and power-off / reboot system.
193- * or at least go to a WFI loop
194- */
195- for (;;) {
196- }
198+ fail ();
197199}
Original file line number Diff line number Diff line change @@ -48,6 +48,9 @@ void relocation_log(uint64_t reloc_addr, uint64_t curr_addr);
4848
4949extern uint64_t _stack [NUM_ACTIVE_CPUS ][STACK_SIZE / sizeof (uint64_t )];
5050
51+ /* Fatal error, call to not continue execution of the loader. */
52+ void fail (void );
53+
5154void start_kernel (int logical_cpu );
5255
5356#endif
You can’t perform that action at this time.
0 commit comments