17c88f3f6SAchin Gupta/* 2*67b6ff9fSAntonio Nino Diaz * Copyright (c) 2013-2019, ARM Limited and Contributors. All rights reserved. 37c88f3f6SAchin Gupta * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 57c88f3f6SAchin Gupta */ 67c88f3f6SAchin Gupta 77c88f3f6SAchin Gupta#include <arch.h> 80a30cf54SAndrew Thoelke#include <asm_macros.S> 909d40e0eSAntonio Nino Diaz#include <bl32/tsp/tsp.h> 1009d40e0eSAntonio Nino Diaz#include <lib/xlat_tables/xlat_tables_defs.h> 1109d40e0eSAntonio Nino Diaz 12da0af78aSDan Handley#include "../tsp_private.h" 137c88f3f6SAchin Gupta 147c88f3f6SAchin Gupta 157c88f3f6SAchin Gupta .globl tsp_entrypoint 16399fb08fSAndrew Thoelke .globl tsp_vector_table 177c88f3f6SAchin Gupta 18239b04faSSoby Mathew 19239b04faSSoby Mathew 207c88f3f6SAchin Gupta /* --------------------------------------------- 217c88f3f6SAchin Gupta * Populate the params in x0-x7 from the pointer 227c88f3f6SAchin Gupta * to the smc args structure in x0. 237c88f3f6SAchin Gupta * --------------------------------------------- 247c88f3f6SAchin Gupta */ 257c88f3f6SAchin Gupta .macro restore_args_call_smc 267c88f3f6SAchin Gupta ldp x6, x7, [x0, #TSP_ARG6] 277c88f3f6SAchin Gupta ldp x4, x5, [x0, #TSP_ARG4] 287c88f3f6SAchin Gupta ldp x2, x3, [x0, #TSP_ARG2] 297c88f3f6SAchin Gupta ldp x0, x1, [x0, #TSP_ARG0] 307c88f3f6SAchin Gupta smc #0 317c88f3f6SAchin Gupta .endm 327c88f3f6SAchin Gupta 336cf89021SAchin Gupta .macro save_eret_context reg1 reg2 346cf89021SAchin Gupta mrs \reg1, elr_el1 356cf89021SAchin Gupta mrs \reg2, spsr_el1 366cf89021SAchin Gupta stp \reg1, \reg2, [sp, #-0x10]! 376cf89021SAchin Gupta stp x30, x18, [sp, #-0x10]! 386cf89021SAchin Gupta .endm 396cf89021SAchin Gupta 406cf89021SAchin Gupta .macro restore_eret_context reg1 reg2 416cf89021SAchin Gupta ldp x30, x18, [sp], #0x10 426cf89021SAchin Gupta ldp \reg1, \reg2, [sp], #0x10 436cf89021SAchin Gupta msr elr_el1, \reg1 446cf89021SAchin Gupta msr spsr_el1, \reg2 456cf89021SAchin Gupta .endm 466cf89021SAchin Gupta 4764726e6dSJulius Wernerfunc tsp_entrypoint _align=3 487c88f3f6SAchin Gupta 497c88f3f6SAchin Gupta /* --------------------------------------------- 507c88f3f6SAchin Gupta * Set the exception vector to something sane. 517c88f3f6SAchin Gupta * --------------------------------------------- 527c88f3f6SAchin Gupta */ 5357356e90SAchin Gupta adr x0, tsp_exceptions 547c88f3f6SAchin Gupta msr vbar_el1, x0 550c8d4fefSAchin Gupta isb 560c8d4fefSAchin Gupta 570c8d4fefSAchin Gupta /* --------------------------------------------- 580c8d4fefSAchin Gupta * Enable the SError interrupt now that the 590c8d4fefSAchin Gupta * exception vectors have been setup. 600c8d4fefSAchin Gupta * --------------------------------------------- 610c8d4fefSAchin Gupta */ 620c8d4fefSAchin Gupta msr daifclr, #DAIF_ABT_BIT 637c88f3f6SAchin Gupta 647c88f3f6SAchin Gupta /* --------------------------------------------- 65ec3c1003SAchin Gupta * Enable the instruction cache, stack pointer 66ec3c1003SAchin Gupta * and data access alignment checks 677c88f3f6SAchin Gupta * --------------------------------------------- 687c88f3f6SAchin Gupta */ 69ec3c1003SAchin Gupta mov x1, #(SCTLR_I_BIT | SCTLR_A_BIT | SCTLR_SA_BIT) 707c88f3f6SAchin Gupta mrs x0, sctlr_el1 71ec3c1003SAchin Gupta orr x0, x0, x1 727c88f3f6SAchin Gupta msr sctlr_el1, x0 737c88f3f6SAchin Gupta isb 747c88f3f6SAchin Gupta 757c88f3f6SAchin Gupta /* --------------------------------------------- 7654dc71e7SAchin Gupta * Invalidate the RW memory used by the BL32 7754dc71e7SAchin Gupta * image. This includes the data and NOBITS 7854dc71e7SAchin Gupta * sections. This is done to safeguard against 7954dc71e7SAchin Gupta * possible corruption of this memory by dirty 8054dc71e7SAchin Gupta * cache lines in a system cache as a result of 8154dc71e7SAchin Gupta * use by an earlier boot loader stage. 8254dc71e7SAchin Gupta * --------------------------------------------- 8354dc71e7SAchin Gupta */ 8454dc71e7SAchin Gupta adr x0, __RW_START__ 8554dc71e7SAchin Gupta adr x1, __RW_END__ 8654dc71e7SAchin Gupta sub x1, x1, x0 8754dc71e7SAchin Gupta bl inv_dcache_range 8854dc71e7SAchin Gupta 8954dc71e7SAchin Gupta /* --------------------------------------------- 907c88f3f6SAchin Gupta * Zero out NOBITS sections. There are 2 of them: 917c88f3f6SAchin Gupta * - the .bss section; 927c88f3f6SAchin Gupta * - the coherent memory section. 937c88f3f6SAchin Gupta * --------------------------------------------- 947c88f3f6SAchin Gupta */ 957c88f3f6SAchin Gupta ldr x0, =__BSS_START__ 967c88f3f6SAchin Gupta ldr x1, =__BSS_SIZE__ 97308d359bSDouglas Raillard bl zeromem 987c88f3f6SAchin Gupta 99ab8707e6SSoby Mathew#if USE_COHERENT_MEM 1007c88f3f6SAchin Gupta ldr x0, =__COHERENT_RAM_START__ 1017c88f3f6SAchin Gupta ldr x1, =__COHERENT_RAM_UNALIGNED_SIZE__ 102308d359bSDouglas Raillard bl zeromem 103ab8707e6SSoby Mathew#endif 1047c88f3f6SAchin Gupta 1057c88f3f6SAchin Gupta /* -------------------------------------------- 106754a2b7aSAchin Gupta * Allocate a stack whose memory will be marked 107754a2b7aSAchin Gupta * as Normal-IS-WBWA when the MMU is enabled. 108754a2b7aSAchin Gupta * There is no risk of reading stale stack 109754a2b7aSAchin Gupta * memory after enabling the MMU as only the 110754a2b7aSAchin Gupta * primary cpu is running at the moment. 1117c88f3f6SAchin Gupta * -------------------------------------------- 1127c88f3f6SAchin Gupta */ 113fd650ff6SSoby Mathew bl plat_set_my_stack 1147c88f3f6SAchin Gupta 1157c88f3f6SAchin Gupta /* --------------------------------------------- 11651faada7SDouglas Raillard * Initialize the stack protector canary before 11751faada7SDouglas Raillard * any C code is called. 11851faada7SDouglas Raillard * --------------------------------------------- 11951faada7SDouglas Raillard */ 12051faada7SDouglas Raillard#if STACK_PROTECTOR_ENABLED 12151faada7SDouglas Raillard bl update_stack_protector_canary 12251faada7SDouglas Raillard#endif 12351faada7SDouglas Raillard 12451faada7SDouglas Raillard /* --------------------------------------------- 125*67b6ff9fSAntonio Nino Diaz * Perform TSP setup 1267c88f3f6SAchin Gupta * --------------------------------------------- 1277c88f3f6SAchin Gupta */ 128*67b6ff9fSAntonio Nino Diaz bl tsp_setup 129*67b6ff9fSAntonio Nino Diaz 130*67b6ff9fSAntonio Nino Diaz /* --------------------------------------------- 131*67b6ff9fSAntonio Nino Diaz * Enable pointer authentication 132*67b6ff9fSAntonio Nino Diaz * --------------------------------------------- 133*67b6ff9fSAntonio Nino Diaz */ 134*67b6ff9fSAntonio Nino Diaz#if ENABLE_PAUTH 135*67b6ff9fSAntonio Nino Diaz mrs x0, sctlr_el1 136*67b6ff9fSAntonio Nino Diaz orr x0, x0, #SCTLR_EnIA_BIT 137*67b6ff9fSAntonio Nino Diaz msr sctlr_el1, x0 138*67b6ff9fSAntonio Nino Diaz isb 139*67b6ff9fSAntonio Nino Diaz#endif /* ENABLE_PAUTH */ 1407c88f3f6SAchin Gupta 1417c88f3f6SAchin Gupta /* --------------------------------------------- 1427c88f3f6SAchin Gupta * Jump to main function. 1437c88f3f6SAchin Gupta * --------------------------------------------- 1447c88f3f6SAchin Gupta */ 1457c88f3f6SAchin Gupta bl tsp_main 1467c88f3f6SAchin Gupta 1477c88f3f6SAchin Gupta /* --------------------------------------------- 1487c88f3f6SAchin Gupta * Tell TSPD that we are done initialising 1497c88f3f6SAchin Gupta * --------------------------------------------- 1507c88f3f6SAchin Gupta */ 1517c88f3f6SAchin Gupta mov x1, x0 1527c88f3f6SAchin Gupta mov x0, #TSP_ENTRY_DONE 1537c88f3f6SAchin Gupta smc #0 1547c88f3f6SAchin Gupta 1557c88f3f6SAchin Guptatsp_entrypoint_panic: 1567c88f3f6SAchin Gupta b tsp_entrypoint_panic 1578b779620SKévin Petitendfunc tsp_entrypoint 1587c88f3f6SAchin Gupta 159399fb08fSAndrew Thoelke 160399fb08fSAndrew Thoelke /* ------------------------------------------- 161399fb08fSAndrew Thoelke * Table of entrypoint vectors provided to the 162399fb08fSAndrew Thoelke * TSPD for the various entrypoints 163399fb08fSAndrew Thoelke * ------------------------------------------- 164399fb08fSAndrew Thoelke */ 165399fb08fSAndrew Thoelkefunc tsp_vector_table 16616292f54SDavid Cunado b tsp_yield_smc_entry 167399fb08fSAndrew Thoelke b tsp_fast_smc_entry 168399fb08fSAndrew Thoelke b tsp_cpu_on_entry 169399fb08fSAndrew Thoelke b tsp_cpu_off_entry 170399fb08fSAndrew Thoelke b tsp_cpu_resume_entry 171399fb08fSAndrew Thoelke b tsp_cpu_suspend_entry 17202446137SSoby Mathew b tsp_sel1_intr_entry 173d5f13093SJuan Castillo b tsp_system_off_entry 174d5f13093SJuan Castillo b tsp_system_reset_entry 17516292f54SDavid Cunado b tsp_abort_yield_smc_entry 1768b779620SKévin Petitendfunc tsp_vector_table 177399fb08fSAndrew Thoelke 1787c88f3f6SAchin Gupta /*--------------------------------------------- 1797c88f3f6SAchin Gupta * This entrypoint is used by the TSPD when this 1807c88f3f6SAchin Gupta * cpu is to be turned off through a CPU_OFF 1817c88f3f6SAchin Gupta * psci call to ask the TSP to perform any 1827c88f3f6SAchin Gupta * bookeeping necessary. In the current 1837c88f3f6SAchin Gupta * implementation, the TSPD expects the TSP to 1847c88f3f6SAchin Gupta * re-initialise its state so nothing is done 1857c88f3f6SAchin Gupta * here except for acknowledging the request. 1867c88f3f6SAchin Gupta * --------------------------------------------- 1877c88f3f6SAchin Gupta */ 1880a30cf54SAndrew Thoelkefunc tsp_cpu_off_entry 1897c88f3f6SAchin Gupta bl tsp_cpu_off_main 1907c88f3f6SAchin Gupta restore_args_call_smc 1918b779620SKévin Petitendfunc tsp_cpu_off_entry 1927c88f3f6SAchin Gupta 1937c88f3f6SAchin Gupta /*--------------------------------------------- 194d5f13093SJuan Castillo * This entrypoint is used by the TSPD when the 195d5f13093SJuan Castillo * system is about to be switched off (through 196d5f13093SJuan Castillo * a SYSTEM_OFF psci call) to ask the TSP to 197d5f13093SJuan Castillo * perform any necessary bookkeeping. 198d5f13093SJuan Castillo * --------------------------------------------- 199d5f13093SJuan Castillo */ 200d5f13093SJuan Castillofunc tsp_system_off_entry 201d5f13093SJuan Castillo bl tsp_system_off_main 202d5f13093SJuan Castillo restore_args_call_smc 2038b779620SKévin Petitendfunc tsp_system_off_entry 204d5f13093SJuan Castillo 205d5f13093SJuan Castillo /*--------------------------------------------- 206d5f13093SJuan Castillo * This entrypoint is used by the TSPD when the 207d5f13093SJuan Castillo * system is about to be reset (through a 208d5f13093SJuan Castillo * SYSTEM_RESET psci call) to ask the TSP to 209d5f13093SJuan Castillo * perform any necessary bookkeeping. 210d5f13093SJuan Castillo * --------------------------------------------- 211d5f13093SJuan Castillo */ 212d5f13093SJuan Castillofunc tsp_system_reset_entry 213d5f13093SJuan Castillo bl tsp_system_reset_main 214d5f13093SJuan Castillo restore_args_call_smc 2158b779620SKévin Petitendfunc tsp_system_reset_entry 216d5f13093SJuan Castillo 217d5f13093SJuan Castillo /*--------------------------------------------- 2187c88f3f6SAchin Gupta * This entrypoint is used by the TSPD when this 2197c88f3f6SAchin Gupta * cpu is turned on using a CPU_ON psci call to 2207c88f3f6SAchin Gupta * ask the TSP to initialise itself i.e. setup 2217c88f3f6SAchin Gupta * the mmu, stacks etc. Minimal architectural 2227c88f3f6SAchin Gupta * state will be initialised by the TSPD when 2237c88f3f6SAchin Gupta * this function is entered i.e. Caches and MMU 2247c88f3f6SAchin Gupta * will be turned off, the execution state 2257c88f3f6SAchin Gupta * will be aarch64 and exceptions masked. 2267c88f3f6SAchin Gupta * --------------------------------------------- 2277c88f3f6SAchin Gupta */ 2280a30cf54SAndrew Thoelkefunc tsp_cpu_on_entry 2297c88f3f6SAchin Gupta /* --------------------------------------------- 2307c88f3f6SAchin Gupta * Set the exception vector to something sane. 2317c88f3f6SAchin Gupta * --------------------------------------------- 2327c88f3f6SAchin Gupta */ 23357356e90SAchin Gupta adr x0, tsp_exceptions 2347c88f3f6SAchin Gupta msr vbar_el1, x0 2350c8d4fefSAchin Gupta isb 2360c8d4fefSAchin Gupta 2370c8d4fefSAchin Gupta /* Enable the SError interrupt */ 2380c8d4fefSAchin Gupta msr daifclr, #DAIF_ABT_BIT 2397c88f3f6SAchin Gupta 2407c88f3f6SAchin Gupta /* --------------------------------------------- 241ec3c1003SAchin Gupta * Enable the instruction cache, stack pointer 242ec3c1003SAchin Gupta * and data access alignment checks 2437c88f3f6SAchin Gupta * --------------------------------------------- 2447c88f3f6SAchin Gupta */ 245ec3c1003SAchin Gupta mov x1, #(SCTLR_I_BIT | SCTLR_A_BIT | SCTLR_SA_BIT) 2467c88f3f6SAchin Gupta mrs x0, sctlr_el1 247ec3c1003SAchin Gupta orr x0, x0, x1 2487c88f3f6SAchin Gupta msr sctlr_el1, x0 2497c88f3f6SAchin Gupta isb 2507c88f3f6SAchin Gupta 2517c88f3f6SAchin Gupta /* -------------------------------------------- 252b51da821SAchin Gupta * Give ourselves a stack whose memory will be 253b51da821SAchin Gupta * marked as Normal-IS-WBWA when the MMU is 254b51da821SAchin Gupta * enabled. 2557c88f3f6SAchin Gupta * -------------------------------------------- 2567c88f3f6SAchin Gupta */ 257fd650ff6SSoby Mathew bl plat_set_my_stack 2587c88f3f6SAchin Gupta 259b51da821SAchin Gupta /* -------------------------------------------- 260bb00ea5bSJeenu Viswambharan * Enable MMU and D-caches together. 261b51da821SAchin Gupta * -------------------------------------------- 2627c88f3f6SAchin Gupta */ 263bb00ea5bSJeenu Viswambharan mov x0, #0 264dff8e47aSDan Handley bl bl32_plat_enable_mmu 2657c88f3f6SAchin Gupta 2667c88f3f6SAchin Gupta /* --------------------------------------------- 2677c88f3f6SAchin Gupta * Enter C runtime to perform any remaining 2687c88f3f6SAchin Gupta * book keeping 2697c88f3f6SAchin Gupta * --------------------------------------------- 2707c88f3f6SAchin Gupta */ 2717c88f3f6SAchin Gupta bl tsp_cpu_on_main 2727c88f3f6SAchin Gupta restore_args_call_smc 2737c88f3f6SAchin Gupta 2747c88f3f6SAchin Gupta /* Should never reach here */ 2757c88f3f6SAchin Guptatsp_cpu_on_entry_panic: 2767c88f3f6SAchin Gupta b tsp_cpu_on_entry_panic 2778b779620SKévin Petitendfunc tsp_cpu_on_entry 2787c88f3f6SAchin Gupta 2797c88f3f6SAchin Gupta /*--------------------------------------------- 2807c88f3f6SAchin Gupta * This entrypoint is used by the TSPD when this 2817c88f3f6SAchin Gupta * cpu is to be suspended through a CPU_SUSPEND 2827c88f3f6SAchin Gupta * psci call to ask the TSP to perform any 2837c88f3f6SAchin Gupta * bookeeping necessary. In the current 2847c88f3f6SAchin Gupta * implementation, the TSPD saves and restores 2857c88f3f6SAchin Gupta * the EL1 state. 2867c88f3f6SAchin Gupta * --------------------------------------------- 2877c88f3f6SAchin Gupta */ 2880a30cf54SAndrew Thoelkefunc tsp_cpu_suspend_entry 2897c88f3f6SAchin Gupta bl tsp_cpu_suspend_main 2907c88f3f6SAchin Gupta restore_args_call_smc 2918b779620SKévin Petitendfunc tsp_cpu_suspend_entry 2927c88f3f6SAchin Gupta 29302446137SSoby Mathew /*------------------------------------------------- 2946cf89021SAchin Gupta * This entrypoint is used by the TSPD to pass 29563b8440fSSoby Mathew * control for `synchronously` handling a S-EL1 29663b8440fSSoby Mathew * Interrupt which was triggered while executing 29763b8440fSSoby Mathew * in normal world. 'x0' contains a magic number 29863b8440fSSoby Mathew * which indicates this. TSPD expects control to 29963b8440fSSoby Mathew * be handed back at the end of interrupt 30063b8440fSSoby Mathew * processing. This is done through an SMC. 30163b8440fSSoby Mathew * The handover agreement is: 3026cf89021SAchin Gupta * 3036cf89021SAchin Gupta * 1. PSTATE.DAIF are set upon entry. 'x1' has 3046cf89021SAchin Gupta * the ELR_EL3 from the non-secure state. 3056cf89021SAchin Gupta * 2. TSP has to preserve the callee saved 3066cf89021SAchin Gupta * general purpose registers, SP_EL1/EL0 and 3076cf89021SAchin Gupta * LR. 3086cf89021SAchin Gupta * 3. TSP has to preserve the system and vfp 3096cf89021SAchin Gupta * registers (if applicable). 3106cf89021SAchin Gupta * 4. TSP can use 'x0-x18' to enable its C 3116cf89021SAchin Gupta * runtime. 3126cf89021SAchin Gupta * 5. TSP returns to TSPD using an SMC with 31302446137SSoby Mathew * 'x0' = TSP_HANDLED_S_EL1_INTR 31402446137SSoby Mathew * ------------------------------------------------ 3156cf89021SAchin Gupta */ 31602446137SSoby Mathewfunc tsp_sel1_intr_entry 3176cf89021SAchin Gupta#if DEBUG 31863b8440fSSoby Mathew mov_imm x2, TSP_HANDLE_SEL1_INTR_AND_RETURN 3196cf89021SAchin Gupta cmp x0, x2 32002446137SSoby Mathew b.ne tsp_sel1_int_entry_panic 3216cf89021SAchin Gupta#endif 32202446137SSoby Mathew /*------------------------------------------------- 3236cf89021SAchin Gupta * Save any previous context needed to perform 3246cf89021SAchin Gupta * an exception return from S-EL1 e.g. context 32502446137SSoby Mathew * from a previous Non secure Interrupt. 32602446137SSoby Mathew * Update statistics and handle the S-EL1 32702446137SSoby Mathew * interrupt before returning to the TSPD. 3286cf89021SAchin Gupta * IRQ/FIQs are not enabled since that will 3296cf89021SAchin Gupta * complicate the implementation. Execution 3306cf89021SAchin Gupta * will be transferred back to the normal world 33163b8440fSSoby Mathew * in any case. The handler can return 0 33263b8440fSSoby Mathew * if the interrupt was handled or TSP_PREEMPTED 33363b8440fSSoby Mathew * if the expected interrupt was preempted 33463b8440fSSoby Mathew * by an interrupt that should be handled in EL3 33563b8440fSSoby Mathew * e.g. Group 0 interrupt in GICv3. In both 33663b8440fSSoby Mathew * the cases switch to EL3 using SMC with id 33763b8440fSSoby Mathew * TSP_HANDLED_S_EL1_INTR. Any other return value 33863b8440fSSoby Mathew * from the handler will result in panic. 33902446137SSoby Mathew * ------------------------------------------------ 3406cf89021SAchin Gupta */ 3416cf89021SAchin Gupta save_eret_context x2 x3 34202446137SSoby Mathew bl tsp_update_sync_sel1_intr_stats 34302446137SSoby Mathew bl tsp_common_int_handler 34463b8440fSSoby Mathew /* Check if the S-EL1 interrupt has been handled */ 34563b8440fSSoby Mathew cbnz x0, tsp_sel1_intr_check_preemption 34663b8440fSSoby Mathew b tsp_sel1_intr_return 34763b8440fSSoby Mathewtsp_sel1_intr_check_preemption: 34863b8440fSSoby Mathew /* Check if the S-EL1 interrupt has been preempted */ 34963b8440fSSoby Mathew mov_imm x1, TSP_PREEMPTED 35063b8440fSSoby Mathew cmp x0, x1 35163b8440fSSoby Mathew b.ne tsp_sel1_int_entry_panic 35263b8440fSSoby Mathewtsp_sel1_intr_return: 35363b8440fSSoby Mathew mov_imm x0, TSP_HANDLED_S_EL1_INTR 3546cf89021SAchin Gupta restore_eret_context x2 x3 3556cf89021SAchin Gupta smc #0 3566cf89021SAchin Gupta 35763b8440fSSoby Mathew /* Should never reach here */ 35802446137SSoby Mathewtsp_sel1_int_entry_panic: 359a806dad5SJeenu Viswambharan no_ret plat_panic_handler 36002446137SSoby Mathewendfunc tsp_sel1_intr_entry 3616cf89021SAchin Gupta 3626cf89021SAchin Gupta /*--------------------------------------------- 3637c88f3f6SAchin Gupta * This entrypoint is used by the TSPD when this 3647c88f3f6SAchin Gupta * cpu resumes execution after an earlier 3657c88f3f6SAchin Gupta * CPU_SUSPEND psci call to ask the TSP to 3667c88f3f6SAchin Gupta * restore its saved context. In the current 3677c88f3f6SAchin Gupta * implementation, the TSPD saves and restores 3687c88f3f6SAchin Gupta * EL1 state so nothing is done here apart from 3697c88f3f6SAchin Gupta * acknowledging the request. 3707c88f3f6SAchin Gupta * --------------------------------------------- 3717c88f3f6SAchin Gupta */ 3720a30cf54SAndrew Thoelkefunc tsp_cpu_resume_entry 3737c88f3f6SAchin Gupta bl tsp_cpu_resume_main 3747c88f3f6SAchin Gupta restore_args_call_smc 3751c3ea103SAntonio Nino Diaz 3761c3ea103SAntonio Nino Diaz /* Should never reach here */ 377a806dad5SJeenu Viswambharan no_ret plat_panic_handler 3788b779620SKévin Petitendfunc tsp_cpu_resume_entry 3797c88f3f6SAchin Gupta 3807c88f3f6SAchin Gupta /*--------------------------------------------- 3817c88f3f6SAchin Gupta * This entrypoint is used by the TSPD to ask 3827c88f3f6SAchin Gupta * the TSP to service a fast smc request. 3837c88f3f6SAchin Gupta * --------------------------------------------- 3847c88f3f6SAchin Gupta */ 3850a30cf54SAndrew Thoelkefunc tsp_fast_smc_entry 386239b04faSSoby Mathew bl tsp_smc_handler 3877c88f3f6SAchin Gupta restore_args_call_smc 3881c3ea103SAntonio Nino Diaz 3891c3ea103SAntonio Nino Diaz /* Should never reach here */ 390a806dad5SJeenu Viswambharan no_ret plat_panic_handler 3918b779620SKévin Petitendfunc tsp_fast_smc_entry 3927c88f3f6SAchin Gupta 393239b04faSSoby Mathew /*--------------------------------------------- 394239b04faSSoby Mathew * This entrypoint is used by the TSPD to ask 39516292f54SDavid Cunado * the TSP to service a Yielding SMC request. 396239b04faSSoby Mathew * We will enable preemption during execution 397239b04faSSoby Mathew * of tsp_smc_handler. 398239b04faSSoby Mathew * --------------------------------------------- 399239b04faSSoby Mathew */ 40016292f54SDavid Cunadofunc tsp_yield_smc_entry 401239b04faSSoby Mathew msr daifclr, #DAIF_FIQ_BIT | DAIF_IRQ_BIT 402239b04faSSoby Mathew bl tsp_smc_handler 403239b04faSSoby Mathew msr daifset, #DAIF_FIQ_BIT | DAIF_IRQ_BIT 404239b04faSSoby Mathew restore_args_call_smc 4051c3ea103SAntonio Nino Diaz 4061c3ea103SAntonio Nino Diaz /* Should never reach here */ 407a806dad5SJeenu Viswambharan no_ret plat_panic_handler 40816292f54SDavid Cunadoendfunc tsp_yield_smc_entry 4093df6012aSDouglas Raillard 4103df6012aSDouglas Raillard /*--------------------------------------------------------------------- 41116292f54SDavid Cunado * This entrypoint is used by the TSPD to abort a pre-empted Yielding 4123df6012aSDouglas Raillard * SMC. It could be on behalf of non-secure world or because a CPU 4133df6012aSDouglas Raillard * suspend/CPU off request needs to abort the preempted SMC. 4143df6012aSDouglas Raillard * -------------------------------------------------------------------- 4153df6012aSDouglas Raillard */ 41616292f54SDavid Cunadofunc tsp_abort_yield_smc_entry 4173df6012aSDouglas Raillard 4183df6012aSDouglas Raillard /* 4193df6012aSDouglas Raillard * Exceptions masking is already done by the TSPD when entering this 4203df6012aSDouglas Raillard * hook so there is no need to do it here. 4213df6012aSDouglas Raillard */ 4223df6012aSDouglas Raillard 4233df6012aSDouglas Raillard /* Reset the stack used by the pre-empted SMC */ 4243df6012aSDouglas Raillard bl plat_set_my_stack 4253df6012aSDouglas Raillard 4263df6012aSDouglas Raillard /* 4273df6012aSDouglas Raillard * Allow some cleanup such as releasing locks. 4283df6012aSDouglas Raillard */ 4293df6012aSDouglas Raillard bl tsp_abort_smc_handler 4303df6012aSDouglas Raillard 4313df6012aSDouglas Raillard restore_args_call_smc 4323df6012aSDouglas Raillard 4333df6012aSDouglas Raillard /* Should never reach here */ 4343df6012aSDouglas Raillard bl plat_panic_handler 43516292f54SDavid Cunadoendfunc tsp_abort_yield_smc_entry 436