Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 1 | /* |
Alexei Fedorov | b8f26e9 | 2020-02-06 17:11:03 +0000 | [diff] [blame] | 2 | * Copyright (c) 2014-2020, ARM Limited and Contributors. All rights reserved. |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 5 | */ |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 6 | |
| 7 | #include <plat_macros.S> |
| 8 | #include <platform_def.h> |
| 9 | |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 10 | #include <arch.h> |
| 11 | #include <asm_macros.S> |
| 12 | #include <context.h> |
Antonio Nino Diaz | e0f9063 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 13 | #include <lib/el3_runtime/cpu_data.h> |
| 14 | #include <lib/utils_def.h> |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 15 | |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 16 | .globl report_unhandled_exception |
| 17 | .globl report_unhandled_interrupt |
| 18 | .globl el3_panic |
Alexei Fedorov | 813c9f9 | 2020-03-03 13:31:58 +0000 | [diff] [blame] | 19 | .globl elx_panic |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 20 | |
Andrew Thoelke | 385f4d4 | 2014-06-03 11:50:53 +0100 | [diff] [blame] | 21 | #if CRASH_REPORTING |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 22 | |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 23 | /* ------------------------------------------------------ |
| 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 Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 30 | .section .rodata.crash_prints, "aS" |
| 31 | print_spacer: |
Alexei Fedorov | c4dfb3b | 2019-07-29 13:34:07 +0100 | [diff] [blame] | 32 | .asciz " = 0x" |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 33 | |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 34 | gp_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", "" |
| 39 | el3_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 Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 43 | |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 44 | non_el3_sys_regs: |
| 45 | .asciz "spsr_el1", "elr_el1", "spsr_abt", "spsr_und",\ |
| 46 | "spsr_irq", "spsr_fiq", "sctlr_el1", "actlr_el1", "cpacr_el1",\ |
| 47 | "csselr_el1", "sp_el1", "esr_el1", "ttbr0_el1", "ttbr1_el1",\ |
| 48 | "mair_el1", "amair_el1", "tcr_el1", "tpidr_el1", "tpidr_el0",\ |
Imre Kis | b5b903c | 2019-07-22 11:56:45 +0200 | [diff] [blame] | 49 | "tpidrro_el0", "par_el1", "mpidr_el1", "afsr0_el1", "afsr1_el1",\ |
| 50 | "contextidr_el1", "vbar_el1", "cntp_ctl_el0", "cntp_cval_el0",\ |
| 51 | "cntv_ctl_el0", "cntv_cval_el0", "cntkctl_el1", "sp_el0", "isr_el1", "" |
| 52 | |
| 53 | #if CTX_INCLUDE_AARCH32_REGS |
| 54 | aarch32_regs: |
| 55 | .asciz "dacr32_el2", "ifsr32_el2", "" |
| 56 | #endif /* CTX_INCLUDE_AARCH32_REGS */ |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 57 | |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 58 | panic_msg: |
Alexei Fedorov | c4dfb3b | 2019-07-29 13:34:07 +0100 | [diff] [blame] | 59 | .asciz "PANIC in EL3.\nx30" |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 60 | excpt_msg: |
Alexei Fedorov | c4dfb3b | 2019-07-29 13:34:07 +0100 | [diff] [blame] | 61 | .asciz "Unhandled Exception in EL3.\nx30" |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 62 | intr_excpt_msg: |
Alexei Fedorov | 813c9f9 | 2020-03-03 13:31:58 +0000 | [diff] [blame] | 63 | .ascii "Unhandled Interrupt Exception in EL3.\n" |
| 64 | x30_msg: |
| 65 | .asciz "x30" |
| 66 | excpt_msg_el: |
| 67 | .asciz "Unhandled Exception from EL" |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 68 | |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 69 | /* |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 70 | * Helper function to print from crash buf. |
| 71 | * The print loop is controlled by the buf size and |
| 72 | * ascii reg name list which is passed in x6. The |
| 73 | * function returns the crash buf address in x0. |
| 74 | * Clobbers : x0 - x7, sp |
| 75 | */ |
| 76 | func size_controlled_print |
| 77 | /* Save the lr */ |
| 78 | mov sp, x30 |
| 79 | /* load the crash buf address */ |
| 80 | mrs x7, tpidr_el3 |
| 81 | test_size_list: |
| 82 | /* Calculate x5 always as it will be clobbered by asm_print_hex */ |
| 83 | mrs x5, tpidr_el3 |
| 84 | add x5, x5, #CPU_DATA_CRASH_BUF_SIZE |
| 85 | /* Test whether we have reached end of crash buf */ |
| 86 | cmp x7, x5 |
| 87 | b.eq exit_size_print |
| 88 | ldrb w4, [x6] |
| 89 | /* Test whether we are at end of list */ |
| 90 | cbz w4, exit_size_print |
| 91 | mov x4, x6 |
| 92 | /* asm_print_str updates x4 to point to next entry in list */ |
| 93 | bl asm_print_str |
Alexei Fedorov | c4dfb3b | 2019-07-29 13:34:07 +0100 | [diff] [blame] | 94 | /* x0 = number of symbols printed + 1 */ |
| 95 | sub x0, x4, x6 |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 96 | /* update x6 with the updated list pointer */ |
| 97 | mov x6, x4 |
Alexei Fedorov | c4dfb3b | 2019-07-29 13:34:07 +0100 | [diff] [blame] | 98 | bl print_alignment |
Julius Werner | 02eb727 | 2017-12-12 14:23:26 -0800 | [diff] [blame] | 99 | ldr x4, [x7], #REGSZ |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 100 | bl asm_print_hex |
Justin Chadwell | 7690382 | 2019-08-20 10:58:49 +0100 | [diff] [blame] | 101 | bl asm_print_newline |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 102 | b test_size_list |
| 103 | exit_size_print: |
| 104 | mov x30, sp |
| 105 | ret |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 106 | endfunc size_controlled_print |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 107 | |
Alexei Fedorov | c4dfb3b | 2019-07-29 13:34:07 +0100 | [diff] [blame] | 108 | /* ----------------------------------------------------- |
| 109 | * This function calculates and prints required number |
| 110 | * of space characters followed by "= 0x", based on the |
| 111 | * length of ascii register name. |
| 112 | * x0: length of ascii register name + 1 |
| 113 | * ------------------------------------------------------ |
| 114 | */ |
| 115 | func print_alignment |
| 116 | /* The minimum ascii length is 3, e.g. for "x0" */ |
| 117 | adr x4, print_spacer - 3 |
| 118 | add x4, x4, x0 |
| 119 | b asm_print_str |
| 120 | endfunc print_alignment |
| 121 | |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 122 | /* |
| 123 | * Helper function to store x8 - x15 registers to |
| 124 | * the crash buf. The system registers values are |
| 125 | * copied to x8 to x15 by the caller which are then |
| 126 | * copied to the crash buf by this function. |
| 127 | * x0 points to the crash buf. It then calls |
| 128 | * size_controlled_print to print to console. |
| 129 | * Clobbers : x0 - x7, sp |
| 130 | */ |
| 131 | func str_in_crash_buf_print |
| 132 | /* restore the crash buf address in x0 */ |
| 133 | mrs x0, tpidr_el3 |
| 134 | stp x8, x9, [x0] |
Julius Werner | 02eb727 | 2017-12-12 14:23:26 -0800 | [diff] [blame] | 135 | stp x10, x11, [x0, #REGSZ * 2] |
| 136 | stp x12, x13, [x0, #REGSZ * 4] |
| 137 | stp x14, x15, [x0, #REGSZ * 6] |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 138 | b size_controlled_print |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 139 | endfunc str_in_crash_buf_print |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 140 | |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 141 | /* ------------------------------------------------------ |
| 142 | * This macro calculates the offset to crash buf from |
| 143 | * cpu_data and stores it in tpidr_el3. It also saves x0 |
| 144 | * and x1 in the crash buf by using sp as a temporary |
| 145 | * register. |
| 146 | * ------------------------------------------------------ |
| 147 | */ |
| 148 | .macro prepare_crash_buf_save_x0_x1 |
| 149 | /* we can corrupt this reg to free up x0 */ |
| 150 | mov sp, x0 |
| 151 | /* tpidr_el3 contains the address to cpu_data structure */ |
| 152 | mrs x0, tpidr_el3 |
| 153 | /* Calculate the Crash buffer offset in cpu_data */ |
| 154 | add x0, x0, #CPU_DATA_CRASH_BUF_OFFSET |
| 155 | /* Store crash buffer address in tpidr_el3 */ |
| 156 | msr tpidr_el3, x0 |
Julius Werner | 02eb727 | 2017-12-12 14:23:26 -0800 | [diff] [blame] | 157 | str x1, [x0, #REGSZ] |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 158 | mov x1, sp |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 159 | str x1, [x0] |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 160 | .endm |
| 161 | |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 162 | /* ----------------------------------------------------- |
| 163 | * This function allows to report a crash (if crash |
| 164 | * reporting is enabled) when an unhandled exception |
| 165 | * occurs. It prints the CPU state via the crash console |
| 166 | * making use of the crash buf. This function will |
| 167 | * not return. |
| 168 | * ----------------------------------------------------- |
| 169 | */ |
| 170 | func report_unhandled_exception |
| 171 | prepare_crash_buf_save_x0_x1 |
| 172 | adr x0, excpt_msg |
| 173 | mov sp, x0 |
| 174 | /* This call will not return */ |
| 175 | b do_crash_reporting |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 176 | endfunc report_unhandled_exception |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 177 | |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 178 | /* ----------------------------------------------------- |
| 179 | * This function allows to report a crash (if crash |
| 180 | * reporting is enabled) when an unhandled interrupt |
| 181 | * occurs. It prints the CPU state via the crash console |
| 182 | * making use of the crash buf. This function will |
| 183 | * not return. |
| 184 | * ----------------------------------------------------- |
| 185 | */ |
| 186 | func report_unhandled_interrupt |
| 187 | prepare_crash_buf_save_x0_x1 |
| 188 | adr x0, intr_excpt_msg |
| 189 | mov sp, x0 |
| 190 | /* This call will not return */ |
| 191 | b do_crash_reporting |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 192 | endfunc report_unhandled_interrupt |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 193 | |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 194 | /* ----------------------------------------------------- |
Alexei Fedorov | 813c9f9 | 2020-03-03 13:31:58 +0000 | [diff] [blame] | 195 | * This function allows to report a crash from the lower |
| 196 | * exception level (if crash reporting is enabled) when |
| 197 | * panic() is invoked from C Runtime. |
| 198 | * It prints the CPU state via the crash console making |
| 199 | * use of 'cpu_context' structure where general purpose |
| 200 | * registers are saved and the crash buf. |
| 201 | * This function will not return. |
| 202 | * |
| 203 | * x0: Exception level |
| 204 | * ----------------------------------------------------- |
| 205 | */ |
| 206 | func elx_panic |
| 207 | msr spsel, #MODE_SP_ELX |
| 208 | mov x8, x0 |
| 209 | |
| 210 | /* Print the crash message */ |
| 211 | adr x4, excpt_msg_el |
| 212 | bl asm_print_str |
| 213 | |
| 214 | /* Print exception level */ |
| 215 | add x0, x8, #'0' |
| 216 | bl plat_crash_console_putc |
| 217 | bl asm_print_newline |
| 218 | |
| 219 | /* Report x0 - x29 values stored in 'gpregs_ctx' structure */ |
| 220 | /* Store the ascii list pointer in x6 */ |
| 221 | adr x6, gp_regs |
| 222 | add x7, sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X0 |
| 223 | |
| 224 | print_next: |
| 225 | ldrb w4, [x6] |
| 226 | /* Test whether we are at end of list */ |
| 227 | cbz w4, print_x30 |
| 228 | mov x4, x6 |
| 229 | /* asm_print_str updates x4 to point to next entry in list */ |
| 230 | bl asm_print_str |
| 231 | /* x0 = number of symbols printed + 1 */ |
| 232 | sub x0, x4, x6 |
| 233 | /* Update x6 with the updated list pointer */ |
| 234 | mov x6, x4 |
| 235 | bl print_alignment |
| 236 | ldr x4, [x7], #REGSZ |
| 237 | bl asm_print_hex |
| 238 | bl asm_print_newline |
| 239 | b print_next |
| 240 | |
| 241 | print_x30: |
| 242 | adr x4, x30_msg |
| 243 | bl asm_print_str |
| 244 | |
| 245 | /* Print spaces to align "x30" string */ |
| 246 | mov x0, #4 |
| 247 | bl print_alignment |
| 248 | |
| 249 | /* Report x30 */ |
| 250 | ldr x4, [x7] |
| 251 | |
| 252 | /* ---------------------------------------------------------------- |
| 253 | * Different virtual address space size can be defined for each EL. |
| 254 | * Ensure that we use the proper one by reading the corresponding |
| 255 | * TCR_ELx register. |
| 256 | * ---------------------------------------------------------------- |
| 257 | */ |
| 258 | cmp x8, #MODE_EL2 |
| 259 | b.lt from_el1 /* EL1 */ |
| 260 | mrs x2, sctlr_el2 |
| 261 | mrs x1, tcr_el2 |
| 262 | |
| 263 | /* ---------------------------------------------------------------- |
| 264 | * Check if pointer authentication is enabled at the specified EL. |
| 265 | * If it isn't, we can then skip stripping a PAC code. |
| 266 | * ---------------------------------------------------------------- |
| 267 | */ |
| 268 | test_pauth: |
| 269 | tst x2, #(SCTLR_EnIA_BIT | SCTLR_EnIB_BIT) |
| 270 | b.eq no_pauth |
| 271 | |
| 272 | /* Demangle address */ |
| 273 | and x1, x1, #0x3F /* T0SZ = TCR_ELx[5:0] */ |
| 274 | sub x1, x1, #64 |
| 275 | neg x1, x1 /* bottom_pac_bit = 64 - T0SZ */ |
| 276 | mov x2, #-1 |
| 277 | lsl x2, x2, x1 |
| 278 | bic x4, x4, x2 |
| 279 | |
| 280 | no_pauth: |
| 281 | bl asm_print_hex |
| 282 | bl asm_print_newline |
| 283 | |
| 284 | /* tpidr_el3 contains the address to cpu_data structure */ |
| 285 | mrs x0, tpidr_el3 |
| 286 | /* Calculate the Crash buffer offset in cpu_data */ |
| 287 | add x0, x0, #CPU_DATA_CRASH_BUF_OFFSET |
| 288 | /* Store crash buffer address in tpidr_el3 */ |
| 289 | msr tpidr_el3, x0 |
| 290 | |
| 291 | /* Print the rest of crash dump */ |
| 292 | b print_el3_sys_regs |
| 293 | |
| 294 | from_el1: |
| 295 | mrs x2, sctlr_el1 |
| 296 | mrs x1, tcr_el1 |
| 297 | b test_pauth |
| 298 | endfunc elx_panic |
| 299 | |
| 300 | /* ----------------------------------------------------- |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 301 | * This function allows to report a crash (if crash |
| 302 | * reporting is enabled) when panic() is invoked from |
| 303 | * C Runtime. It prints the CPU state via the crash |
| 304 | * console making use of the crash buf. This function |
| 305 | * will not return. |
| 306 | * ----------------------------------------------------- |
| 307 | */ |
| 308 | func el3_panic |
Alexei Fedorov | c4dfb3b | 2019-07-29 13:34:07 +0100 | [diff] [blame] | 309 | msr spsel, #MODE_SP_ELX |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 310 | prepare_crash_buf_save_x0_x1 |
| 311 | adr x0, panic_msg |
| 312 | mov sp, x0 |
Alexei Fedorov | 813c9f9 | 2020-03-03 13:31:58 +0000 | [diff] [blame] | 313 | /* Fall through to 'do_crash_reporting' */ |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 314 | |
| 315 | /* ------------------------------------------------------------ |
| 316 | * The common crash reporting functionality. It requires x0 |
| 317 | * and x1 has already been stored in crash buf, sp points to |
| 318 | * crash message and tpidr_el3 contains the crash buf address. |
| 319 | * The function does the following: |
| 320 | * - Retrieve the crash buffer from tpidr_el3 |
| 321 | * - Store x2 to x6 in the crash buffer |
| 322 | * - Initialise the crash console. |
| 323 | * - Print the crash message by using the address in sp. |
| 324 | * - Print x30 value to the crash console. |
| 325 | * - Print x0 - x7 from the crash buf to the crash console. |
| 326 | * - Print x8 - x29 (in groups of 8 registers) using the |
| 327 | * crash buf to the crash console. |
| 328 | * - Print el3 sys regs (in groups of 8 registers) using the |
| 329 | * crash buf to the crash console. |
| 330 | * - Print non el3 sys regs (in groups of 8 registers) using |
| 331 | * the crash buf to the crash console. |
| 332 | * ------------------------------------------------------------ |
| 333 | */ |
Alexei Fedorov | 813c9f9 | 2020-03-03 13:31:58 +0000 | [diff] [blame] | 334 | do_crash_reporting: |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 335 | /* Retrieve the crash buf from tpidr_el3 */ |
| 336 | mrs x0, tpidr_el3 |
| 337 | /* Store x2 - x6, x30 in the crash buffer */ |
Julius Werner | 02eb727 | 2017-12-12 14:23:26 -0800 | [diff] [blame] | 338 | stp x2, x3, [x0, #REGSZ * 2] |
| 339 | stp x4, x5, [x0, #REGSZ * 4] |
| 340 | stp x6, x30, [x0, #REGSZ * 6] |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 341 | /* Initialize the crash console */ |
| 342 | bl plat_crash_console_init |
| 343 | /* Verify the console is initialized */ |
| 344 | cbz x0, crash_panic |
| 345 | /* Print the crash message. sp points to the crash message */ |
| 346 | mov x4, sp |
| 347 | bl asm_print_str |
Alexei Fedorov | c4dfb3b | 2019-07-29 13:34:07 +0100 | [diff] [blame] | 348 | /* Print spaces to align "x30" string */ |
| 349 | mov x0, #4 |
| 350 | bl print_alignment |
Alexei Fedorov | 813c9f9 | 2020-03-03 13:31:58 +0000 | [diff] [blame] | 351 | /* Load the crash buf address */ |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 352 | mrs x0, tpidr_el3 |
Alexei Fedorov | 813c9f9 | 2020-03-03 13:31:58 +0000 | [diff] [blame] | 353 | /* Report x30 first from the crash buf */ |
Julius Werner | 02eb727 | 2017-12-12 14:23:26 -0800 | [diff] [blame] | 354 | ldr x4, [x0, #REGSZ * 7] |
Alexei Fedorov | b8f26e9 | 2020-02-06 17:11:03 +0000 | [diff] [blame] | 355 | |
| 356 | #if ENABLE_PAUTH |
| 357 | /* Demangle address */ |
| 358 | xpaci x4 |
| 359 | #endif |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 360 | bl asm_print_hex |
Justin Chadwell | 7690382 | 2019-08-20 10:58:49 +0100 | [diff] [blame] | 361 | bl asm_print_newline |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 362 | /* Load the crash buf address */ |
| 363 | mrs x0, tpidr_el3 |
| 364 | /* Now mov x7 into crash buf */ |
Julius Werner | 02eb727 | 2017-12-12 14:23:26 -0800 | [diff] [blame] | 365 | str x7, [x0, #REGSZ * 7] |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 366 | |
Alexei Fedorov | 813c9f9 | 2020-03-03 13:31:58 +0000 | [diff] [blame] | 367 | /* Report x0 - x29 values stored in crash buf */ |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 368 | /* Store the ascii list pointer in x6 */ |
| 369 | adr x6, gp_regs |
| 370 | /* Print x0 to x7 from the crash buf */ |
| 371 | bl size_controlled_print |
| 372 | /* Store x8 - x15 in crash buf and print */ |
| 373 | bl str_in_crash_buf_print |
| 374 | /* Load the crash buf address */ |
| 375 | mrs x0, tpidr_el3 |
| 376 | /* Store the rest of gp regs and print */ |
| 377 | stp x16, x17, [x0] |
Julius Werner | 02eb727 | 2017-12-12 14:23:26 -0800 | [diff] [blame] | 378 | stp x18, x19, [x0, #REGSZ * 2] |
| 379 | stp x20, x21, [x0, #REGSZ * 4] |
| 380 | stp x22, x23, [x0, #REGSZ * 6] |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 381 | bl size_controlled_print |
| 382 | /* Load the crash buf address */ |
| 383 | mrs x0, tpidr_el3 |
| 384 | stp x24, x25, [x0] |
Julius Werner | 02eb727 | 2017-12-12 14:23:26 -0800 | [diff] [blame] | 385 | stp x26, x27, [x0, #REGSZ * 2] |
| 386 | stp x28, x29, [x0, #REGSZ * 4] |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 387 | bl size_controlled_print |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 388 | |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 389 | /* Print the el3 sys registers */ |
Alexei Fedorov | 813c9f9 | 2020-03-03 13:31:58 +0000 | [diff] [blame] | 390 | print_el3_sys_regs: |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 391 | adr x6, el3_sys_regs |
| 392 | mrs x8, scr_el3 |
| 393 | mrs x9, sctlr_el3 |
| 394 | mrs x10, cptr_el3 |
| 395 | mrs x11, tcr_el3 |
| 396 | mrs x12, daif |
| 397 | mrs x13, mair_el3 |
| 398 | mrs x14, spsr_el3 |
| 399 | mrs x15, elr_el3 |
| 400 | bl str_in_crash_buf_print |
| 401 | mrs x8, ttbr0_el3 |
| 402 | mrs x9, esr_el3 |
| 403 | mrs x10, far_el3 |
| 404 | bl str_in_crash_buf_print |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 405 | |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 406 | /* Print the non el3 sys registers */ |
| 407 | adr x6, non_el3_sys_regs |
| 408 | mrs x8, spsr_el1 |
| 409 | mrs x9, elr_el1 |
| 410 | mrs x10, spsr_abt |
| 411 | mrs x11, spsr_und |
| 412 | mrs x12, spsr_irq |
| 413 | mrs x13, spsr_fiq |
| 414 | mrs x14, sctlr_el1 |
| 415 | mrs x15, actlr_el1 |
| 416 | bl str_in_crash_buf_print |
| 417 | mrs x8, cpacr_el1 |
| 418 | mrs x9, csselr_el1 |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 419 | mrs x10, sp_el1 |
| 420 | mrs x11, esr_el1 |
| 421 | mrs x12, ttbr0_el1 |
| 422 | mrs x13, ttbr1_el1 |
| 423 | mrs x14, mair_el1 |
| 424 | mrs x15, amair_el1 |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 425 | bl str_in_crash_buf_print |
| 426 | mrs x8, tcr_el1 |
| 427 | mrs x9, tpidr_el1 |
| 428 | mrs x10, tpidr_el0 |
| 429 | mrs x11, tpidrro_el0 |
Imre Kis | b5b903c | 2019-07-22 11:56:45 +0200 | [diff] [blame] | 430 | mrs x12, par_el1 |
| 431 | mrs x13, mpidr_el1 |
| 432 | mrs x14, afsr0_el1 |
| 433 | mrs x15, afsr1_el1 |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 434 | bl str_in_crash_buf_print |
Imre Kis | b5b903c | 2019-07-22 11:56:45 +0200 | [diff] [blame] | 435 | mrs x8, contextidr_el1 |
| 436 | mrs x9, vbar_el1 |
| 437 | mrs x10, cntp_ctl_el0 |
| 438 | mrs x11, cntp_cval_el0 |
| 439 | mrs x12, cntv_ctl_el0 |
| 440 | mrs x13, cntv_cval_el0 |
| 441 | mrs x14, cntkctl_el1 |
| 442 | mrs x15, sp_el0 |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 443 | bl str_in_crash_buf_print |
Imre Kis | b5b903c | 2019-07-22 11:56:45 +0200 | [diff] [blame] | 444 | mrs x8, isr_el1 |
| 445 | bl str_in_crash_buf_print |
| 446 | |
| 447 | #if CTX_INCLUDE_AARCH32_REGS |
| 448 | /* Print the AArch32 registers */ |
| 449 | adr x6, aarch32_regs |
| 450 | mrs x8, dacr32_el2 |
| 451 | mrs x9, ifsr32_el2 |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 452 | bl str_in_crash_buf_print |
Imre Kis | b5b903c | 2019-07-22 11:56:45 +0200 | [diff] [blame] | 453 | #endif /* CTX_INCLUDE_AARCH32_REGS */ |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 454 | |
Soby Mathew | 38b4bc9 | 2014-08-14 13:36:41 +0100 | [diff] [blame] | 455 | /* Get the cpu specific registers to report */ |
| 456 | bl do_cpu_reg_dump |
| 457 | bl str_in_crash_buf_print |
Soby Mathew | 0da9593 | 2014-07-16 09:23:52 +0100 | [diff] [blame] | 458 | |
Gerald Lejeune | 2c7ed5b | 2015-11-26 15:47:53 +0100 | [diff] [blame] | 459 | /* Print some platform registers */ |
| 460 | plat_crash_print_regs |
Soby Mathew | 0da9593 | 2014-07-16 09:23:52 +0100 | [diff] [blame] | 461 | |
Antonio Nino Diaz | d3ec543 | 2017-02-17 17:11:27 +0000 | [diff] [blame] | 462 | bl plat_crash_console_flush |
| 463 | |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 464 | /* Done reporting */ |
Jeenu Viswambharan | 68aef10 | 2016-11-30 15:21:11 +0000 | [diff] [blame] | 465 | no_ret plat_panic_handler |
Alexei Fedorov | 813c9f9 | 2020-03-03 13:31:58 +0000 | [diff] [blame] | 466 | endfunc el3_panic |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 467 | |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 468 | #else /* CRASH_REPORTING */ |
| 469 | func report_unhandled_exception |
| 470 | report_unhandled_interrupt: |
Jeenu Viswambharan | 68aef10 | 2016-11-30 15:21:11 +0000 | [diff] [blame] | 471 | no_ret plat_panic_handler |
Kévin Petit | a877c25 | 2015-03-24 14:03:57 +0000 | [diff] [blame] | 472 | endfunc report_unhandled_exception |
Sandrine Bailleux | f4119ec | 2015-12-17 13:58:58 +0000 | [diff] [blame] | 473 | #endif /* CRASH_REPORTING */ |
Soby Mathew | 5e5c207 | 2014-04-07 15:28:55 +0100 | [diff] [blame] | 474 | |
Soby Mathew | c1adbbc | 2014-06-25 10:07:40 +0100 | [diff] [blame] | 475 | func crash_panic |
Jeenu Viswambharan | 68aef10 | 2016-11-30 15:21:11 +0000 | [diff] [blame] | 476 | no_ret plat_panic_handler |
Antonio Nino Diaz | 1f21bcf | 2016-02-01 13:57:25 +0000 | [diff] [blame] | 477 | endfunc crash_panic |