xref: /rk3399_ARM-atf/bl32/sp_min/aarch32/entrypoint.S (revision 56055e87b0a756d4756a22ed26b855fbe7afe93c)
1c11ba852SSoby Mathew/*
2*56055e87SStephan Gerhold * Copyright (c) 2016-2023, Arm Limited and Contributors. All rights reserved.
3c11ba852SSoby Mathew *
482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause
5c11ba852SSoby Mathew */
6c11ba852SSoby Mathew
7c11ba852SSoby Mathew#include <arch.h>
8c11ba852SSoby Mathew#include <asm_macros.S>
909d40e0eSAntonio Nino Diaz#include <common/bl_common.h>
1009d40e0eSAntonio Nino Diaz#include <common/runtime_svc.h>
11c11ba852SSoby Mathew#include <context.h>
123bdf0e5dSYatharth Kochar#include <el3_common_macros.S>
130531ada5SBence Szépkúti#include <lib/el3_runtime/cpu_data.h>
140531ada5SBence Szépkúti#include <lib/pmf/aarch32/pmf_asm_macros.S>
150531ada5SBence Szépkúti#include <lib/runtime_instr.h>
1609d40e0eSAntonio Nino Diaz#include <lib/xlat_tables/xlat_tables_defs.h>
17085e80ecSAntonio Nino Diaz#include <smccc_helpers.h>
18085e80ecSAntonio Nino Diaz#include <smccc_macros.S>
19c11ba852SSoby Mathew
20c11ba852SSoby Mathew	.globl	sp_min_vector_table
21c11ba852SSoby Mathew	.globl	sp_min_entrypoint
22c11ba852SSoby Mathew	.globl	sp_min_warm_entrypoint
237343505dSDimitris Papastamos	.globl	sp_min_handle_smc
247343505dSDimitris Papastamos	.globl	sp_min_handle_fiq
25c11ba852SSoby Mathew
264324a14bSYann Gautier#define FIXUP_SIZE	((BL32_LIMIT) - (BL32_BASE))
274324a14bSYann Gautier
2871816096SEtienne Carriere	.macro route_fiq_to_sp_min reg
2971816096SEtienne Carriere		/* -----------------------------------------------------
3071816096SEtienne Carriere		 * FIQs are secure interrupts trapped by Monitor and non
3171816096SEtienne Carriere		 * secure is not allowed to mask the FIQs.
3271816096SEtienne Carriere		 * -----------------------------------------------------
3371816096SEtienne Carriere		 */
3471816096SEtienne Carriere		ldcopr	\reg, SCR
3571816096SEtienne Carriere		orr	\reg, \reg, #SCR_FIQ_BIT
3671816096SEtienne Carriere		bic	\reg, \reg, #SCR_FW_BIT
3771816096SEtienne Carriere		stcopr	\reg, SCR
3871816096SEtienne Carriere	.endm
393bdf0e5dSYatharth Kochar
4070896274SEtienne Carriere	.macro clrex_on_monitor_entry
4170896274SEtienne Carriere#if (ARM_ARCH_MAJOR == 7)
4270896274SEtienne Carriere	/*
4370896274SEtienne Carriere	 * ARMv7 architectures need to clear the exclusive access when
4470896274SEtienne Carriere	 * entering Monitor mode.
4570896274SEtienne Carriere	 */
4670896274SEtienne Carriere	clrex
4770896274SEtienne Carriere#endif
4870896274SEtienne Carriere	.endm
4970896274SEtienne Carriere
503bdf0e5dSYatharth Kocharvector_base sp_min_vector_table
51c11ba852SSoby Mathew	b	sp_min_entrypoint
52c11ba852SSoby Mathew	b	plat_panic_handler	/* Undef */
537343505dSDimitris Papastamos	b	sp_min_handle_smc	/* Syscall */
546dc5979aSYann Gautier	b	report_prefetch_abort	/* Prefetch abort */
556dc5979aSYann Gautier	b	report_data_abort	/* Data abort */
56c11ba852SSoby Mathew	b	plat_panic_handler	/* Reserved */
57c11ba852SSoby Mathew	b	plat_panic_handler	/* IRQ */
587343505dSDimitris Papastamos	b	sp_min_handle_fiq	/* FIQ */
59c11ba852SSoby Mathew
60c11ba852SSoby Mathew
61c11ba852SSoby Mathew/*
62c11ba852SSoby Mathew * The Cold boot/Reset entrypoint for SP_MIN
63c11ba852SSoby Mathew */
64c11ba852SSoby Mathewfunc sp_min_entrypoint
653bdf0e5dSYatharth Kochar	/* ---------------------------------------------------------------
66*56055e87SStephan Gerhold	 * Stash the previous bootloader arguments r0 - r3 for later use.
673bdf0e5dSYatharth Kochar	 * ---------------------------------------------------------------
68c11ba852SSoby Mathew	 */
69a6f340feSSoby Mathew	mov	r9, r0
70a6f340feSSoby Mathew	mov	r10, r1
71a6f340feSSoby Mathew	mov	r11, r2
72a6f340feSSoby Mathew	mov	r12, r3
73c11ba852SSoby Mathew
74*56055e87SStephan Gerhold#if !RESET_TO_SP_MIN
753bdf0e5dSYatharth Kochar	/* ---------------------------------------------------------------------
763bdf0e5dSYatharth Kochar	 * For !RESET_TO_SP_MIN systems, only the primary CPU ever reaches
773bdf0e5dSYatharth Kochar	 * sp_min_entrypoint() during the cold boot flow, so the cold/warm boot
783bdf0e5dSYatharth Kochar	 * and primary/secondary CPU logic should not be executed in this case.
793bdf0e5dSYatharth Kochar	 *
8018f2efd6SDavid Cunado	 * Also, assume that the previous bootloader has already initialised the
8118f2efd6SDavid Cunado	 * SCTLR, including the CPU endianness, and has initialised the memory.
823bdf0e5dSYatharth Kochar	 * ---------------------------------------------------------------------
83c11ba852SSoby Mathew	 */
843bdf0e5dSYatharth Kochar	el3_entrypoint_common					\
8518f2efd6SDavid Cunado		_init_sctlr=0					\
863bdf0e5dSYatharth Kochar		_warm_boot_mailbox=0				\
873bdf0e5dSYatharth Kochar		_secondary_cold_boot=0				\
883bdf0e5dSYatharth Kochar		_init_memory=0					\
893bdf0e5dSYatharth Kochar		_init_c_runtime=1				\
904324a14bSYann Gautier		_exception_vectors=sp_min_vector_table		\
914324a14bSYann Gautier		_pie_fixup_size=FIXUP_SIZE
923bdf0e5dSYatharth Kochar#else
933bdf0e5dSYatharth Kochar	/* ---------------------------------------------------------------------
943bdf0e5dSYatharth Kochar	 * For RESET_TO_SP_MIN systems which have a programmable reset address,
953bdf0e5dSYatharth Kochar	 * sp_min_entrypoint() is executed only on the cold boot path so we can
963bdf0e5dSYatharth Kochar	 * skip the warm boot mailbox mechanism.
973bdf0e5dSYatharth Kochar	 * ---------------------------------------------------------------------
98c11ba852SSoby Mathew	 */
993bdf0e5dSYatharth Kochar	el3_entrypoint_common					\
10018f2efd6SDavid Cunado		_init_sctlr=1					\
1013bdf0e5dSYatharth Kochar		_warm_boot_mailbox=!PROGRAMMABLE_RESET_ADDRESS	\
1023bdf0e5dSYatharth Kochar		_secondary_cold_boot=!COLD_BOOT_SINGLE_CPU	\
1033bdf0e5dSYatharth Kochar		_init_memory=1					\
1043bdf0e5dSYatharth Kochar		_init_c_runtime=1				\
1054324a14bSYann Gautier		_exception_vectors=sp_min_vector_table		\
1064324a14bSYann Gautier		_pie_fixup_size=FIXUP_SIZE
1073bdf0e5dSYatharth Kochar#endif /* RESET_TO_SP_MIN */
108c11ba852SSoby Mathew
10971816096SEtienne Carriere#if SP_MIN_WITH_SECURE_FIQ
11071816096SEtienne Carriere	route_fiq_to_sp_min r4
11171816096SEtienne Carriere#endif
11271816096SEtienne Carriere
113*56055e87SStephan Gerhold	/* ---------------------------------------------------------------------
114*56055e87SStephan Gerhold	 * Relay the previous bootloader's arguments to the platform layer
115*56055e87SStephan Gerhold	 * ---------------------------------------------------------------------
116*56055e87SStephan Gerhold	 */
117a6f340feSSoby Mathew	mov	r0, r9
118a6f340feSSoby Mathew	mov	r1, r10
119a6f340feSSoby Mathew	mov	r2, r11
120a6f340feSSoby Mathew	mov	r3, r12
121a6f340feSSoby Mathew	bl	sp_min_early_platform_setup2
122c11ba852SSoby Mathew	bl	sp_min_plat_arch_setup
123c11ba852SSoby Mathew
124c11ba852SSoby Mathew	/* Jump to the main function */
125c11ba852SSoby Mathew	bl	sp_min_main
126c11ba852SSoby Mathew
127c11ba852SSoby Mathew	/* -------------------------------------------------------------
128c11ba852SSoby Mathew	 * Clean the .data & .bss sections to main memory. This ensures
129c11ba852SSoby Mathew	 * that any global data which was initialised by the primary CPU
130c11ba852SSoby Mathew	 * is visible to secondary CPUs before they enable their data
131c11ba852SSoby Mathew	 * caches and participate in coherency.
132c11ba852SSoby Mathew	 * -------------------------------------------------------------
133c11ba852SSoby Mathew	 */
134c11ba852SSoby Mathew	ldr	r0, =__DATA_START__
135c11ba852SSoby Mathew	ldr	r1, =__DATA_END__
136c11ba852SSoby Mathew	sub	r1, r1, r0
137c11ba852SSoby Mathew	bl	clean_dcache_range
138c11ba852SSoby Mathew
139c11ba852SSoby Mathew	ldr	r0, =__BSS_START__
140c11ba852SSoby Mathew	ldr	r1, =__BSS_END__
141c11ba852SSoby Mathew	sub	r1, r1, r0
142c11ba852SSoby Mathew	bl	clean_dcache_range
143c11ba852SSoby Mathew
144c11ba852SSoby Mathew	bl	smc_get_next_ctx
145b6285d64SSoby Mathew
146b6285d64SSoby Mathew	/* r0 points to `smc_ctx_t` */
147b6285d64SSoby Mathew	/* The PSCI cpu_context registers have been copied to `smc_ctx_t` */
148c11ba852SSoby Mathew	b	sp_min_exit
149c11ba852SSoby Mathewendfunc sp_min_entrypoint
150c11ba852SSoby Mathew
1513bdf0e5dSYatharth Kochar
1523bdf0e5dSYatharth Kochar/*
1533bdf0e5dSYatharth Kochar * SMC handling function for SP_MIN.
1543bdf0e5dSYatharth Kochar */
1557343505dSDimitris Papastamosfunc sp_min_handle_smc
156b6285d64SSoby Mathew	/* On SMC entry, `sp` points to `smc_ctx_t`. Save `lr`. */
157b6285d64SSoby Mathew	str	lr, [sp, #SMC_CTX_LR_MON]
158b6285d64SSoby Mathew
1590531ada5SBence Szépkúti#if ENABLE_RUNTIME_INSTRUMENTATION
1600531ada5SBence Szépkúti	/*
1610531ada5SBence Szépkúti	 * Read the timestamp value and store it on top of the C runtime stack.
1620531ada5SBence Szépkúti	 * The value will be saved to the per-cpu data once the C stack is
1630531ada5SBence Szépkúti	 * available, as a valid stack is needed to call _cpu_data()
1640531ada5SBence Szépkúti	 */
1650531ada5SBence Szépkúti	strd	r0, r1, [sp, #SMC_CTX_GPREG_R0]
1660531ada5SBence Szépkúti	ldcopr16 r0, r1, CNTPCT_64
1670531ada5SBence Szépkúti	ldr	lr, [sp, #SMC_CTX_SP_MON]
1680531ada5SBence Szépkúti	strd	r0, r1, [lr, #-8]!
1690531ada5SBence Szépkúti	str	lr, [sp, #SMC_CTX_SP_MON]
1700531ada5SBence Szépkúti	ldrd	r0, r1, [sp, #SMC_CTX_GPREG_R0]
1710531ada5SBence Szépkúti#endif
1720531ada5SBence Szépkúti
173085e80ecSAntonio Nino Diaz	smccc_save_gp_mode_regs
1743bdf0e5dSYatharth Kochar
17570896274SEtienne Carriere	clrex_on_monitor_entry
17670896274SEtienne Carriere
1779f3ee61cSSoby Mathew	/*
178b6285d64SSoby Mathew	 * `sp` still points to `smc_ctx_t`. Save it to a register
179b6285d64SSoby Mathew	 * and restore the C runtime stack pointer to `sp`.
1809f3ee61cSSoby Mathew	 */
181b6285d64SSoby Mathew	mov	r2, sp				/* handle */
182b6285d64SSoby Mathew	ldr	sp, [r2, #SMC_CTX_SP_MON]
183b6285d64SSoby Mathew
1840531ada5SBence Szépkúti#if ENABLE_RUNTIME_INSTRUMENTATION
1850531ada5SBence Szépkúti	/* Save handle to a callee saved register */
1860531ada5SBence Szépkúti	mov	r6, r2
1870531ada5SBence Szépkúti
1880531ada5SBence Szépkúti	/*
1890531ada5SBence Szépkúti	 * Restore the timestamp value and store it in per-cpu data. The value
1900531ada5SBence Szépkúti	 * will be extracted from per-cpu data by the C level SMC handler and
1910531ada5SBence Szépkúti	 * saved to the PMF timestamp region.
1920531ada5SBence Szépkúti	 */
1930531ada5SBence Szépkúti	ldrd	r4, r5, [sp], #8
1940531ada5SBence Szépkúti	bl	_cpu_data
1950531ada5SBence Szépkúti	strd	r4, r5, [r0, #CPU_DATA_PMF_TS0_OFFSET]
1960531ada5SBence Szépkúti
1970531ada5SBence Szépkúti	/* Restore handle */
1980531ada5SBence Szépkúti	mov	r2, r6
1990531ada5SBence Szépkúti#endif
2000531ada5SBence Szépkúti
201b6285d64SSoby Mathew	ldr	r0, [r2, #SMC_CTX_SCR]
2023bdf0e5dSYatharth Kochar	and	r3, r0, #SCR_NS_BIT		/* flags */
2033bdf0e5dSYatharth Kochar
2043bdf0e5dSYatharth Kochar	/* Switch to Secure Mode*/
2053bdf0e5dSYatharth Kochar	bic	r0, #SCR_NS_BIT
2063bdf0e5dSYatharth Kochar	stcopr	r0, SCR
2073bdf0e5dSYatharth Kochar	isb
208b6285d64SSoby Mathew
2093bdf0e5dSYatharth Kochar	ldr	r0, [r2, #SMC_CTX_GPREG_R0]	/* smc_fid */
2103bdf0e5dSYatharth Kochar	/* Check whether an SMC64 is issued */
2113bdf0e5dSYatharth Kochar	tst	r0, #(FUNCID_CC_MASK << FUNCID_CC_SHIFT)
212b6285d64SSoby Mathew	beq	1f
213b6285d64SSoby Mathew	/* SMC32 is not detected. Return error back to caller */
2143bdf0e5dSYatharth Kochar	mov	r0, #SMC_UNK
2153bdf0e5dSYatharth Kochar	str	r0, [r2, #SMC_CTX_GPREG_R0]
2163bdf0e5dSYatharth Kochar	mov	r0, r2
217b6285d64SSoby Mathew	b	sp_min_exit
2183bdf0e5dSYatharth Kochar1:
219b6285d64SSoby Mathew	/* SMC32 is detected */
2203bdf0e5dSYatharth Kochar	mov	r1, #0				/* cookie */
2213bdf0e5dSYatharth Kochar	bl	handle_runtime_svc
2223bdf0e5dSYatharth Kochar
223b6285d64SSoby Mathew	/* `r0` points to `smc_ctx_t` */
2243bdf0e5dSYatharth Kochar	b	sp_min_exit
2257343505dSDimitris Papastamosendfunc sp_min_handle_smc
2263bdf0e5dSYatharth Kochar
227c11ba852SSoby Mathew/*
22871816096SEtienne Carriere * Secure Interrupts handling function for SP_MIN.
22971816096SEtienne Carriere */
2307343505dSDimitris Papastamosfunc sp_min_handle_fiq
23171816096SEtienne Carriere#if !SP_MIN_WITH_SECURE_FIQ
23271816096SEtienne Carriere	b plat_panic_handler
23371816096SEtienne Carriere#else
23471816096SEtienne Carriere	/* FIQ has a +4 offset for lr compared to preferred return address */
23571816096SEtienne Carriere	sub	lr, lr, #4
23671816096SEtienne Carriere	/* On SMC entry, `sp` points to `smc_ctx_t`. Save `lr`. */
23771816096SEtienne Carriere	str	lr, [sp, #SMC_CTX_LR_MON]
23871816096SEtienne Carriere
239085e80ecSAntonio Nino Diaz	smccc_save_gp_mode_regs
24071816096SEtienne Carriere
24170896274SEtienne Carriere	clrex_on_monitor_entry
24271816096SEtienne Carriere
24371816096SEtienne Carriere	/* load run-time stack */
24471816096SEtienne Carriere	mov	r2, sp
24571816096SEtienne Carriere	ldr	sp, [r2, #SMC_CTX_SP_MON]
24671816096SEtienne Carriere
24771816096SEtienne Carriere	/* Switch to Secure Mode */
24871816096SEtienne Carriere	ldr	r0, [r2, #SMC_CTX_SCR]
24971816096SEtienne Carriere	bic	r0, #SCR_NS_BIT
25071816096SEtienne Carriere	stcopr	r0, SCR
25171816096SEtienne Carriere	isb
25271816096SEtienne Carriere
25371816096SEtienne Carriere	push	{r2, r3}
25471816096SEtienne Carriere	bl	sp_min_fiq
25571816096SEtienne Carriere	pop	{r0, r3}
25671816096SEtienne Carriere
25771816096SEtienne Carriere	b	sp_min_exit
25871816096SEtienne Carriere#endif
2597343505dSDimitris Papastamosendfunc sp_min_handle_fiq
26071816096SEtienne Carriere
26171816096SEtienne Carriere/*
262c11ba852SSoby Mathew * The Warm boot entrypoint for SP_MIN.
263c11ba852SSoby Mathew */
264c11ba852SSoby Mathewfunc sp_min_warm_entrypoint
2650531ada5SBence Szépkúti#if ENABLE_RUNTIME_INSTRUMENTATION
2660531ada5SBence Szépkúti	/*
2670531ada5SBence Szépkúti	 * This timestamp update happens with cache off.  The next
2680531ada5SBence Szépkúti	 * timestamp collection will need to do cache maintenance prior
2690531ada5SBence Szépkúti	 * to timestamp update.
2700531ada5SBence Szépkúti	 */
2710531ada5SBence Szépkúti	pmf_calc_timestamp_addr rt_instr_svc, RT_INSTR_EXIT_HW_LOW_PWR
2720531ada5SBence Szépkúti	ldcopr16 r2, r3, CNTPCT_64
2730531ada5SBence Szépkúti	strd	r2, r3, [r0]
2740531ada5SBence Szépkúti#endif
2753bdf0e5dSYatharth Kochar	/*
2763bdf0e5dSYatharth Kochar	 * On the warm boot path, most of the EL3 initialisations performed by
2773bdf0e5dSYatharth Kochar	 * 'el3_entrypoint_common' must be skipped:
2783bdf0e5dSYatharth Kochar	 *
2793bdf0e5dSYatharth Kochar	 *  - Only when the platform bypasses the BL1/BL32 (SP_MIN) entrypoint by
28018f2efd6SDavid Cunado	 *    programming the reset address do we need to initialied the SCTLR.
2813bdf0e5dSYatharth Kochar	 *    In other cases, we assume this has been taken care by the
2823bdf0e5dSYatharth Kochar	 *    entrypoint code.
2833bdf0e5dSYatharth Kochar	 *
2843bdf0e5dSYatharth Kochar	 *  - No need to determine the type of boot, we know it is a warm boot.
2853bdf0e5dSYatharth Kochar	 *
2863bdf0e5dSYatharth Kochar	 *  - Do not try to distinguish between primary and secondary CPUs, this
2873bdf0e5dSYatharth Kochar	 *    notion only exists for a cold boot.
2883bdf0e5dSYatharth Kochar	 *
2893bdf0e5dSYatharth Kochar	 *  - No need to initialise the memory or the C runtime environment,
2903bdf0e5dSYatharth Kochar	 *    it has been done once and for all on the cold boot path.
2913bdf0e5dSYatharth Kochar	 */
2923bdf0e5dSYatharth Kochar	el3_entrypoint_common					\
29318f2efd6SDavid Cunado		_init_sctlr=PROGRAMMABLE_RESET_ADDRESS		\
2943bdf0e5dSYatharth Kochar		_warm_boot_mailbox=0				\
2953bdf0e5dSYatharth Kochar		_secondary_cold_boot=0				\
2963bdf0e5dSYatharth Kochar		_init_memory=0					\
2973bdf0e5dSYatharth Kochar		_init_c_runtime=0				\
2984324a14bSYann Gautier		_exception_vectors=sp_min_vector_table		\
2994324a14bSYann Gautier		_pie_fixup_size=0
300c11ba852SSoby Mathew
30125a93f7cSJeenu Viswambharan	/*
30225a93f7cSJeenu Viswambharan	 * We're about to enable MMU and participate in PSCI state coordination.
30325a93f7cSJeenu Viswambharan	 *
30425a93f7cSJeenu Viswambharan	 * The PSCI implementation invokes platform routines that enable CPUs to
30525a93f7cSJeenu Viswambharan	 * participate in coherency. On a system where CPUs are not
306bcc3c49cSSoby Mathew	 * cache-coherent without appropriate platform specific programming,
307bcc3c49cSSoby Mathew	 * having caches enabled until such time might lead to coherency issues
308bcc3c49cSSoby Mathew	 * (resulting from stale data getting speculatively fetched, among
309bcc3c49cSSoby Mathew	 * others). Therefore we keep data caches disabled even after enabling
310bcc3c49cSSoby Mathew	 * the MMU for such platforms.
31125a93f7cSJeenu Viswambharan	 *
312bcc3c49cSSoby Mathew	 * On systems with hardware-assisted coherency, or on single cluster
313bcc3c49cSSoby Mathew	 * platforms, such platform specific programming is not required to
314bcc3c49cSSoby Mathew	 * enter coherency (as CPUs already are); and there's no reason to have
315bcc3c49cSSoby Mathew	 * caches disabled either.
316c11ba852SSoby Mathew	 */
31764ee263eSJeenu Viswambharan#if HW_ASSISTED_COHERENCY || WARMBOOT_ENABLE_DCACHE_EARLY
31864ee263eSJeenu Viswambharan	mov	r0, #0
31964ee263eSJeenu Viswambharan#else
320c11ba852SSoby Mathew	mov	r0, #DISABLE_DCACHE
32164ee263eSJeenu Viswambharan#endif
322c11ba852SSoby Mathew	bl	bl32_plat_enable_mmu
323c11ba852SSoby Mathew
32471816096SEtienne Carriere#if SP_MIN_WITH_SECURE_FIQ
32571816096SEtienne Carriere	route_fiq_to_sp_min r0
32671816096SEtienne Carriere#endif
32771816096SEtienne Carriere
328c11ba852SSoby Mathew	bl	sp_min_warm_boot
329c11ba852SSoby Mathew	bl	smc_get_next_ctx
330b6285d64SSoby Mathew	/* r0 points to `smc_ctx_t` */
331b6285d64SSoby Mathew	/* The PSCI cpu_context registers have been copied to `smc_ctx_t` */
3320531ada5SBence Szépkúti
3330531ada5SBence Szépkúti#if ENABLE_RUNTIME_INSTRUMENTATION
3340531ada5SBence Szépkúti	/* Save smc_ctx_t */
3350531ada5SBence Szépkúti	mov	r5, r0
3360531ada5SBence Szépkúti
3370531ada5SBence Szépkúti	pmf_calc_timestamp_addr rt_instr_svc, RT_INSTR_EXIT_PSCI
3380531ada5SBence Szépkúti	mov	r4, r0
3390531ada5SBence Szépkúti
3400531ada5SBence Szépkúti	/*
3410531ada5SBence Szépkúti	 * Invalidate before updating timestamp to ensure previous timestamp
3420531ada5SBence Szépkúti	 * updates on the same cache line with caches disabled are properly
3430531ada5SBence Szépkúti	 * seen by the same core. Without the cache invalidate, the core might
3440531ada5SBence Szépkúti	 * write into a stale cache line.
3450531ada5SBence Szépkúti	 */
3460531ada5SBence Szépkúti	mov	r1, #PMF_TS_SIZE
3470531ada5SBence Szépkúti	bl	inv_dcache_range
3480531ada5SBence Szépkúti
3490531ada5SBence Szépkúti	ldcopr16 r0, r1, CNTPCT_64
3500531ada5SBence Szépkúti	strd	r0, r1, [r4]
3510531ada5SBence Szépkúti
3520531ada5SBence Szépkúti	/* Restore smc_ctx_t */
3530531ada5SBence Szépkúti	mov	r0, r5
3540531ada5SBence Szépkúti#endif
3550531ada5SBence Szépkúti
356c11ba852SSoby Mathew	b	sp_min_exit
357c11ba852SSoby Mathewendfunc sp_min_warm_entrypoint
358c11ba852SSoby Mathew
359c11ba852SSoby Mathew/*
360c11ba852SSoby Mathew * The function to restore the registers from SMC context and return
361c11ba852SSoby Mathew * to the mode restored to SPSR.
362c11ba852SSoby Mathew *
363c11ba852SSoby Mathew * Arguments : r0 must point to the SMC context to restore from.
364c11ba852SSoby Mathew */
365c11ba852SSoby Mathewfunc sp_min_exit
366b6285d64SSoby Mathew	monitor_exit
367c11ba852SSoby Mathewendfunc sp_min_exit
368