blob: 7b6169297f1e5a711f0757a5bc00167ea73ad38f [file] [log] [blame]
Soby Mathewa43d4312014-04-07 15:28:55 +01001/*
Igor Podgainõi58fadd62024-11-15 15:20:50 +01002 * Copyright (c) 2014-2025, Arm Limited and Contributors. All rights reserved.
Soby Mathewa43d4312014-04-07 15:28:55 +01003 *
dp-arm82cb2c12017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Soby Mathewa43d4312014-04-07 15:28:55 +01005 */
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +00006
7#include <plat_macros.S>
8#include <platform_def.h>
9
Soby Mathewa43d4312014-04-07 15:28:55 +010010#include <arch.h>
11#include <asm_macros.S>
12#include <context.h>
Antonio Nino Diaz09d40e02018-12-14 00:18:21 +000013#include <lib/el3_runtime/cpu_data.h>
14#include <lib/utils_def.h>
Soby Mathewa43d4312014-04-07 15:28:55 +010015
Soby Mathew626ed512014-06-25 10:07:40 +010016 .globl report_unhandled_exception
17 .globl report_unhandled_interrupt
Govindraj Rajaf300ef62023-01-16 16:44:45 +000018 .globl report_el3_panic
Govindraj Raja7e619ec2023-01-16 15:11:47 +000019 .globl report_elx_panic
Soby Mathewa43d4312014-04-07 15:28:55 +010020
Andrew Thoelke9c22b322014-06-03 11:50:53 +010021#if CRASH_REPORTING
Soby Mathew626ed512014-06-25 10:07:40 +010022
Soby Mathewa43d4312014-04-07 15:28:55 +010023 /* ------------------------------------------------------
24 * The below section deals with dumping the system state
25 * when an unhandled exception is taken in EL3.
26 * The layout and the names of the registers which will
27 * be dumped during a unhandled exception is given below.
28 * ------------------------------------------------------
29 */
Soby Mathew626ed512014-06-25 10:07:40 +010030.section .rodata.crash_prints, "aS"
31print_spacer:
Alexei Fedorov6c6a4702019-07-29 13:34:07 +010032 .asciz " = 0x"
Soby Mathewa43d4312014-04-07 15:28:55 +010033
Soby Mathew626ed512014-06-25 10:07:40 +010034gp_regs:
35 .asciz "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7",\
36 "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15",\
37 "x16", "x17", "x18", "x19", "x20", "x21", "x22",\
38 "x23", "x24", "x25", "x26", "x27", "x28", "x29", ""
39el3_sys_regs:
40 .asciz "scr_el3", "sctlr_el3", "cptr_el3", "tcr_el3",\
41 "daif", "mair_el3", "spsr_el3", "elr_el3", "ttbr0_el3",\
42 "esr_el3", "far_el3", ""
Soby Mathewa43d4312014-04-07 15:28:55 +010043
Igor Podgainõi58fadd62024-11-15 15:20:50 +010044non_el3_sys_regs_1:
Soby Mathew626ed512014-06-25 10:07:40 +010045 .asciz "spsr_el1", "elr_el1", "spsr_abt", "spsr_und",\
46 "spsr_irq", "spsr_fiq", "sctlr_el1", "actlr_el1", "cpacr_el1",\
Igor Podgainõi58fadd62024-11-15 15:20:50 +010047 "csselr_el1", "sp_el1", "esr_el1", ""
48
49ttbr_regs:
50 .asciz "ttbr0_el1", "ttbr0_el2", "ttbr1_el1", "vttbr_el2", ""
51
52non_el3_sys_regs_2:
53 .asciz "mair_el1", "amair_el1", "tcr_el1", "tpidr_el1",\
54 "tpidr_el0", "tpidrro_el0", ""
55
56par_reg:
57 .asciz "par_el1", ""
58
59non_el3_sys_regs_3:
60 .asciz "mpidr_el1", "afsr0_el1", "afsr1_el1", "contextidr_el1",\
61 "vbar_el1", "cntp_ctl_el0", "cntp_cval_el0", "cntv_ctl_el0",\
62 "cntv_cval_el0", "cntkctl_el1", "sp_el0", "isr_el1", ""
Imre Kisc424b912019-07-22 11:56:45 +020063
64#if CTX_INCLUDE_AARCH32_REGS
65aarch32_regs:
66 .asciz "dacr32_el2", "ifsr32_el2", ""
67#endif /* CTX_INCLUDE_AARCH32_REGS */
Soby Mathewa43d4312014-04-07 15:28:55 +010068
Soby Mathew626ed512014-06-25 10:07:40 +010069panic_msg:
Alexei Fedorov6c6a4702019-07-29 13:34:07 +010070 .asciz "PANIC in EL3.\nx30"
Soby Mathew626ed512014-06-25 10:07:40 +010071excpt_msg:
Alexei Fedorov6c6a4702019-07-29 13:34:07 +010072 .asciz "Unhandled Exception in EL3.\nx30"
Soby Mathew626ed512014-06-25 10:07:40 +010073intr_excpt_msg:
Alexei Fedorovb4292bc2020-03-03 13:31:58 +000074 .ascii "Unhandled Interrupt Exception in EL3.\n"
75x30_msg:
76 .asciz "x30"
77excpt_msg_el:
Govindraj Raja7e619ec2023-01-16 15:11:47 +000078 .asciz "Unhandled Exception from lower EL.\n"
Soby Mathewa43d4312014-04-07 15:28:55 +010079
Soby Mathew626ed512014-06-25 10:07:40 +010080 /*
Soby Mathew626ed512014-06-25 10:07:40 +010081 * Helper function to print from crash buf.
82 * The print loop is controlled by the buf size and
83 * ascii reg name list which is passed in x6. The
84 * function returns the crash buf address in x0.
Igor Podgainõi58fadd62024-11-15 15:20:50 +010085 * Clobbers : x0 - x7, x20, sp
Soby Mathew626ed512014-06-25 10:07:40 +010086 */
Igor Podgainõi58fadd62024-11-15 15:20:50 +010087func size_controlled_print_helper
88#if ENABLE_FEAT_D128
89size_controlled_print_128:
90 /* Set flag to print 128-bit registers */
91 mov x20, #1
92 b 1f
93
94size_controlled_print:
95 /* Set flag to print 64-bit registers */
96 mov x20, #0
971:
98#else
99size_controlled_print:
100#endif
Soby Mathew626ed512014-06-25 10:07:40 +0100101 /* Save the lr */
102 mov sp, x30
103 /* load the crash buf address */
104 mrs x7, tpidr_el3
105test_size_list:
106 /* Calculate x5 always as it will be clobbered by asm_print_hex */
107 mrs x5, tpidr_el3
108 add x5, x5, #CPU_DATA_CRASH_BUF_SIZE
109 /* Test whether we have reached end of crash buf */
110 cmp x7, x5
111 b.eq exit_size_print
112 ldrb w4, [x6]
113 /* Test whether we are at end of list */
114 cbz w4, exit_size_print
115 mov x4, x6
116 /* asm_print_str updates x4 to point to next entry in list */
117 bl asm_print_str
Alexei Fedorov6c6a4702019-07-29 13:34:07 +0100118 /* x0 = number of symbols printed + 1 */
119 sub x0, x4, x6
Soby Mathew626ed512014-06-25 10:07:40 +0100120 /* update x6 with the updated list pointer */
121 mov x6, x4
Alexei Fedorov6c6a4702019-07-29 13:34:07 +0100122 bl print_alignment
Igor Podgainõi58fadd62024-11-15 15:20:50 +0100123 /* Print the high 64 bits (or whole 64-bit register) */
Julius Werner155a1002017-12-12 14:23:26 -0800124 ldr x4, [x7], #REGSZ
Soby Mathew626ed512014-06-25 10:07:40 +0100125 bl asm_print_hex
Igor Podgainõi58fadd62024-11-15 15:20:50 +0100126#if ENABLE_FEAT_D128
127 cbz x20, 2f
128 /* Print the low 64 bits in case of a 128-bit register */
129 ldr x4, [x7], #REGSZ
130 bl asm_print_hex
1312:
132#endif
Justin Chadwell53d7e002019-08-20 10:58:49 +0100133 bl asm_print_newline
Soby Mathew626ed512014-06-25 10:07:40 +0100134 b test_size_list
135exit_size_print:
136 mov x30, sp
137 ret
Igor Podgainõi58fadd62024-11-15 15:20:50 +0100138endfunc size_controlled_print_helper
Soby Mathew626ed512014-06-25 10:07:40 +0100139
Alexei Fedorov6c6a4702019-07-29 13:34:07 +0100140 /* -----------------------------------------------------
141 * This function calculates and prints required number
142 * of space characters followed by "= 0x", based on the
143 * length of ascii register name.
144 * x0: length of ascii register name + 1
145 * ------------------------------------------------------
146 */
147func print_alignment
148 /* The minimum ascii length is 3, e.g. for "x0" */
149 adr x4, print_spacer - 3
150 add x4, x4, x0
151 b asm_print_str
152endfunc print_alignment
153
Soby Mathew626ed512014-06-25 10:07:40 +0100154 /*
155 * Helper function to store x8 - x15 registers to
156 * the crash buf. The system registers values are
157 * copied to x8 to x15 by the caller which are then
158 * copied to the crash buf by this function.
159 * x0 points to the crash buf. It then calls
160 * size_controlled_print to print to console.
Igor Podgainõi58fadd62024-11-15 15:20:50 +0100161 * Clobbers : x0 - x7, x20, sp
Soby Mathew626ed512014-06-25 10:07:40 +0100162 */
163func str_in_crash_buf_print
164 /* restore the crash buf address in x0 */
165 mrs x0, tpidr_el3
166 stp x8, x9, [x0]
Julius Werner155a1002017-12-12 14:23:26 -0800167 stp x10, x11, [x0, #REGSZ * 2]
168 stp x12, x13, [x0, #REGSZ * 4]
169 stp x14, x15, [x0, #REGSZ * 6]
Soby Mathew626ed512014-06-25 10:07:40 +0100170 b size_controlled_print
Kévin Petit8b779622015-03-24 14:03:57 +0000171endfunc str_in_crash_buf_print
Soby Mathew626ed512014-06-25 10:07:40 +0100172
Igor Podgainõi58fadd62024-11-15 15:20:50 +0100173 /*
174 * An equivalent helper function for storing x8 - x15
175 * registers in a different order inside the crash buf.
176 * In the end the function size_controlled_print_128 is
177 * called to print the registers to the console.
178 * Clobbers : x0 - x7, x20, sp
179 */
180func str_in_crash_buf_print_128
181 /* restore the crash buf address in x0 */
182 mrs x0, tpidr_el3
183 stp x8, x9, [x0]
184 stp x10, x11, [x0, #REGSZ * 2]
185 stp x12, x13, [x0, #REGSZ * 4]
186 stp x14, x15, [x0, #REGSZ * 6]
187 b size_controlled_print_128
188endfunc str_in_crash_buf_print_128
189
Soby Mathew626ed512014-06-25 10:07:40 +0100190 /* ------------------------------------------------------
191 * This macro calculates the offset to crash buf from
192 * cpu_data and stores it in tpidr_el3. It also saves x0
193 * and x1 in the crash buf by using sp as a temporary
194 * register.
195 * ------------------------------------------------------
196 */
197 .macro prepare_crash_buf_save_x0_x1
198 /* we can corrupt this reg to free up x0 */
199 mov sp, x0
200 /* tpidr_el3 contains the address to cpu_data structure */
201 mrs x0, tpidr_el3
202 /* Calculate the Crash buffer offset in cpu_data */
203 add x0, x0, #CPU_DATA_CRASH_BUF_OFFSET
204 /* Store crash buffer address in tpidr_el3 */
205 msr tpidr_el3, x0
Julius Werner155a1002017-12-12 14:23:26 -0800206 str x1, [x0, #REGSZ]
Soby Mathew626ed512014-06-25 10:07:40 +0100207 mov x1, sp
208 str x1, [x0]
209 .endm
Soby Mathewa43d4312014-04-07 15:28:55 +0100210
211 /* -----------------------------------------------------
Soby Mathew626ed512014-06-25 10:07:40 +0100212 * This function allows to report a crash (if crash
213 * reporting is enabled) when an unhandled exception
214 * occurs. It prints the CPU state via the crash console
215 * making use of the crash buf. This function will
216 * not return.
Soby Mathewa43d4312014-04-07 15:28:55 +0100217 * -----------------------------------------------------
218 */
Soby Mathew626ed512014-06-25 10:07:40 +0100219func report_unhandled_exception
220 prepare_crash_buf_save_x0_x1
221 adr x0, excpt_msg
222 mov sp, x0
223 /* This call will not return */
224 b do_crash_reporting
Kévin Petit8b779622015-03-24 14:03:57 +0000225endfunc report_unhandled_exception
Soby Mathewa43d4312014-04-07 15:28:55 +0100226
Soby Mathew626ed512014-06-25 10:07:40 +0100227 /* -----------------------------------------------------
228 * This function allows to report a crash (if crash
229 * reporting is enabled) when an unhandled interrupt
230 * occurs. It prints the CPU state via the crash console
231 * making use of the crash buf. This function will
232 * not return.
233 * -----------------------------------------------------
234 */
235func report_unhandled_interrupt
236 prepare_crash_buf_save_x0_x1
237 adr x0, intr_excpt_msg
238 mov sp, x0
239 /* This call will not return */
240 b do_crash_reporting
Kévin Petit8b779622015-03-24 14:03:57 +0000241endfunc report_unhandled_interrupt
Soby Mathewa43d4312014-04-07 15:28:55 +0100242
Soby Mathew626ed512014-06-25 10:07:40 +0100243 /* -----------------------------------------------------
Alexei Fedorovb4292bc2020-03-03 13:31:58 +0000244 * This function allows to report a crash from the lower
245 * exception level (if crash reporting is enabled) when
Govindraj Raja7e619ec2023-01-16 15:11:47 +0000246 * lower_el_panic() is invoked from C Runtime.
Alexei Fedorovb4292bc2020-03-03 13:31:58 +0000247 * It prints the CPU state via the crash console making
248 * use of 'cpu_context' structure where general purpose
249 * registers are saved and the crash buf.
250 * This function will not return.
Alexei Fedorovb4292bc2020-03-03 13:31:58 +0000251 * -----------------------------------------------------
252 */
Govindraj Raja7e619ec2023-01-16 15:11:47 +0000253func report_elx_panic
Alexei Fedorovb4292bc2020-03-03 13:31:58 +0000254 msr spsel, #MODE_SP_ELX
Alexei Fedorovb4292bc2020-03-03 13:31:58 +0000255
256 /* Print the crash message */
257 adr x4, excpt_msg_el
258 bl asm_print_str
259
Alexei Fedorovb4292bc2020-03-03 13:31:58 +0000260 /* Report x0 - x29 values stored in 'gpregs_ctx' structure */
261 /* Store the ascii list pointer in x6 */
262 adr x6, gp_regs
263 add x7, sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X0
264
265print_next:
266 ldrb w4, [x6]
267 /* Test whether we are at end of list */
268 cbz w4, print_x30
269 mov x4, x6
270 /* asm_print_str updates x4 to point to next entry in list */
271 bl asm_print_str
272 /* x0 = number of symbols printed + 1 */
273 sub x0, x4, x6
274 /* Update x6 with the updated list pointer */
275 mov x6, x4
276 bl print_alignment
277 ldr x4, [x7], #REGSZ
278 bl asm_print_hex
279 bl asm_print_newline
280 b print_next
281
282print_x30:
283 adr x4, x30_msg
284 bl asm_print_str
285
286 /* Print spaces to align "x30" string */
287 mov x0, #4
288 bl print_alignment
289
290 /* Report x30 */
291 ldr x4, [x7]
292
293 /* ----------------------------------------------------------------
294 * Different virtual address space size can be defined for each EL.
295 * Ensure that we use the proper one by reading the corresponding
296 * TCR_ELx register.
297 * ----------------------------------------------------------------
298 */
299 cmp x8, #MODE_EL2
300 b.lt from_el1 /* EL1 */
301 mrs x2, sctlr_el2
302 mrs x1, tcr_el2
303
304 /* ----------------------------------------------------------------
305 * Check if pointer authentication is enabled at the specified EL.
306 * If it isn't, we can then skip stripping a PAC code.
307 * ----------------------------------------------------------------
308 */
309test_pauth:
310 tst x2, #(SCTLR_EnIA_BIT | SCTLR_EnIB_BIT)
311 b.eq no_pauth
312
313 /* Demangle address */
314 and x1, x1, #0x3F /* T0SZ = TCR_ELx[5:0] */
315 sub x1, x1, #64
316 neg x1, x1 /* bottom_pac_bit = 64 - T0SZ */
317 mov x2, #-1
318 lsl x2, x2, x1
319 bic x4, x4, x2
320
321no_pauth:
322 bl asm_print_hex
323 bl asm_print_newline
324
325 /* tpidr_el3 contains the address to cpu_data structure */
326 mrs x0, tpidr_el3
327 /* Calculate the Crash buffer offset in cpu_data */
328 add x0, x0, #CPU_DATA_CRASH_BUF_OFFSET
329 /* Store crash buffer address in tpidr_el3 */
330 msr tpidr_el3, x0
331
332 /* Print the rest of crash dump */
333 b print_el3_sys_regs
334
335from_el1:
336 mrs x2, sctlr_el1
337 mrs x1, tcr_el1
338 b test_pauth
Govindraj Raja7e619ec2023-01-16 15:11:47 +0000339endfunc report_elx_panic
Alexei Fedorovb4292bc2020-03-03 13:31:58 +0000340
341 /* -----------------------------------------------------
Soby Mathew626ed512014-06-25 10:07:40 +0100342 * This function allows to report a crash (if crash
343 * reporting is enabled) when panic() is invoked from
344 * C Runtime. It prints the CPU state via the crash
345 * console making use of the crash buf. This function
346 * will not return.
347 * -----------------------------------------------------
348 */
Govindraj Rajaf300ef62023-01-16 16:44:45 +0000349func report_el3_panic
Alexei Fedorov6c6a4702019-07-29 13:34:07 +0100350 msr spsel, #MODE_SP_ELX
Soby Mathew626ed512014-06-25 10:07:40 +0100351 prepare_crash_buf_save_x0_x1
352 adr x0, panic_msg
353 mov sp, x0
Alexei Fedorovb4292bc2020-03-03 13:31:58 +0000354 /* Fall through to 'do_crash_reporting' */
Soby Mathewa43d4312014-04-07 15:28:55 +0100355
Soby Mathew626ed512014-06-25 10:07:40 +0100356 /* ------------------------------------------------------------
357 * The common crash reporting functionality. It requires x0
358 * and x1 has already been stored in crash buf, sp points to
359 * crash message and tpidr_el3 contains the crash buf address.
360 * The function does the following:
361 * - Retrieve the crash buffer from tpidr_el3
362 * - Store x2 to x6 in the crash buffer
363 * - Initialise the crash console.
364 * - Print the crash message by using the address in sp.
365 * - Print x30 value to the crash console.
366 * - Print x0 - x7 from the crash buf to the crash console.
367 * - Print x8 - x29 (in groups of 8 registers) using the
368 * crash buf to the crash console.
369 * - Print el3 sys regs (in groups of 8 registers) using the
370 * crash buf to the crash console.
371 * - Print non el3 sys regs (in groups of 8 registers) using
Igor Podgainõi58fadd62024-11-15 15:20:50 +0100372 * the crash buf to the crash console. A group may be
373 * interrupted in case a potential group of 128-bit
374 * sys regs needs to be printed.
Soby Mathew626ed512014-06-25 10:07:40 +0100375 * ------------------------------------------------------------
376 */
Alexei Fedorovb4292bc2020-03-03 13:31:58 +0000377do_crash_reporting:
Soby Mathew626ed512014-06-25 10:07:40 +0100378 /* Retrieve the crash buf from tpidr_el3 */
379 mrs x0, tpidr_el3
380 /* Store x2 - x6, x30 in the crash buffer */
Julius Werner155a1002017-12-12 14:23:26 -0800381 stp x2, x3, [x0, #REGSZ * 2]
382 stp x4, x5, [x0, #REGSZ * 4]
383 stp x6, x30, [x0, #REGSZ * 6]
Soby Mathew626ed512014-06-25 10:07:40 +0100384 /* Initialize the crash console */
385 bl plat_crash_console_init
386 /* Verify the console is initialized */
387 cbz x0, crash_panic
388 /* Print the crash message. sp points to the crash message */
389 mov x4, sp
390 bl asm_print_str
Alexei Fedorov6c6a4702019-07-29 13:34:07 +0100391 /* Print spaces to align "x30" string */
392 mov x0, #4
393 bl print_alignment
Alexei Fedorovb4292bc2020-03-03 13:31:58 +0000394 /* Load the crash buf address */
Soby Mathew626ed512014-06-25 10:07:40 +0100395 mrs x0, tpidr_el3
Alexei Fedorovb4292bc2020-03-03 13:31:58 +0000396 /* Report x30 first from the crash buf */
Julius Werner155a1002017-12-12 14:23:26 -0800397 ldr x4, [x0, #REGSZ * 7]
Alexei Fedorov68c76082020-02-06 17:11:03 +0000398
399#if ENABLE_PAUTH
Boyan Karatotev8d9f5f22025-04-02 11:16:18 +0100400#if ENABLE_PAUTH == 2
401 /* Skip if not present in hardware */
402 is_feat_pauth_present_asm x0, x1
403 beq 1f
404#endif
405 /*
406 * The assembler must see support for xpaci. So turn the compiler
407 * extension on. GCC prior to 10 doesn't understand the PAuth extension
408 * but it does understand armv8.3-a in general. Avoid using 8.3 if
409 * the compiler understands "pauth" so we don't downgrade a higher
410 * -march that was specified on the commandline.
411 */
412#if __GNUC__ < 10
413 .arch armv8.3-a
414#else
415 .arch_extension pauth
416#endif
Alexei Fedorov68c76082020-02-06 17:11:03 +0000417 /* Demangle address */
418 xpaci x4
Boyan Karatotev8d9f5f22025-04-02 11:16:18 +01004191:
Alexei Fedorov68c76082020-02-06 17:11:03 +0000420#endif
Soby Mathew626ed512014-06-25 10:07:40 +0100421 bl asm_print_hex
Justin Chadwell53d7e002019-08-20 10:58:49 +0100422 bl asm_print_newline
Soby Mathew626ed512014-06-25 10:07:40 +0100423 /* Load the crash buf address */
424 mrs x0, tpidr_el3
425 /* Now mov x7 into crash buf */
Julius Werner155a1002017-12-12 14:23:26 -0800426 str x7, [x0, #REGSZ * 7]
Soby Mathewa43d4312014-04-07 15:28:55 +0100427
Alexei Fedorovb4292bc2020-03-03 13:31:58 +0000428 /* Report x0 - x29 values stored in crash buf */
Soby Mathew626ed512014-06-25 10:07:40 +0100429 /* Store the ascii list pointer in x6 */
430 adr x6, gp_regs
431 /* Print x0 to x7 from the crash buf */
432 bl size_controlled_print
433 /* Store x8 - x15 in crash buf and print */
434 bl str_in_crash_buf_print
435 /* Load the crash buf address */
436 mrs x0, tpidr_el3
437 /* Store the rest of gp regs and print */
438 stp x16, x17, [x0]
Julius Werner155a1002017-12-12 14:23:26 -0800439 stp x18, x19, [x0, #REGSZ * 2]
440 stp x20, x21, [x0, #REGSZ * 4]
441 stp x22, x23, [x0, #REGSZ * 6]
Soby Mathew626ed512014-06-25 10:07:40 +0100442 bl size_controlled_print
443 /* Load the crash buf address */
444 mrs x0, tpidr_el3
445 stp x24, x25, [x0]
Julius Werner155a1002017-12-12 14:23:26 -0800446 stp x26, x27, [x0, #REGSZ * 2]
447 stp x28, x29, [x0, #REGSZ * 4]
Soby Mathew626ed512014-06-25 10:07:40 +0100448 bl size_controlled_print
Soby Mathewa43d4312014-04-07 15:28:55 +0100449
Soby Mathew626ed512014-06-25 10:07:40 +0100450 /* Print the el3 sys registers */
Alexei Fedorovb4292bc2020-03-03 13:31:58 +0000451print_el3_sys_regs:
Soby Mathew626ed512014-06-25 10:07:40 +0100452 adr x6, el3_sys_regs
453 mrs x8, scr_el3
454 mrs x9, sctlr_el3
455 mrs x10, cptr_el3
456 mrs x11, tcr_el3
457 mrs x12, daif
458 mrs x13, mair_el3
459 mrs x14, spsr_el3
460 mrs x15, elr_el3
461 bl str_in_crash_buf_print
462 mrs x8, ttbr0_el3
463 mrs x9, esr_el3
464 mrs x10, far_el3
465 bl str_in_crash_buf_print
Soby Mathewa43d4312014-04-07 15:28:55 +0100466
Soby Mathew626ed512014-06-25 10:07:40 +0100467 /* Print the non el3 sys registers */
Igor Podgainõi58fadd62024-11-15 15:20:50 +0100468 adr x6, non_el3_sys_regs_1
Soby Mathew626ed512014-06-25 10:07:40 +0100469 mrs x8, spsr_el1
470 mrs x9, elr_el1
471 mrs x10, spsr_abt
472 mrs x11, spsr_und
473 mrs x12, spsr_irq
474 mrs x13, spsr_fiq
475 mrs x14, sctlr_el1
476 mrs x15, actlr_el1
477 bl str_in_crash_buf_print
478 mrs x8, cpacr_el1
479 mrs x9, csselr_el1
Soby Mathewa43d4312014-04-07 15:28:55 +0100480 mrs x10, sp_el1
481 mrs x11, esr_el1
Soby Mathew626ed512014-06-25 10:07:40 +0100482 bl str_in_crash_buf_print
Igor Podgainõi58fadd62024-11-15 15:20:50 +0100483
484 adr x6, ttbr_regs
485#if ENABLE_FEAT_D128
486 is_feat_sysreg128_present_asm x19
487 /* Fallback to 64-bit if FEAT_SYSREG128 is disabled */
488 cbz x19, ttbr_regs_64_bit
489 bl read_ttbr0_el1
490 mov x8, x1
491 mov x9, x0
492 bl read_ttbr0_el2
493 mov x10, x1
494 mov x11, x0
495 bl read_ttbr1_el1
496 mov x12, x1
497 mov x13, x0
498 bl read_vttbr_el2
499 mov x14, x1
500 mov x15, x0
501 bl str_in_crash_buf_print_128
502 b 1f
503
504ttbr_regs_64_bit:
505#endif
506 mrs x8, ttbr0_el1
507 mrs x9, ttbr0_el2
508 mrs x10, ttbr1_el1
509 mrs x11, vttbr_el2
Soby Mathew626ed512014-06-25 10:07:40 +0100510 bl str_in_crash_buf_print
Igor Podgainõi58fadd62024-11-15 15:20:50 +01005111:
512 adr x6, non_el3_sys_regs_2
513 mrs x8, mair_el1
514 mrs x9, amair_el1
515 mrs x10, tcr_el1
516 mrs x11, tpidr_el1
517 mrs x12, tpidr_el0
518 mrs x13, tpidrro_el0
Soby Mathew626ed512014-06-25 10:07:40 +0100519 bl str_in_crash_buf_print
Igor Podgainõi58fadd62024-11-15 15:20:50 +0100520
521 adr x6, par_reg
522#if ENABLE_FEAT_D128
523 /* Fallback to 64-bit if FEAT_SYSREG128 is disabled */
524 cbz x19, par_reg_64_bit
525 bl read_par_el1
526 mov x8, x1
527 mov x9, x0
528 bl str_in_crash_buf_print_128
529 b 2f
530
531par_reg_64_bit:
532#endif
533 mrs x8, par_el1
534 bl str_in_crash_buf_print
5352:
536 adr x6, non_el3_sys_regs_3
537 mrs x8, mpidr_el1
538 mrs x9, afsr0_el1
539 mrs x10, afsr1_el1
540 mrs x11, contextidr_el1
541 mrs x12, vbar_el1
542 mrs x13, cntp_ctl_el0
543 mrs x14, cntp_cval_el0
544 mrs x15, cntv_ctl_el0
545 bl str_in_crash_buf_print
546 mrs x8, cntv_cval_el0
547 mrs x9, cntkctl_el1
548 mrs x10, sp_el0
549 mrs x11, isr_el1
Soby Mathew626ed512014-06-25 10:07:40 +0100550 bl str_in_crash_buf_print
Soby Mathewa43d4312014-04-07 15:28:55 +0100551
Imre Kisc424b912019-07-22 11:56:45 +0200552#if CTX_INCLUDE_AARCH32_REGS
553 /* Print the AArch32 registers */
554 adr x6, aarch32_regs
555 mrs x8, dacr32_el2
556 mrs x9, ifsr32_el2
557 bl str_in_crash_buf_print
558#endif /* CTX_INCLUDE_AARCH32_REGS */
559
Soby Mathewd3f70af2014-08-14 13:36:41 +0100560 /* Get the cpu specific registers to report */
561 bl do_cpu_reg_dump
562 bl str_in_crash_buf_print
Soby Mathew8c106902014-07-16 09:23:52 +0100563
Gerald Lejeune9ff67fa2015-11-26 15:47:53 +0100564 /* Print some platform registers */
565 plat_crash_print_regs
Soby Mathew8c106902014-07-16 09:23:52 +0100566
Antonio Nino Diaz801cf932017-02-17 17:11:27 +0000567 bl plat_crash_console_flush
568
Soby Mathew626ed512014-06-25 10:07:40 +0100569 /* Done reporting */
Jeenu Viswambharana806dad2016-11-30 15:21:11 +0000570 no_ret plat_panic_handler
Govindraj Rajaf300ef62023-01-16 16:44:45 +0000571endfunc report_el3_panic
Soby Mathewa43d4312014-04-07 15:28:55 +0100572
Soby Mathew626ed512014-06-25 10:07:40 +0100573#else /* CRASH_REPORTING */
574func report_unhandled_exception
575report_unhandled_interrupt:
Jeenu Viswambharana806dad2016-11-30 15:21:11 +0000576 no_ret plat_panic_handler
Kévin Petit8b779622015-03-24 14:03:57 +0000577endfunc report_unhandled_exception
Sandrine Bailleux1645d3e2015-12-17 13:58:58 +0000578#endif /* CRASH_REPORTING */
Andrew Thoelke9c22b322014-06-03 11:50:53 +0100579
Soby Mathew626ed512014-06-25 10:07:40 +0100580func crash_panic
Jeenu Viswambharana806dad2016-11-30 15:21:11 +0000581 no_ret plat_panic_handler
Antonio Nino Diaz1c3ea102016-02-01 13:57:25 +0000582endfunc crash_panic