1a43d431bSSoby Mathew/* 268c76088SAlexei Fedorov * Copyright (c) 2014-2020, ARM Limited and Contributors. All rights reserved. 3a43d431bSSoby Mathew * 482cb2c1aSdp-arm * SPDX-License-Identifier: BSD-3-Clause 5a43d431bSSoby Mathew */ 609d40e0eSAntonio Nino Diaz 709d40e0eSAntonio Nino Diaz#include <plat_macros.S> 809d40e0eSAntonio Nino Diaz#include <platform_def.h> 909d40e0eSAntonio Nino Diaz 10a43d431bSSoby Mathew#include <arch.h> 11a43d431bSSoby Mathew#include <asm_macros.S> 12a43d431bSSoby Mathew#include <context.h> 1309d40e0eSAntonio Nino Diaz#include <lib/el3_runtime/cpu_data.h> 1409d40e0eSAntonio Nino Diaz#include <lib/utils_def.h> 15a43d431bSSoby Mathew 16626ed510SSoby Mathew .globl report_unhandled_exception 17626ed510SSoby Mathew .globl report_unhandled_interrupt 18626ed510SSoby Mathew .globl el3_panic 19*b4292bc6SAlexei Fedorov .globl elx_panic 20a43d431bSSoby Mathew 219c22b323SAndrew Thoelke#if CRASH_REPORTING 22626ed510SSoby Mathew 23a43d431bSSoby Mathew /* ------------------------------------------------------ 24a43d431bSSoby Mathew * The below section deals with dumping the system state 25a43d431bSSoby Mathew * when an unhandled exception is taken in EL3. 26a43d431bSSoby Mathew * The layout and the names of the registers which will 27a43d431bSSoby Mathew * be dumped during a unhandled exception is given below. 28a43d431bSSoby Mathew * ------------------------------------------------------ 29a43d431bSSoby Mathew */ 30626ed510SSoby Mathew.section .rodata.crash_prints, "aS" 31626ed510SSoby Mathewprint_spacer: 326c6a470fSAlexei Fedorov .asciz " = 0x" 33a43d431bSSoby Mathew 34626ed510SSoby Mathewgp_regs: 35626ed510SSoby Mathew .asciz "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7",\ 36626ed510SSoby Mathew "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15",\ 37626ed510SSoby Mathew "x16", "x17", "x18", "x19", "x20", "x21", "x22",\ 38626ed510SSoby Mathew "x23", "x24", "x25", "x26", "x27", "x28", "x29", "" 39626ed510SSoby Mathewel3_sys_regs: 40626ed510SSoby Mathew .asciz "scr_el3", "sctlr_el3", "cptr_el3", "tcr_el3",\ 41626ed510SSoby Mathew "daif", "mair_el3", "spsr_el3", "elr_el3", "ttbr0_el3",\ 42626ed510SSoby Mathew "esr_el3", "far_el3", "" 43a43d431bSSoby Mathew 44626ed510SSoby Mathewnon_el3_sys_regs: 45626ed510SSoby Mathew .asciz "spsr_el1", "elr_el1", "spsr_abt", "spsr_und",\ 46a43d431bSSoby Mathew "spsr_irq", "spsr_fiq", "sctlr_el1", "actlr_el1", "cpacr_el1",\ 47a43d431bSSoby Mathew "csselr_el1", "sp_el1", "esr_el1", "ttbr0_el1", "ttbr1_el1",\ 48626ed510SSoby Mathew "mair_el1", "amair_el1", "tcr_el1", "tpidr_el1", "tpidr_el0",\ 49c424b91eSImre Kis "tpidrro_el0", "par_el1", "mpidr_el1", "afsr0_el1", "afsr1_el1",\ 50c424b91eSImre Kis "contextidr_el1", "vbar_el1", "cntp_ctl_el0", "cntp_cval_el0",\ 51c424b91eSImre Kis "cntv_ctl_el0", "cntv_cval_el0", "cntkctl_el1", "sp_el0", "isr_el1", "" 52c424b91eSImre Kis 53c424b91eSImre Kis#if CTX_INCLUDE_AARCH32_REGS 54c424b91eSImre Kisaarch32_regs: 55c424b91eSImre Kis .asciz "dacr32_el2", "ifsr32_el2", "" 56c424b91eSImre Kis#endif /* CTX_INCLUDE_AARCH32_REGS */ 57a43d431bSSoby Mathew 58626ed510SSoby Mathewpanic_msg: 596c6a470fSAlexei Fedorov .asciz "PANIC in EL3.\nx30" 60626ed510SSoby Mathewexcpt_msg: 616c6a470fSAlexei Fedorov .asciz "Unhandled Exception in EL3.\nx30" 62626ed510SSoby Mathewintr_excpt_msg: 63*b4292bc6SAlexei Fedorov .ascii "Unhandled Interrupt Exception in EL3.\n" 64*b4292bc6SAlexei Fedorovx30_msg: 65*b4292bc6SAlexei Fedorov .asciz "x30" 66*b4292bc6SAlexei Fedorovexcpt_msg_el: 67*b4292bc6SAlexei Fedorov .asciz "Unhandled Exception from EL" 68626ed510SSoby Mathew 69626ed510SSoby Mathew /* 70626ed510SSoby Mathew * Helper function to print from crash buf. 71626ed510SSoby Mathew * The print loop is controlled by the buf size and 72626ed510SSoby Mathew * ascii reg name list which is passed in x6. The 73626ed510SSoby Mathew * function returns the crash buf address in x0. 74626ed510SSoby Mathew * Clobbers : x0 - x7, sp 75626ed510SSoby Mathew */ 76626ed510SSoby Mathewfunc size_controlled_print 77626ed510SSoby Mathew /* Save the lr */ 78626ed510SSoby Mathew mov sp, x30 79626ed510SSoby Mathew /* load the crash buf address */ 80626ed510SSoby Mathew mrs x7, tpidr_el3 81626ed510SSoby Mathewtest_size_list: 82626ed510SSoby Mathew /* Calculate x5 always as it will be clobbered by asm_print_hex */ 83626ed510SSoby Mathew mrs x5, tpidr_el3 84626ed510SSoby Mathew add x5, x5, #CPU_DATA_CRASH_BUF_SIZE 85626ed510SSoby Mathew /* Test whether we have reached end of crash buf */ 86626ed510SSoby Mathew cmp x7, x5 87626ed510SSoby Mathew b.eq exit_size_print 88626ed510SSoby Mathew ldrb w4, [x6] 89626ed510SSoby Mathew /* Test whether we are at end of list */ 90626ed510SSoby Mathew cbz w4, exit_size_print 91626ed510SSoby Mathew mov x4, x6 92626ed510SSoby Mathew /* asm_print_str updates x4 to point to next entry in list */ 93626ed510SSoby Mathew bl asm_print_str 946c6a470fSAlexei Fedorov /* x0 = number of symbols printed + 1 */ 956c6a470fSAlexei Fedorov sub x0, x4, x6 96626ed510SSoby Mathew /* update x6 with the updated list pointer */ 97626ed510SSoby Mathew mov x6, x4 986c6a470fSAlexei Fedorov bl print_alignment 99155a1006SJulius Werner ldr x4, [x7], #REGSZ 100626ed510SSoby Mathew bl asm_print_hex 10153d7e003SJustin Chadwell bl asm_print_newline 102626ed510SSoby Mathew b test_size_list 103626ed510SSoby Mathewexit_size_print: 104626ed510SSoby Mathew mov x30, sp 105626ed510SSoby Mathew ret 1068b779620SKévin Petitendfunc size_controlled_print 107626ed510SSoby Mathew 1086c6a470fSAlexei Fedorov /* ----------------------------------------------------- 1096c6a470fSAlexei Fedorov * This function calculates and prints required number 1106c6a470fSAlexei Fedorov * of space characters followed by "= 0x", based on the 1116c6a470fSAlexei Fedorov * length of ascii register name. 1126c6a470fSAlexei Fedorov * x0: length of ascii register name + 1 1136c6a470fSAlexei Fedorov * ------------------------------------------------------ 1146c6a470fSAlexei Fedorov */ 1156c6a470fSAlexei Fedorovfunc print_alignment 1166c6a470fSAlexei Fedorov /* The minimum ascii length is 3, e.g. for "x0" */ 1176c6a470fSAlexei Fedorov adr x4, print_spacer - 3 1186c6a470fSAlexei Fedorov add x4, x4, x0 1196c6a470fSAlexei Fedorov b asm_print_str 1206c6a470fSAlexei Fedorovendfunc print_alignment 1216c6a470fSAlexei Fedorov 122626ed510SSoby Mathew /* 123626ed510SSoby Mathew * Helper function to store x8 - x15 registers to 124626ed510SSoby Mathew * the crash buf. The system registers values are 125626ed510SSoby Mathew * copied to x8 to x15 by the caller which are then 126626ed510SSoby Mathew * copied to the crash buf by this function. 127626ed510SSoby Mathew * x0 points to the crash buf. It then calls 128626ed510SSoby Mathew * size_controlled_print to print to console. 129626ed510SSoby Mathew * Clobbers : x0 - x7, sp 130626ed510SSoby Mathew */ 131626ed510SSoby Mathewfunc str_in_crash_buf_print 132626ed510SSoby Mathew /* restore the crash buf address in x0 */ 133626ed510SSoby Mathew mrs x0, tpidr_el3 134626ed510SSoby Mathew stp x8, x9, [x0] 135155a1006SJulius Werner stp x10, x11, [x0, #REGSZ * 2] 136155a1006SJulius Werner stp x12, x13, [x0, #REGSZ * 4] 137155a1006SJulius Werner stp x14, x15, [x0, #REGSZ * 6] 138626ed510SSoby Mathew b size_controlled_print 1398b779620SKévin Petitendfunc str_in_crash_buf_print 140626ed510SSoby Mathew 141626ed510SSoby Mathew /* ------------------------------------------------------ 142626ed510SSoby Mathew * This macro calculates the offset to crash buf from 143626ed510SSoby Mathew * cpu_data and stores it in tpidr_el3. It also saves x0 144626ed510SSoby Mathew * and x1 in the crash buf by using sp as a temporary 145626ed510SSoby Mathew * register. 146626ed510SSoby Mathew * ------------------------------------------------------ 147626ed510SSoby Mathew */ 148626ed510SSoby Mathew .macro prepare_crash_buf_save_x0_x1 149626ed510SSoby Mathew /* we can corrupt this reg to free up x0 */ 150626ed510SSoby Mathew mov sp, x0 151626ed510SSoby Mathew /* tpidr_el3 contains the address to cpu_data structure */ 152626ed510SSoby Mathew mrs x0, tpidr_el3 153626ed510SSoby Mathew /* Calculate the Crash buffer offset in cpu_data */ 154626ed510SSoby Mathew add x0, x0, #CPU_DATA_CRASH_BUF_OFFSET 155626ed510SSoby Mathew /* Store crash buffer address in tpidr_el3 */ 156626ed510SSoby Mathew msr tpidr_el3, x0 157155a1006SJulius Werner str x1, [x0, #REGSZ] 158626ed510SSoby Mathew mov x1, sp 159626ed510SSoby Mathew str x1, [x0] 160626ed510SSoby Mathew .endm 161a43d431bSSoby Mathew 162a43d431bSSoby Mathew /* ----------------------------------------------------- 163626ed510SSoby Mathew * This function allows to report a crash (if crash 164626ed510SSoby Mathew * reporting is enabled) when an unhandled exception 165626ed510SSoby Mathew * occurs. It prints the CPU state via the crash console 166626ed510SSoby Mathew * making use of the crash buf. This function will 167626ed510SSoby Mathew * not return. 168a43d431bSSoby Mathew * ----------------------------------------------------- 169a43d431bSSoby Mathew */ 170626ed510SSoby Mathewfunc report_unhandled_exception 171626ed510SSoby Mathew prepare_crash_buf_save_x0_x1 172626ed510SSoby Mathew adr x0, excpt_msg 173626ed510SSoby Mathew mov sp, x0 174626ed510SSoby Mathew /* This call will not return */ 175626ed510SSoby Mathew b do_crash_reporting 1768b779620SKévin Petitendfunc report_unhandled_exception 177a43d431bSSoby Mathew 178626ed510SSoby Mathew /* ----------------------------------------------------- 179626ed510SSoby Mathew * This function allows to report a crash (if crash 180626ed510SSoby Mathew * reporting is enabled) when an unhandled interrupt 181626ed510SSoby Mathew * occurs. It prints the CPU state via the crash console 182626ed510SSoby Mathew * making use of the crash buf. This function will 183626ed510SSoby Mathew * not return. 184626ed510SSoby Mathew * ----------------------------------------------------- 185626ed510SSoby Mathew */ 186626ed510SSoby Mathewfunc report_unhandled_interrupt 187626ed510SSoby Mathew prepare_crash_buf_save_x0_x1 188626ed510SSoby Mathew adr x0, intr_excpt_msg 189626ed510SSoby Mathew mov sp, x0 190626ed510SSoby Mathew /* This call will not return */ 191626ed510SSoby Mathew b do_crash_reporting 1928b779620SKévin Petitendfunc report_unhandled_interrupt 193a43d431bSSoby Mathew 194626ed510SSoby Mathew /* ----------------------------------------------------- 195*b4292bc6SAlexei Fedorov * This function allows to report a crash from the lower 196*b4292bc6SAlexei Fedorov * exception level (if crash reporting is enabled) when 197*b4292bc6SAlexei Fedorov * panic() is invoked from C Runtime. 198*b4292bc6SAlexei Fedorov * It prints the CPU state via the crash console making 199*b4292bc6SAlexei Fedorov * use of 'cpu_context' structure where general purpose 200*b4292bc6SAlexei Fedorov * registers are saved and the crash buf. 201*b4292bc6SAlexei Fedorov * This function will not return. 202*b4292bc6SAlexei Fedorov * 203*b4292bc6SAlexei Fedorov * x0: Exception level 204*b4292bc6SAlexei Fedorov * ----------------------------------------------------- 205*b4292bc6SAlexei Fedorov */ 206*b4292bc6SAlexei Fedorovfunc elx_panic 207*b4292bc6SAlexei Fedorov msr spsel, #MODE_SP_ELX 208*b4292bc6SAlexei Fedorov mov x8, x0 209*b4292bc6SAlexei Fedorov 210*b4292bc6SAlexei Fedorov /* Print the crash message */ 211*b4292bc6SAlexei Fedorov adr x4, excpt_msg_el 212*b4292bc6SAlexei Fedorov bl asm_print_str 213*b4292bc6SAlexei Fedorov 214*b4292bc6SAlexei Fedorov /* Print exception level */ 215*b4292bc6SAlexei Fedorov add x0, x8, #'0' 216*b4292bc6SAlexei Fedorov bl plat_crash_console_putc 217*b4292bc6SAlexei Fedorov bl asm_print_newline 218*b4292bc6SAlexei Fedorov 219*b4292bc6SAlexei Fedorov /* Report x0 - x29 values stored in 'gpregs_ctx' structure */ 220*b4292bc6SAlexei Fedorov /* Store the ascii list pointer in x6 */ 221*b4292bc6SAlexei Fedorov adr x6, gp_regs 222*b4292bc6SAlexei Fedorov add x7, sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X0 223*b4292bc6SAlexei Fedorov 224*b4292bc6SAlexei Fedorovprint_next: 225*b4292bc6SAlexei Fedorov ldrb w4, [x6] 226*b4292bc6SAlexei Fedorov /* Test whether we are at end of list */ 227*b4292bc6SAlexei Fedorov cbz w4, print_x30 228*b4292bc6SAlexei Fedorov mov x4, x6 229*b4292bc6SAlexei Fedorov /* asm_print_str updates x4 to point to next entry in list */ 230*b4292bc6SAlexei Fedorov bl asm_print_str 231*b4292bc6SAlexei Fedorov /* x0 = number of symbols printed + 1 */ 232*b4292bc6SAlexei Fedorov sub x0, x4, x6 233*b4292bc6SAlexei Fedorov /* Update x6 with the updated list pointer */ 234*b4292bc6SAlexei Fedorov mov x6, x4 235*b4292bc6SAlexei Fedorov bl print_alignment 236*b4292bc6SAlexei Fedorov ldr x4, [x7], #REGSZ 237*b4292bc6SAlexei Fedorov bl asm_print_hex 238*b4292bc6SAlexei Fedorov bl asm_print_newline 239*b4292bc6SAlexei Fedorov b print_next 240*b4292bc6SAlexei Fedorov 241*b4292bc6SAlexei Fedorovprint_x30: 242*b4292bc6SAlexei Fedorov adr x4, x30_msg 243*b4292bc6SAlexei Fedorov bl asm_print_str 244*b4292bc6SAlexei Fedorov 245*b4292bc6SAlexei Fedorov /* Print spaces to align "x30" string */ 246*b4292bc6SAlexei Fedorov mov x0, #4 247*b4292bc6SAlexei Fedorov bl print_alignment 248*b4292bc6SAlexei Fedorov 249*b4292bc6SAlexei Fedorov /* Report x30 */ 250*b4292bc6SAlexei Fedorov ldr x4, [x7] 251*b4292bc6SAlexei Fedorov 252*b4292bc6SAlexei Fedorov /* ---------------------------------------------------------------- 253*b4292bc6SAlexei Fedorov * Different virtual address space size can be defined for each EL. 254*b4292bc6SAlexei Fedorov * Ensure that we use the proper one by reading the corresponding 255*b4292bc6SAlexei Fedorov * TCR_ELx register. 256*b4292bc6SAlexei Fedorov * ---------------------------------------------------------------- 257*b4292bc6SAlexei Fedorov */ 258*b4292bc6SAlexei Fedorov cmp x8, #MODE_EL2 259*b4292bc6SAlexei Fedorov b.lt from_el1 /* EL1 */ 260*b4292bc6SAlexei Fedorov mrs x2, sctlr_el2 261*b4292bc6SAlexei Fedorov mrs x1, tcr_el2 262*b4292bc6SAlexei Fedorov 263*b4292bc6SAlexei Fedorov /* ---------------------------------------------------------------- 264*b4292bc6SAlexei Fedorov * Check if pointer authentication is enabled at the specified EL. 265*b4292bc6SAlexei Fedorov * If it isn't, we can then skip stripping a PAC code. 266*b4292bc6SAlexei Fedorov * ---------------------------------------------------------------- 267*b4292bc6SAlexei Fedorov */ 268*b4292bc6SAlexei Fedorovtest_pauth: 269*b4292bc6SAlexei Fedorov tst x2, #(SCTLR_EnIA_BIT | SCTLR_EnIB_BIT) 270*b4292bc6SAlexei Fedorov b.eq no_pauth 271*b4292bc6SAlexei Fedorov 272*b4292bc6SAlexei Fedorov /* Demangle address */ 273*b4292bc6SAlexei Fedorov and x1, x1, #0x3F /* T0SZ = TCR_ELx[5:0] */ 274*b4292bc6SAlexei Fedorov sub x1, x1, #64 275*b4292bc6SAlexei Fedorov neg x1, x1 /* bottom_pac_bit = 64 - T0SZ */ 276*b4292bc6SAlexei Fedorov mov x2, #-1 277*b4292bc6SAlexei Fedorov lsl x2, x2, x1 278*b4292bc6SAlexei Fedorov bic x4, x4, x2 279*b4292bc6SAlexei Fedorov 280*b4292bc6SAlexei Fedorovno_pauth: 281*b4292bc6SAlexei Fedorov bl asm_print_hex 282*b4292bc6SAlexei Fedorov bl asm_print_newline 283*b4292bc6SAlexei Fedorov 284*b4292bc6SAlexei Fedorov /* tpidr_el3 contains the address to cpu_data structure */ 285*b4292bc6SAlexei Fedorov mrs x0, tpidr_el3 286*b4292bc6SAlexei Fedorov /* Calculate the Crash buffer offset in cpu_data */ 287*b4292bc6SAlexei Fedorov add x0, x0, #CPU_DATA_CRASH_BUF_OFFSET 288*b4292bc6SAlexei Fedorov /* Store crash buffer address in tpidr_el3 */ 289*b4292bc6SAlexei Fedorov msr tpidr_el3, x0 290*b4292bc6SAlexei Fedorov 291*b4292bc6SAlexei Fedorov /* Print the rest of crash dump */ 292*b4292bc6SAlexei Fedorov b print_el3_sys_regs 293*b4292bc6SAlexei Fedorov 294*b4292bc6SAlexei Fedorovfrom_el1: 295*b4292bc6SAlexei Fedorov mrs x2, sctlr_el1 296*b4292bc6SAlexei Fedorov mrs x1, tcr_el1 297*b4292bc6SAlexei Fedorov b test_pauth 298*b4292bc6SAlexei Fedorovendfunc elx_panic 299*b4292bc6SAlexei Fedorov 300*b4292bc6SAlexei Fedorov /* ----------------------------------------------------- 301626ed510SSoby Mathew * This function allows to report a crash (if crash 302626ed510SSoby Mathew * reporting is enabled) when panic() is invoked from 303626ed510SSoby Mathew * C Runtime. It prints the CPU state via the crash 304626ed510SSoby Mathew * console making use of the crash buf. This function 305626ed510SSoby Mathew * will not return. 306626ed510SSoby Mathew * ----------------------------------------------------- 307626ed510SSoby Mathew */ 308626ed510SSoby Mathewfunc el3_panic 3096c6a470fSAlexei Fedorov msr spsel, #MODE_SP_ELX 310626ed510SSoby Mathew prepare_crash_buf_save_x0_x1 311626ed510SSoby Mathew adr x0, panic_msg 312626ed510SSoby Mathew mov sp, x0 313*b4292bc6SAlexei Fedorov /* Fall through to 'do_crash_reporting' */ 314a43d431bSSoby Mathew 315626ed510SSoby Mathew /* ------------------------------------------------------------ 316626ed510SSoby Mathew * The common crash reporting functionality. It requires x0 317626ed510SSoby Mathew * and x1 has already been stored in crash buf, sp points to 318626ed510SSoby Mathew * crash message and tpidr_el3 contains the crash buf address. 319626ed510SSoby Mathew * The function does the following: 320626ed510SSoby Mathew * - Retrieve the crash buffer from tpidr_el3 321626ed510SSoby Mathew * - Store x2 to x6 in the crash buffer 322626ed510SSoby Mathew * - Initialise the crash console. 323626ed510SSoby Mathew * - Print the crash message by using the address in sp. 324626ed510SSoby Mathew * - Print x30 value to the crash console. 325626ed510SSoby Mathew * - Print x0 - x7 from the crash buf to the crash console. 326626ed510SSoby Mathew * - Print x8 - x29 (in groups of 8 registers) using the 327626ed510SSoby Mathew * crash buf to the crash console. 328626ed510SSoby Mathew * - Print el3 sys regs (in groups of 8 registers) using the 329626ed510SSoby Mathew * crash buf to the crash console. 330626ed510SSoby Mathew * - Print non el3 sys regs (in groups of 8 registers) using 331626ed510SSoby Mathew * the crash buf to the crash console. 332626ed510SSoby Mathew * ------------------------------------------------------------ 333626ed510SSoby Mathew */ 334*b4292bc6SAlexei Fedorovdo_crash_reporting: 335626ed510SSoby Mathew /* Retrieve the crash buf from tpidr_el3 */ 336626ed510SSoby Mathew mrs x0, tpidr_el3 337626ed510SSoby Mathew /* Store x2 - x6, x30 in the crash buffer */ 338155a1006SJulius Werner stp x2, x3, [x0, #REGSZ * 2] 339155a1006SJulius Werner stp x4, x5, [x0, #REGSZ * 4] 340155a1006SJulius Werner stp x6, x30, [x0, #REGSZ * 6] 341626ed510SSoby Mathew /* Initialize the crash console */ 342626ed510SSoby Mathew bl plat_crash_console_init 343626ed510SSoby Mathew /* Verify the console is initialized */ 344626ed510SSoby Mathew cbz x0, crash_panic 345626ed510SSoby Mathew /* Print the crash message. sp points to the crash message */ 346626ed510SSoby Mathew mov x4, sp 347626ed510SSoby Mathew bl asm_print_str 3486c6a470fSAlexei Fedorov /* Print spaces to align "x30" string */ 3496c6a470fSAlexei Fedorov mov x0, #4 3506c6a470fSAlexei Fedorov bl print_alignment 351*b4292bc6SAlexei Fedorov /* Load the crash buf address */ 352626ed510SSoby Mathew mrs x0, tpidr_el3 353*b4292bc6SAlexei Fedorov /* Report x30 first from the crash buf */ 354155a1006SJulius Werner ldr x4, [x0, #REGSZ * 7] 35568c76088SAlexei Fedorov 35668c76088SAlexei Fedorov#if ENABLE_PAUTH 35768c76088SAlexei Fedorov /* Demangle address */ 35868c76088SAlexei Fedorov xpaci x4 35968c76088SAlexei Fedorov#endif 360626ed510SSoby Mathew bl asm_print_hex 36153d7e003SJustin Chadwell bl asm_print_newline 362626ed510SSoby Mathew /* Load the crash buf address */ 363626ed510SSoby Mathew mrs x0, tpidr_el3 364626ed510SSoby Mathew /* Now mov x7 into crash buf */ 365155a1006SJulius Werner str x7, [x0, #REGSZ * 7] 366a43d431bSSoby Mathew 367626ed510SSoby Mathew /* Report x0 - x29 values stored in crash buf */ 368626ed510SSoby Mathew /* Store the ascii list pointer in x6 */ 369626ed510SSoby Mathew adr x6, gp_regs 370626ed510SSoby Mathew /* Print x0 to x7 from the crash buf */ 371626ed510SSoby Mathew bl size_controlled_print 372626ed510SSoby Mathew /* Store x8 - x15 in crash buf and print */ 373626ed510SSoby Mathew bl str_in_crash_buf_print 374626ed510SSoby Mathew /* Load the crash buf address */ 375626ed510SSoby Mathew mrs x0, tpidr_el3 376626ed510SSoby Mathew /* Store the rest of gp regs and print */ 377626ed510SSoby Mathew stp x16, x17, [x0] 378155a1006SJulius Werner stp x18, x19, [x0, #REGSZ * 2] 379155a1006SJulius Werner stp x20, x21, [x0, #REGSZ * 4] 380155a1006SJulius Werner stp x22, x23, [x0, #REGSZ * 6] 381626ed510SSoby Mathew bl size_controlled_print 382626ed510SSoby Mathew /* Load the crash buf address */ 383626ed510SSoby Mathew mrs x0, tpidr_el3 384626ed510SSoby Mathew stp x24, x25, [x0] 385155a1006SJulius Werner stp x26, x27, [x0, #REGSZ * 2] 386155a1006SJulius Werner stp x28, x29, [x0, #REGSZ * 4] 387626ed510SSoby Mathew bl size_controlled_print 388a43d431bSSoby Mathew 389626ed510SSoby Mathew /* Print the el3 sys registers */ 390*b4292bc6SAlexei Fedorovprint_el3_sys_regs: 391626ed510SSoby Mathew adr x6, el3_sys_regs 392626ed510SSoby Mathew mrs x8, scr_el3 393626ed510SSoby Mathew mrs x9, sctlr_el3 394626ed510SSoby Mathew mrs x10, cptr_el3 395626ed510SSoby Mathew mrs x11, tcr_el3 396626ed510SSoby Mathew mrs x12, daif 397626ed510SSoby Mathew mrs x13, mair_el3 398626ed510SSoby Mathew mrs x14, spsr_el3 399626ed510SSoby Mathew mrs x15, elr_el3 400626ed510SSoby Mathew bl str_in_crash_buf_print 401626ed510SSoby Mathew mrs x8, ttbr0_el3 402626ed510SSoby Mathew mrs x9, esr_el3 403626ed510SSoby Mathew mrs x10, far_el3 404626ed510SSoby Mathew bl str_in_crash_buf_print 405a43d431bSSoby Mathew 406626ed510SSoby Mathew /* Print the non el3 sys registers */ 407626ed510SSoby Mathew adr x6, non_el3_sys_regs 408626ed510SSoby Mathew mrs x8, spsr_el1 409626ed510SSoby Mathew mrs x9, elr_el1 410626ed510SSoby Mathew mrs x10, spsr_abt 411626ed510SSoby Mathew mrs x11, spsr_und 412626ed510SSoby Mathew mrs x12, spsr_irq 413626ed510SSoby Mathew mrs x13, spsr_fiq 414626ed510SSoby Mathew mrs x14, sctlr_el1 415626ed510SSoby Mathew mrs x15, actlr_el1 416626ed510SSoby Mathew bl str_in_crash_buf_print 417626ed510SSoby Mathew mrs x8, cpacr_el1 418626ed510SSoby Mathew mrs x9, csselr_el1 419a43d431bSSoby Mathew mrs x10, sp_el1 420a43d431bSSoby Mathew mrs x11, esr_el1 421a43d431bSSoby Mathew mrs x12, ttbr0_el1 422a43d431bSSoby Mathew mrs x13, ttbr1_el1 423a43d431bSSoby Mathew mrs x14, mair_el1 424a43d431bSSoby Mathew mrs x15, amair_el1 425626ed510SSoby Mathew bl str_in_crash_buf_print 426626ed510SSoby Mathew mrs x8, tcr_el1 427626ed510SSoby Mathew mrs x9, tpidr_el1 428626ed510SSoby Mathew mrs x10, tpidr_el0 429626ed510SSoby Mathew mrs x11, tpidrro_el0 430c424b91eSImre Kis mrs x12, par_el1 431c424b91eSImre Kis mrs x13, mpidr_el1 432c424b91eSImre Kis mrs x14, afsr0_el1 433c424b91eSImre Kis mrs x15, afsr1_el1 434626ed510SSoby Mathew bl str_in_crash_buf_print 435c424b91eSImre Kis mrs x8, contextidr_el1 436c424b91eSImre Kis mrs x9, vbar_el1 437c424b91eSImre Kis mrs x10, cntp_ctl_el0 438c424b91eSImre Kis mrs x11, cntp_cval_el0 439c424b91eSImre Kis mrs x12, cntv_ctl_el0 440c424b91eSImre Kis mrs x13, cntv_cval_el0 441c424b91eSImre Kis mrs x14, cntkctl_el1 442c424b91eSImre Kis mrs x15, sp_el0 443626ed510SSoby Mathew bl str_in_crash_buf_print 444c424b91eSImre Kis mrs x8, isr_el1 445626ed510SSoby Mathew bl str_in_crash_buf_print 446a43d431bSSoby Mathew 447c424b91eSImre Kis#if CTX_INCLUDE_AARCH32_REGS 448c424b91eSImre Kis /* Print the AArch32 registers */ 449c424b91eSImre Kis adr x6, aarch32_regs 450c424b91eSImre Kis mrs x8, dacr32_el2 451c424b91eSImre Kis mrs x9, ifsr32_el2 452c424b91eSImre Kis bl str_in_crash_buf_print 453c424b91eSImre Kis#endif /* CTX_INCLUDE_AARCH32_REGS */ 454c424b91eSImre Kis 455d3f70af6SSoby Mathew /* Get the cpu specific registers to report */ 456d3f70af6SSoby Mathew bl do_cpu_reg_dump 457d3f70af6SSoby Mathew bl str_in_crash_buf_print 4588c106902SSoby Mathew 4599ff67fa6SGerald Lejeune /* Print some platform registers */ 4609ff67fa6SGerald Lejeune plat_crash_print_regs 4618c106902SSoby Mathew 462801cf93cSAntonio Nino Diaz bl plat_crash_console_flush 463801cf93cSAntonio Nino Diaz 464626ed510SSoby Mathew /* Done reporting */ 465a806dad5SJeenu Viswambharan no_ret plat_panic_handler 466*b4292bc6SAlexei Fedorovendfunc el3_panic 467a43d431bSSoby Mathew 468626ed510SSoby Mathew#else /* CRASH_REPORTING */ 469626ed510SSoby Mathewfunc report_unhandled_exception 470626ed510SSoby Mathewreport_unhandled_interrupt: 471a806dad5SJeenu Viswambharan no_ret plat_panic_handler 4728b779620SKévin Petitendfunc report_unhandled_exception 4731645d3eeSSandrine Bailleux#endif /* CRASH_REPORTING */ 4749c22b323SAndrew Thoelke 475626ed510SSoby Mathewfunc crash_panic 476a806dad5SJeenu Viswambharan no_ret plat_panic_handler 4778b779620SKévin Petitendfunc crash_panic 478