From 663c446439d110453b2d22275d7fddf6410dcc99 Mon Sep 17 00:00:00 2001 From: TuxSH Date: Wed, 21 Feb 2018 00:53:23 +0100 Subject: [PATCH] Mention that Nintendo copy-pasted some startup code from arm-trusted-firmware --- exosphere/smc_user.c | 4 ++-- exosphere/start.cold.s | 21 +++++++++++++++++++-- exosphere/start.warm.s | 21 +++++++++++++++++++-- 3 files changed, 40 insertions(+), 6 deletions(-) diff --git a/exosphere/smc_user.c b/exosphere/smc_user.c index d05a7997a..b79fe0927 100644 --- a/exosphere/smc_user.c +++ b/exosphere/smc_user.c @@ -417,7 +417,7 @@ uint32_t user_decrypt_rsa_private_key(smc_args_t *args) { } is_personalized = (int)args->X[3]; user_address = (void *)args->X[4]; - size = = (size_t)args->X[5]; + size = (size_t)args->X[5]; wrapped_key[0] = args->X[6]; wrapped_key[1] = args->X[7]; @@ -609,4 +609,4 @@ uint32_t user_unwrap_aes_wrapped_titlekey(smc_args_t *args) { args->X[1] = sealed_titlekey[0]; args->X[2] = sealed_titlekey[1]; -} \ No newline at end of file +} diff --git a/exosphere/start.cold.s b/exosphere/start.cold.s index be0bdf862..f959358bc 100644 --- a/exosphere/start.cold.s +++ b/exosphere/start.cold.s @@ -1,7 +1,14 @@ -.align 4 +.align 6 .section .text.cold.start, "ax", %progbits .global __start_cold __start_cold: + /* Nintendo copy-pasted https://github.com/ARM-software/arm-trusted-firmware/blob/master/plat/nvidia/tegra/common/aarch64/tegra_helpers.S#L312 */ + /* + * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + /* The following comments are mine. */ /* mask all interrupts */ msr daifset, daif @@ -25,6 +32,10 @@ __start_cold: bic x0, x0, #1 msr cpuactlr_el1, x0 +.rept 7 + nop /* wait long enough for the write to cpuactlr_el1 to have completed */ +.endr + /* if the OS lock is set, disable it and request a warm reset */ mrs x0, oslsr_el1 ands x0, x0, #2 @@ -39,7 +50,13 @@ __start_cold: msr rmr_el3, x0 isb dsb - wfi + /* Nintendo forgot to copy-paste the branch instruction below. */ + _reset_wfi: + wfi + b _reset_wfi +.rept 65 + nop /* guard against speculative excecution */ +.endr _set_lock_and_sp: /* set the OS lock */ diff --git a/exosphere/start.warm.s b/exosphere/start.warm.s index b39b3b337..a27fbf528 100644 --- a/exosphere/start.warm.s +++ b/exosphere/start.warm.s @@ -1,7 +1,14 @@ -.align 4 +.align 6 .section .text.warm.start, "ax", %progbits .global __start_warm __start_warm: + /* Nintendo copy-pasted https://github.com/ARM-software/arm-trusted-firmware/blob/master/plat/nvidia/tegra/common/aarch64/tegra_helpers.S#L312 */ + /* + * Copyright (c) 2015-2017, ARM Limited and Contributors. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + /* The following comments are mine. */ /* mask all interrupts */ msr daifset, daif @@ -25,6 +32,10 @@ __start_warm: bic x0, x0, #1 msr cpuactlr_el1, x0 +.rept 7 + nop /* wait long enough for the write to cpuactlr_el1 to have completed */ +.endr + /* if the OS lock is set, disable it and request a warm reset */ mrs x0, oslsr_el1 ands x0, x0, #2 @@ -39,7 +50,13 @@ __start_warm: msr rmr_el3, x0 isb dsb - wfi + /* Nintendo forgot to copy-paste the branch instruction below. */ + _reset_wfi: + wfi + b _reset_wfi +.rept 65 + nop /* guard against speculative excecution */ +.endr _set_lock_and_sp: /* set the OS lock */