blob: 9c98ad6a5de1b555b495ca3deb993beb439b3327 [file] [log] [blame]
Achin Gupta4f6ad662013-10-25 09:08:21 +01001/*
Dan Handleye83b0ca2014-01-14 18:17:09 +00002 * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
Achin Gupta4f6ad662013-10-25 09:08:21 +01003 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <arch.h>
Dan Handley714a0d22014-04-09 13:13:04 +010032#include <asm_macros.S>
33#include <cm_macros.S>
Dan Handley2bd4ef22014-04-09 13:14:54 +010034#include <context.h>
35#include <platform.h>
36#include <runtime_svc.h>
Achin Gupta4f6ad662013-10-25 09:08:21 +010037
38 .globl runtime_exceptions
Jeenu Viswambharancaa84932014-02-06 10:36:15 +000039 .globl el3_exit
40 .globl get_exception_stack
Achin Gupta4f6ad662013-10-25 09:08:21 +010041
Soby Mathew6c5192a2014-04-30 15:36:37 +010042 .macro save_x18_to_x29_sp_el0
43 stp x18, x19, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X18]
44 stp x20, x21, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X20]
45 stp x22, x23, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X22]
46 stp x24, x25, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X24]
47 stp x26, x27, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X26]
48 stp x28, x29, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X28]
49 mrs x18, sp_el0
50 str x18, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_SP_EL0]
51 .endm
52
Achin Guptab739f222014-01-18 16:50:09 +000053 .section .vectors, "ax"; .align 11
54
Achin Gupta4f6ad662013-10-25 09:08:21 +010055 .align 7
56runtime_exceptions:
57 /* -----------------------------------------------------
58 * Current EL with _sp_el0 : 0x0 - 0x180
59 * -----------------------------------------------------
60 */
61sync_exception_sp_el0:
Jeenu Viswambharancaa84932014-02-06 10:36:15 +000062 /* -----------------------------------------------------
63 * We don't expect any synchronous exceptions from EL3
64 * -----------------------------------------------------
65 */
66 wfi
67 b sync_exception_sp_el0
Jeenu Viswambharana7934d62014-02-07 15:53:18 +000068 check_vector_size sync_exception_sp_el0
Achin Gupta4f6ad662013-10-25 09:08:21 +010069
70 .align 7
Jeenu Viswambharancaa84932014-02-06 10:36:15 +000071 /* -----------------------------------------------------
72 * EL3 code is non-reentrant. Any asynchronous exception
73 * is a serious error. Loop infinitely.
74 * -----------------------------------------------------
75 */
Achin Gupta4f6ad662013-10-25 09:08:21 +010076irq_sp_el0:
Jeenu Viswambharancaa84932014-02-06 10:36:15 +000077 handle_async_exception IRQ_SP_EL0
78 b irq_sp_el0
Jeenu Viswambharana7934d62014-02-07 15:53:18 +000079 check_vector_size irq_sp_el0
Achin Gupta4f6ad662013-10-25 09:08:21 +010080
81 .align 7
82fiq_sp_el0:
Jeenu Viswambharancaa84932014-02-06 10:36:15 +000083 handle_async_exception FIQ_SP_EL0
84 b fiq_sp_el0
Jeenu Viswambharana7934d62014-02-07 15:53:18 +000085 check_vector_size fiq_sp_el0
Achin Gupta4f6ad662013-10-25 09:08:21 +010086
87 .align 7
88serror_sp_el0:
Jeenu Viswambharancaa84932014-02-06 10:36:15 +000089 handle_async_exception SERROR_SP_EL0
90 b serror_sp_el0
Jeenu Viswambharana7934d62014-02-07 15:53:18 +000091 check_vector_size serror_sp_el0
Achin Gupta4f6ad662013-10-25 09:08:21 +010092
93 /* -----------------------------------------------------
94 * Current EL with SPx: 0x200 - 0x380
95 * -----------------------------------------------------
96 */
97 .align 7
98sync_exception_sp_elx:
Jeenu Viswambharancaa84932014-02-06 10:36:15 +000099 /* -----------------------------------------------------
100 * This exception will trigger if anything went wrong
101 * during a previous exception entry or exit or while
102 * handling an earlier unexpected synchronous exception.
103 * In any case we cannot rely on SP_EL3. Switching to a
104 * known safe area of memory will corrupt at least a
105 * single register. It is best to enter wfi in loop as
106 * that will preserve the system state for analysis
107 * through a debugger later.
108 * -----------------------------------------------------
109 */
110 wfi
111 b sync_exception_sp_elx
Jeenu Viswambharana7934d62014-02-07 15:53:18 +0000112 check_vector_size sync_exception_sp_elx
Achin Gupta4f6ad662013-10-25 09:08:21 +0100113
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000114 /* -----------------------------------------------------
115 * As mentioned in the previous comment, all bets are
116 * off if SP_EL3 cannot be relied upon. Report their
117 * occurrence.
118 * -----------------------------------------------------
119 */
Achin Gupta4f6ad662013-10-25 09:08:21 +0100120 .align 7
121irq_sp_elx:
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000122 b irq_sp_elx
Jeenu Viswambharana7934d62014-02-07 15:53:18 +0000123 check_vector_size irq_sp_elx
124
Achin Gupta4f6ad662013-10-25 09:08:21 +0100125 .align 7
126fiq_sp_elx:
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000127 b fiq_sp_elx
Jeenu Viswambharana7934d62014-02-07 15:53:18 +0000128 check_vector_size fiq_sp_elx
129
Achin Gupta4f6ad662013-10-25 09:08:21 +0100130 .align 7
131serror_sp_elx:
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000132 b serror_sp_elx
Jeenu Viswambharana7934d62014-02-07 15:53:18 +0000133 check_vector_size serror_sp_elx
Achin Gupta4f6ad662013-10-25 09:08:21 +0100134
135 /* -----------------------------------------------------
136 * Lower EL using AArch64 : 0x400 - 0x580
137 * -----------------------------------------------------
138 */
139 .align 7
140sync_exception_aarch64:
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000141 /* -----------------------------------------------------
142 * This exception vector will be the entry point for
143 * SMCs and traps that are unhandled at lower ELs most
144 * commonly. SP_EL3 should point to a valid cpu context
145 * where the general purpose and system register state
146 * can be saved.
147 * -----------------------------------------------------
148 */
149 handle_sync_exception
Jeenu Viswambharana7934d62014-02-07 15:53:18 +0000150 check_vector_size sync_exception_aarch64
Achin Gupta4f6ad662013-10-25 09:08:21 +0100151
152 .align 7
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000153 /* -----------------------------------------------------
154 * Asynchronous exceptions from lower ELs are not
155 * currently supported. Report their occurrence.
156 * -----------------------------------------------------
157 */
Achin Gupta4f6ad662013-10-25 09:08:21 +0100158irq_aarch64:
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000159 handle_async_exception IRQ_AARCH64
160 b irq_aarch64
Jeenu Viswambharana7934d62014-02-07 15:53:18 +0000161 check_vector_size irq_aarch64
Achin Gupta4f6ad662013-10-25 09:08:21 +0100162
163 .align 7
164fiq_aarch64:
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000165 handle_async_exception FIQ_AARCH64
166 b fiq_aarch64
Jeenu Viswambharana7934d62014-02-07 15:53:18 +0000167 check_vector_size fiq_aarch64
Achin Gupta4f6ad662013-10-25 09:08:21 +0100168
169 .align 7
170serror_aarch64:
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000171 handle_async_exception SERROR_AARCH64
172 b serror_aarch64
Jeenu Viswambharana7934d62014-02-07 15:53:18 +0000173 check_vector_size serror_aarch64
Achin Gupta4f6ad662013-10-25 09:08:21 +0100174
175 /* -----------------------------------------------------
176 * Lower EL using AArch32 : 0x600 - 0x780
177 * -----------------------------------------------------
178 */
179 .align 7
180sync_exception_aarch32:
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000181 /* -----------------------------------------------------
182 * This exception vector will be the entry point for
183 * SMCs and traps that are unhandled at lower ELs most
184 * commonly. SP_EL3 should point to a valid cpu context
185 * where the general purpose and system register state
186 * can be saved.
187 * -----------------------------------------------------
188 */
189 handle_sync_exception
Jeenu Viswambharana7934d62014-02-07 15:53:18 +0000190 check_vector_size sync_exception_aarch32
Achin Gupta4f6ad662013-10-25 09:08:21 +0100191
192 .align 7
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000193 /* -----------------------------------------------------
194 * Asynchronous exceptions from lower ELs are not
195 * currently supported. Report their occurrence.
196 * -----------------------------------------------------
197 */
Achin Gupta4f6ad662013-10-25 09:08:21 +0100198irq_aarch32:
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000199 handle_async_exception IRQ_AARCH32
200 b irq_aarch32
Jeenu Viswambharana7934d62014-02-07 15:53:18 +0000201 check_vector_size irq_aarch32
Achin Gupta4f6ad662013-10-25 09:08:21 +0100202
203 .align 7
204fiq_aarch32:
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000205 handle_async_exception FIQ_AARCH32
206 b fiq_aarch32
Jeenu Viswambharana7934d62014-02-07 15:53:18 +0000207 check_vector_size fiq_aarch32
Achin Gupta4f6ad662013-10-25 09:08:21 +0100208
209 .align 7
210serror_aarch32:
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000211 handle_async_exception SERROR_AARCH32
212 b serror_aarch32
Jeenu Viswambharana7934d62014-02-07 15:53:18 +0000213 check_vector_size serror_aarch32
214
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000215 .align 7
216
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000217 /* -----------------------------------------------------
218 * The following code handles secure monitor calls.
219 * Depending upon the execution state from where the SMC
220 * has been invoked, it frees some general purpose
221 * registers to perform the remaining tasks. They
222 * involve finding the runtime service handler that is
223 * the target of the SMC & switching to runtime stacks
224 * (SP_EL0) before calling the handler.
225 *
226 * Note that x30 has been explicitly saved and can be
227 * used here
228 * -----------------------------------------------------
229 */
Andrew Thoelke38bde412014-03-18 13:46:55 +0000230func smc_handler
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000231smc_handler32:
232 /* Check whether aarch32 issued an SMC64 */
233 tbnz x0, #FUNCID_CC_SHIFT, smc_prohibited
234
235 /* -----------------------------------------------------
236 * Since we're are coming from aarch32, x8-x18 need to
237 * be saved as per SMC32 calling convention. If a lower
238 * EL in aarch64 is making an SMC32 call then it must
239 * have saved x8-x17 already therein.
240 * -----------------------------------------------------
241 */
242 stp x8, x9, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X8]
243 stp x10, x11, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X10]
244 stp x12, x13, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X12]
245 stp x14, x15, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X14]
246 stp x16, x17, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X16]
247
248 /* x4-x7, x18, sp_el0 are saved below */
249
250smc_handler64:
251 /* -----------------------------------------------------
252 * Populate the parameters for the SMC handler. We
253 * already have x0-x4 in place. x5 will point to a
254 * cookie (not used now). x6 will point to the context
255 * structure (SP_EL3) and x7 will contain flags we need
256 * to pass to the handler Hence save x5-x7. Note that x4
257 * only needs to be preserved for AArch32 callers but we
258 * do it for AArch64 callers as well for convenience
259 * -----------------------------------------------------
260 */
261 stp x4, x5, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X4]
262 stp x6, x7, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X6]
263
Soby Mathew6c5192a2014-04-30 15:36:37 +0100264 /* Save rest of the gpregs and sp_el0*/
265 save_x18_to_x29_sp_el0
266
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000267 mov x5, xzr
268 mov x6, sp
269
270 /* Get the unique owning entity number */
271 ubfx x16, x0, #FUNCID_OEN_SHIFT, #FUNCID_OEN_WIDTH
272 ubfx x15, x0, #FUNCID_TYPE_SHIFT, #FUNCID_TYPE_WIDTH
273 orr x16, x16, x15, lsl #FUNCID_OEN_WIDTH
274
275 adr x11, (__RT_SVC_DESCS_START__ + RT_SVC_DESC_HANDLE)
276
277 /* Load descriptor index from array of indices */
278 adr x14, rt_svc_descs_indices
279 ldrb w15, [x14, x16]
280
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000281 /* -----------------------------------------------------
282 * Restore the saved C runtime stack value which will
283 * become the new SP_EL0 i.e. EL3 runtime stack. It was
284 * saved in the 'cpu_context' structure prior to the last
285 * ERET from EL3.
286 * -----------------------------------------------------
287 */
288 ldr x12, [x6, #CTX_EL3STATE_OFFSET + CTX_RUNTIME_SP]
289
290 /*
291 * Any index greater than 127 is invalid. Check bit 7 for
292 * a valid index
293 */
294 tbnz w15, 7, smc_unknown
295
296 /* Switch to SP_EL0 */
297 msr spsel, #0
298
299 /* -----------------------------------------------------
300 * Get the descriptor using the index
301 * x11 = (base + off), x15 = index
302 *
303 * handler = (base + off) + (index << log2(size))
304 * -----------------------------------------------------
305 */
306 lsl w10, w15, #RT_SVC_SIZE_LOG2
307 ldr x15, [x11, w10, uxtw]
308
309 /* -----------------------------------------------------
310 * Save the SPSR_EL3, ELR_EL3, & SCR_EL3 in case there
311 * is a world switch during SMC handling.
312 * TODO: Revisit if all system registers can be saved
313 * later.
314 * -----------------------------------------------------
315 */
316 mrs x16, spsr_el3
317 mrs x17, elr_el3
318 mrs x18, scr_el3
319 stp x16, x17, [x6, #CTX_EL3STATE_OFFSET + CTX_SPSR_EL3]
320 stp x18, xzr, [x6, #CTX_EL3STATE_OFFSET + CTX_SCR_EL3]
321
322 /* Copy SCR_EL3.NS bit to the flag to indicate caller's security */
323 bfi x7, x18, #0, #1
324
325 mov sp, x12
326
327 /* -----------------------------------------------------
328 * Call the Secure Monitor Call handler and then drop
329 * directly into el3_exit() which will program any
330 * remaining architectural state prior to issuing the
331 * ERET to the desired lower EL.
332 * -----------------------------------------------------
333 */
334#if DEBUG
335 cbz x15, rt_svc_fw_critical_error
336#endif
337 blr x15
338
339 /* -----------------------------------------------------
340 * This routine assumes that the SP_EL3 is pointing to
341 * a valid context structure from where the gp regs and
342 * other special registers can be retrieved.
Andrew Thoelke38bde412014-03-18 13:46:55 +0000343 *
344 * Keep it in the same section as smc_handler as this
345 * function uses a fall-through to el3_exit
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000346 * -----------------------------------------------------
347 */
348el3_exit: ; .type el3_exit, %function
349 /* -----------------------------------------------------
350 * Save the current SP_EL0 i.e. the EL3 runtime stack
351 * which will be used for handling the next SMC. Then
352 * switch to SP_EL3
353 * -----------------------------------------------------
354 */
355 mov x17, sp
356 msr spsel, #1
357 str x17, [sp, #CTX_EL3STATE_OFFSET + CTX_RUNTIME_SP]
358
359 /* -----------------------------------------------------
360 * Restore SPSR_EL3, ELR_EL3 and SCR_EL3 prior to ERET
361 * -----------------------------------------------------
362 */
363 ldp x18, xzr, [sp, #CTX_EL3STATE_OFFSET + CTX_SCR_EL3]
364 ldp x16, x17, [sp, #CTX_EL3STATE_OFFSET + CTX_SPSR_EL3]
365 msr scr_el3, x18
366 msr spsr_el3, x16
367 msr elr_el3, x17
368
369 /* Restore saved general purpose registers and return */
Soby Mathew6c5192a2014-04-30 15:36:37 +0100370 bl restore_gp_registers
371 ldr x30, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_LR]
Achin Gupta4f6ad662013-10-25 09:08:21 +0100372 eret
373
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000374smc_unknown:
375 /*
376 * Here we restore x4-x18 regardless of where we came from. AArch32
377 * callers will find the registers contents unchanged, but AArch64
378 * callers will find the registers modified (with stale earlier NS
379 * content). Either way, we aren't leaking any secure information
380 * through them
381 */
Soby Mathew6c5192a2014-04-30 15:36:37 +0100382 bl restore_gp_registers_callee
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000383
384smc_prohibited:
Soby Mathew6c5192a2014-04-30 15:36:37 +0100385 ldr x30, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_LR]
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000386 mov w0, #SMC_UNK
387 eret
388
389rt_svc_fw_critical_error:
390 b rt_svc_fw_critical_error
391
392 /* -----------------------------------------------------
393 * The following functions are used to saved and restore
Soby Mathew6c5192a2014-04-30 15:36:37 +0100394 * all the general pupose registers. Ideally we would
395 * only save and restore the callee saved registers when
396 * a world switch occurs but that type of implementation
397 * is more complex. So currently we will always save and
398 * restore these registers on entry and exit of EL3.
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000399 * These are not macros to ensure their invocation fits
400 * within the 32 instructions per exception vector.
401 * -----------------------------------------------------
402 */
Soby Mathew6c5192a2014-04-30 15:36:37 +0100403func save_gp_registers
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000404 stp x0, x1, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X0]
405 stp x2, x3, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X2]
406 stp x4, x5, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X4]
407 stp x6, x7, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X6]
408 stp x8, x9, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X8]
409 stp x10, x11, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X10]
410 stp x12, x13, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X12]
411 stp x14, x15, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X14]
412 stp x16, x17, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X16]
Soby Mathew6c5192a2014-04-30 15:36:37 +0100413 save_x18_to_x29_sp_el0
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000414 ret
415
Soby Mathew6c5192a2014-04-30 15:36:37 +0100416func restore_gp_registers
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000417 ldp x0, x1, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X0]
418 ldp x2, x3, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X2]
419
Soby Mathew6c5192a2014-04-30 15:36:37 +0100420restore_gp_registers_callee:
421 ldr x17, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_SP_EL0]
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000422
423 ldp x4, x5, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X4]
424 ldp x6, x7, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X6]
425 ldp x8, x9, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X8]
426 ldp x10, x11, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X10]
427 ldp x12, x13, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X12]
428 ldp x14, x15, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X14]
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000429 msr sp_el0, x17
430 ldp x16, x17, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X16]
Soby Mathew6c5192a2014-04-30 15:36:37 +0100431 ldp x18, x19, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X18]
432 ldp x20, x21, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X20]
433 ldp x22, x23, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X22]
434 ldp x24, x25, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X24]
435 ldp x26, x27, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X26]
436 ldp x28, x29, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X28]
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000437 ret
438
439 /* -----------------------------------------------------
440 * 256 bytes of exception stack for each cpu
441 * -----------------------------------------------------
442 */
443#if DEBUG
444#define PCPU_EXCEPTION_STACK_SIZE 0x300
445#else
446#define PCPU_EXCEPTION_STACK_SIZE 0x100
447#endif
448 /* -----------------------------------------------------
449 * void get_exception_stack (uint64_t mpidr) : This
450 * function is used to allocate a small stack for
451 * reporting unhandled exceptions
452 * -----------------------------------------------------
453 */
Andrew Thoelke38bde412014-03-18 13:46:55 +0000454func get_exception_stack
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000455 mov x10, x30 // lr
Andrew Thoelke65668f92014-03-20 10:48:23 +0000456 get_mp_stack pcpu_exception_stack, PCPU_EXCEPTION_STACK_SIZE
Jeenu Viswambharancaa84932014-02-06 10:36:15 +0000457 ret x10
458
459 /* -----------------------------------------------------
460 * Per-cpu exception stacks in normal memory.
461 * -----------------------------------------------------
462 */
Andrew Thoelke65668f92014-03-20 10:48:23 +0000463declare_stack pcpu_exception_stack, tzfw_normal_stacks, \
464 PCPU_EXCEPTION_STACK_SIZE, PLATFORM_CORE_COUNT