From 02e01360fdb933fc1716582f2eb4663f98094fe4 Mon Sep 17 00:00:00 2001 From: Michael Scire Date: Thu, 10 May 2018 18:36:52 -0600 Subject: [PATCH] Exosphere: Fix crt0 bug resulting in bad relocation calculations --- exosphere/src/coldboot_init.c | 7 ++++--- exosphere/src/start.s | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/exosphere/src/coldboot_init.c b/exosphere/src/coldboot_init.c index 132398a36..8b2ec3911 100644 --- a/exosphere/src/coldboot_init.c +++ b/exosphere/src/coldboot_init.c @@ -131,13 +131,14 @@ uintptr_t get_coldboot_crt0_stack_address(void) { return TZRAM_GET_SEGMENT_PA(TZRAM_SEGMENT_ID_CORE3_STACK) + 0x800; } -void coldboot_init(coldboot_crt0_reloc_list_t *reloc_list, boot_func_list_t *func_list, boot_func_list_t *func_list_warmboot) { - MAILBOX_NX_SECMON_BOOT_TIME = TIMERUS_CNTR_1US_0; +void coldboot_init(coldboot_crt0_reloc_list_t *reloc_list, boot_func_list_t *func_list, boot_func_list_t *func_list_warmboot, uintptr_t start_cold) { + //MAILBOX_NX_SECMON_BOOT_TIME = TIMERUS_CNTR_1US_0; boot_func_list_t func_copy = *func_list; /* Custom approach */ - reloc_list->reloc_base = (uintptr_t)__start_cold; + reloc_list->reloc_base = start_cold; translate_func_list(reloc_list, func_list, false); + /* From https://events.static.linuxfound.org/sites/events/files/slides/slides_17.pdf : diff --git a/exosphere/src/start.s b/exosphere/src/start.s index 8703c97ce..326305977 100644 --- a/exosphere/src/start.s +++ b/exosphere/src/start.s @@ -90,6 +90,7 @@ __start_cold: mov x19, x0 adr x1, g_coldboot_crt0_main_func_list ldr x2, =g_warmboot_crt0_main_func_list + adr x3, __start_cold bl coldboot_init ldr x16, =__jump_to_main_cold