1a43d431bSSoby Mathew/* 27e619eccSGovindraj Raja * Copyright (c) 2014-2023, 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 18*f300ef66SGovindraj Raja .globl report_el3_panic 197e619eccSGovindraj Raja .globl report_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: 63b4292bc6SAlexei Fedorov .ascii "Unhandled Interrupt Exception in EL3.\n" 64b4292bc6SAlexei Fedorovx30_msg: 65b4292bc6SAlexei Fedorov .asciz "x30" 66b4292bc6SAlexei Fedorovexcpt_msg_el: 677e619eccSGovindraj Raja .asciz "Unhandled Exception from lower EL.\n" 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 /* ----------------------------------------------------- 195b4292bc6SAlexei Fedorov * This function allows to report a crash from the lower 196b4292bc6SAlexei Fedorov * exception level (if crash reporting is enabled) when 1977e619eccSGovindraj Raja * lower_el_panic() is invoked from C Runtime. 198b4292bc6SAlexei Fedorov * It prints the CPU state via the crash console making 199b4292bc6SAlexei Fedorov * use of 'cpu_context' structure where general purpose 200b4292bc6SAlexei Fedorov * registers are saved and the crash buf. 201b4292bc6SAlexei Fedorov * This function will not return. 202b4292bc6SAlexei Fedorov * ----------------------------------------------------- 203b4292bc6SAlexei Fedorov */ 2047e619eccSGovindraj Rajafunc report_elx_panic 205b4292bc6SAlexei Fedorov msr spsel, #MODE_SP_ELX 206b4292bc6SAlexei Fedorov 207b4292bc6SAlexei Fedorov /* Print the crash message */ 208b4292bc6SAlexei Fedorov adr x4, excpt_msg_el 209b4292bc6SAlexei Fedorov bl asm_print_str 210b4292bc6SAlexei Fedorov 211b4292bc6SAlexei Fedorov /* Report x0 - x29 values stored in 'gpregs_ctx' structure */ 212b4292bc6SAlexei Fedorov /* Store the ascii list pointer in x6 */ 213b4292bc6SAlexei Fedorov adr x6, gp_regs 214b4292bc6SAlexei Fedorov add x7, sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X0 215b4292bc6SAlexei Fedorov 216b4292bc6SAlexei Fedorovprint_next: 217b4292bc6SAlexei Fedorov ldrb w4, [x6] 218b4292bc6SAlexei Fedorov /* Test whether we are at end of list */ 219b4292bc6SAlexei Fedorov cbz w4, print_x30 220b4292bc6SAlexei Fedorov mov x4, x6 221b4292bc6SAlexei Fedorov /* asm_print_str updates x4 to point to next entry in list */ 222b4292bc6SAlexei Fedorov bl asm_print_str 223b4292bc6SAlexei Fedorov /* x0 = number of symbols printed + 1 */ 224b4292bc6SAlexei Fedorov sub x0, x4, x6 225b4292bc6SAlexei Fedorov /* Update x6 with the updated list pointer */ 226b4292bc6SAlexei Fedorov mov x6, x4 227b4292bc6SAlexei Fedorov bl print_alignment 228b4292bc6SAlexei Fedorov ldr x4, [x7], #REGSZ 229b4292bc6SAlexei Fedorov bl asm_print_hex 230b4292bc6SAlexei Fedorov bl asm_print_newline 231b4292bc6SAlexei Fedorov b print_next 232b4292bc6SAlexei Fedorov 233b4292bc6SAlexei Fedorovprint_x30: 234b4292bc6SAlexei Fedorov adr x4, x30_msg 235b4292bc6SAlexei Fedorov bl asm_print_str 236b4292bc6SAlexei Fedorov 237b4292bc6SAlexei Fedorov /* Print spaces to align "x30" string */ 238b4292bc6SAlexei Fedorov mov x0, #4 239b4292bc6SAlexei Fedorov bl print_alignment 240b4292bc6SAlexei Fedorov 241b4292bc6SAlexei Fedorov /* Report x30 */ 242b4292bc6SAlexei Fedorov ldr x4, [x7] 243b4292bc6SAlexei Fedorov 244b4292bc6SAlexei Fedorov /* ---------------------------------------------------------------- 245b4292bc6SAlexei Fedorov * Different virtual address space size can be defined for each EL. 246b4292bc6SAlexei Fedorov * Ensure that we use the proper one by reading the corresponding 247b4292bc6SAlexei Fedorov * TCR_ELx register. 248b4292bc6SAlexei Fedorov * ---------------------------------------------------------------- 249b4292bc6SAlexei Fedorov */ 250b4292bc6SAlexei Fedorov cmp x8, #MODE_EL2 251b4292bc6SAlexei Fedorov b.lt from_el1 /* EL1 */ 252b4292bc6SAlexei Fedorov mrs x2, sctlr_el2 253b4292bc6SAlexei Fedorov mrs x1, tcr_el2 254b4292bc6SAlexei Fedorov 255b4292bc6SAlexei Fedorov /* ---------------------------------------------------------------- 256b4292bc6SAlexei Fedorov * Check if pointer authentication is enabled at the specified EL. 257b4292bc6SAlexei Fedorov * If it isn't, we can then skip stripping a PAC code. 258b4292bc6SAlexei Fedorov * ---------------------------------------------------------------- 259b4292bc6SAlexei Fedorov */ 260b4292bc6SAlexei Fedorovtest_pauth: 261b4292bc6SAlexei Fedorov tst x2, #(SCTLR_EnIA_BIT | SCTLR_EnIB_BIT) 262b4292bc6SAlexei Fedorov b.eq no_pauth 263b4292bc6SAlexei Fedorov 264b4292bc6SAlexei Fedorov /* Demangle address */ 265b4292bc6SAlexei Fedorov and x1, x1, #0x3F /* T0SZ = TCR_ELx[5:0] */ 266b4292bc6SAlexei Fedorov sub x1, x1, #64 267b4292bc6SAlexei Fedorov neg x1, x1 /* bottom_pac_bit = 64 - T0SZ */ 268b4292bc6SAlexei Fedorov mov x2, #-1 269b4292bc6SAlexei Fedorov lsl x2, x2, x1 270b4292bc6SAlexei Fedorov bic x4, x4, x2 271b4292bc6SAlexei Fedorov 272b4292bc6SAlexei Fedorovno_pauth: 273b4292bc6SAlexei Fedorov bl asm_print_hex 274b4292bc6SAlexei Fedorov bl asm_print_newline 275b4292bc6SAlexei Fedorov 276b4292bc6SAlexei Fedorov /* tpidr_el3 contains the address to cpu_data structure */ 277b4292bc6SAlexei Fedorov mrs x0, tpidr_el3 278b4292bc6SAlexei Fedorov /* Calculate the Crash buffer offset in cpu_data */ 279b4292bc6SAlexei Fedorov add x0, x0, #CPU_DATA_CRASH_BUF_OFFSET 280b4292bc6SAlexei Fedorov /* Store crash buffer address in tpidr_el3 */ 281b4292bc6SAlexei Fedorov msr tpidr_el3, x0 282b4292bc6SAlexei Fedorov 283b4292bc6SAlexei Fedorov /* Print the rest of crash dump */ 284b4292bc6SAlexei Fedorov b print_el3_sys_regs 285b4292bc6SAlexei Fedorov 286b4292bc6SAlexei Fedorovfrom_el1: 287b4292bc6SAlexei Fedorov mrs x2, sctlr_el1 288b4292bc6SAlexei Fedorov mrs x1, tcr_el1 289b4292bc6SAlexei Fedorov b test_pauth 2907e619eccSGovindraj Rajaendfunc report_elx_panic 291b4292bc6SAlexei Fedorov 292b4292bc6SAlexei Fedorov /* ----------------------------------------------------- 293626ed510SSoby Mathew * This function allows to report a crash (if crash 294626ed510SSoby Mathew * reporting is enabled) when panic() is invoked from 295626ed510SSoby Mathew * C Runtime. It prints the CPU state via the crash 296626ed510SSoby Mathew * console making use of the crash buf. This function 297626ed510SSoby Mathew * will not return. 298626ed510SSoby Mathew * ----------------------------------------------------- 299626ed510SSoby Mathew */ 300*f300ef66SGovindraj Rajafunc report_el3_panic 3016c6a470fSAlexei Fedorov msr spsel, #MODE_SP_ELX 302626ed510SSoby Mathew prepare_crash_buf_save_x0_x1 303626ed510SSoby Mathew adr x0, panic_msg 304626ed510SSoby Mathew mov sp, x0 305b4292bc6SAlexei Fedorov /* Fall through to 'do_crash_reporting' */ 306a43d431bSSoby Mathew 307626ed510SSoby Mathew /* ------------------------------------------------------------ 308626ed510SSoby Mathew * The common crash reporting functionality. It requires x0 309626ed510SSoby Mathew * and x1 has already been stored in crash buf, sp points to 310626ed510SSoby Mathew * crash message and tpidr_el3 contains the crash buf address. 311626ed510SSoby Mathew * The function does the following: 312626ed510SSoby Mathew * - Retrieve the crash buffer from tpidr_el3 313626ed510SSoby Mathew * - Store x2 to x6 in the crash buffer 314626ed510SSoby Mathew * - Initialise the crash console. 315626ed510SSoby Mathew * - Print the crash message by using the address in sp. 316626ed510SSoby Mathew * - Print x30 value to the crash console. 317626ed510SSoby Mathew * - Print x0 - x7 from the crash buf to the crash console. 318626ed510SSoby Mathew * - Print x8 - x29 (in groups of 8 registers) using the 319626ed510SSoby Mathew * crash buf to the crash console. 320626ed510SSoby Mathew * - Print el3 sys regs (in groups of 8 registers) using the 321626ed510SSoby Mathew * crash buf to the crash console. 322626ed510SSoby Mathew * - Print non el3 sys regs (in groups of 8 registers) using 323626ed510SSoby Mathew * the crash buf to the crash console. 324626ed510SSoby Mathew * ------------------------------------------------------------ 325626ed510SSoby Mathew */ 326b4292bc6SAlexei Fedorovdo_crash_reporting: 327626ed510SSoby Mathew /* Retrieve the crash buf from tpidr_el3 */ 328626ed510SSoby Mathew mrs x0, tpidr_el3 329626ed510SSoby Mathew /* Store x2 - x6, x30 in the crash buffer */ 330155a1006SJulius Werner stp x2, x3, [x0, #REGSZ * 2] 331155a1006SJulius Werner stp x4, x5, [x0, #REGSZ * 4] 332155a1006SJulius Werner stp x6, x30, [x0, #REGSZ * 6] 333626ed510SSoby Mathew /* Initialize the crash console */ 334626ed510SSoby Mathew bl plat_crash_console_init 335626ed510SSoby Mathew /* Verify the console is initialized */ 336626ed510SSoby Mathew cbz x0, crash_panic 337626ed510SSoby Mathew /* Print the crash message. sp points to the crash message */ 338626ed510SSoby Mathew mov x4, sp 339626ed510SSoby Mathew bl asm_print_str 3406c6a470fSAlexei Fedorov /* Print spaces to align "x30" string */ 3416c6a470fSAlexei Fedorov mov x0, #4 3426c6a470fSAlexei Fedorov bl print_alignment 343b4292bc6SAlexei Fedorov /* Load the crash buf address */ 344626ed510SSoby Mathew mrs x0, tpidr_el3 345b4292bc6SAlexei Fedorov /* Report x30 first from the crash buf */ 346155a1006SJulius Werner ldr x4, [x0, #REGSZ * 7] 34768c76088SAlexei Fedorov 34868c76088SAlexei Fedorov#if ENABLE_PAUTH 34968c76088SAlexei Fedorov /* Demangle address */ 35068c76088SAlexei Fedorov xpaci x4 35168c76088SAlexei Fedorov#endif 352626ed510SSoby Mathew bl asm_print_hex 35353d7e003SJustin Chadwell bl asm_print_newline 354626ed510SSoby Mathew /* Load the crash buf address */ 355626ed510SSoby Mathew mrs x0, tpidr_el3 356626ed510SSoby Mathew /* Now mov x7 into crash buf */ 357155a1006SJulius Werner str x7, [x0, #REGSZ * 7] 358a43d431bSSoby Mathew 359626ed510SSoby Mathew /* Report x0 - x29 values stored in crash buf */ 360626ed510SSoby Mathew /* Store the ascii list pointer in x6 */ 361626ed510SSoby Mathew adr x6, gp_regs 362626ed510SSoby Mathew /* Print x0 to x7 from the crash buf */ 363626ed510SSoby Mathew bl size_controlled_print 364626ed510SSoby Mathew /* Store x8 - x15 in crash buf and print */ 365626ed510SSoby Mathew bl str_in_crash_buf_print 366626ed510SSoby Mathew /* Load the crash buf address */ 367626ed510SSoby Mathew mrs x0, tpidr_el3 368626ed510SSoby Mathew /* Store the rest of gp regs and print */ 369626ed510SSoby Mathew stp x16, x17, [x0] 370155a1006SJulius Werner stp x18, x19, [x0, #REGSZ * 2] 371155a1006SJulius Werner stp x20, x21, [x0, #REGSZ * 4] 372155a1006SJulius Werner stp x22, x23, [x0, #REGSZ * 6] 373626ed510SSoby Mathew bl size_controlled_print 374626ed510SSoby Mathew /* Load the crash buf address */ 375626ed510SSoby Mathew mrs x0, tpidr_el3 376626ed510SSoby Mathew stp x24, x25, [x0] 377155a1006SJulius Werner stp x26, x27, [x0, #REGSZ * 2] 378155a1006SJulius Werner stp x28, x29, [x0, #REGSZ * 4] 379626ed510SSoby Mathew bl size_controlled_print 380a43d431bSSoby Mathew 381626ed510SSoby Mathew /* Print the el3 sys registers */ 382b4292bc6SAlexei Fedorovprint_el3_sys_regs: 383626ed510SSoby Mathew adr x6, el3_sys_regs 384626ed510SSoby Mathew mrs x8, scr_el3 385626ed510SSoby Mathew mrs x9, sctlr_el3 386626ed510SSoby Mathew mrs x10, cptr_el3 387626ed510SSoby Mathew mrs x11, tcr_el3 388626ed510SSoby Mathew mrs x12, daif 389626ed510SSoby Mathew mrs x13, mair_el3 390626ed510SSoby Mathew mrs x14, spsr_el3 391626ed510SSoby Mathew mrs x15, elr_el3 392626ed510SSoby Mathew bl str_in_crash_buf_print 393626ed510SSoby Mathew mrs x8, ttbr0_el3 394626ed510SSoby Mathew mrs x9, esr_el3 395626ed510SSoby Mathew mrs x10, far_el3 396626ed510SSoby Mathew bl str_in_crash_buf_print 397a43d431bSSoby Mathew 398626ed510SSoby Mathew /* Print the non el3 sys registers */ 399626ed510SSoby Mathew adr x6, non_el3_sys_regs 400626ed510SSoby Mathew mrs x8, spsr_el1 401626ed510SSoby Mathew mrs x9, elr_el1 402626ed510SSoby Mathew mrs x10, spsr_abt 403626ed510SSoby Mathew mrs x11, spsr_und 404626ed510SSoby Mathew mrs x12, spsr_irq 405626ed510SSoby Mathew mrs x13, spsr_fiq 406626ed510SSoby Mathew mrs x14, sctlr_el1 407626ed510SSoby Mathew mrs x15, actlr_el1 408626ed510SSoby Mathew bl str_in_crash_buf_print 409626ed510SSoby Mathew mrs x8, cpacr_el1 410626ed510SSoby Mathew mrs x9, csselr_el1 411a43d431bSSoby Mathew mrs x10, sp_el1 412a43d431bSSoby Mathew mrs x11, esr_el1 413a43d431bSSoby Mathew mrs x12, ttbr0_el1 414a43d431bSSoby Mathew mrs x13, ttbr1_el1 415a43d431bSSoby Mathew mrs x14, mair_el1 416a43d431bSSoby Mathew mrs x15, amair_el1 417626ed510SSoby Mathew bl str_in_crash_buf_print 418626ed510SSoby Mathew mrs x8, tcr_el1 419626ed510SSoby Mathew mrs x9, tpidr_el1 420626ed510SSoby Mathew mrs x10, tpidr_el0 421626ed510SSoby Mathew mrs x11, tpidrro_el0 422c424b91eSImre Kis mrs x12, par_el1 423c424b91eSImre Kis mrs x13, mpidr_el1 424c424b91eSImre Kis mrs x14, afsr0_el1 425c424b91eSImre Kis mrs x15, afsr1_el1 426626ed510SSoby Mathew bl str_in_crash_buf_print 427c424b91eSImre Kis mrs x8, contextidr_el1 428c424b91eSImre Kis mrs x9, vbar_el1 429c424b91eSImre Kis mrs x10, cntp_ctl_el0 430c424b91eSImre Kis mrs x11, cntp_cval_el0 431c424b91eSImre Kis mrs x12, cntv_ctl_el0 432c424b91eSImre Kis mrs x13, cntv_cval_el0 433c424b91eSImre Kis mrs x14, cntkctl_el1 434c424b91eSImre Kis mrs x15, sp_el0 435626ed510SSoby Mathew bl str_in_crash_buf_print 436c424b91eSImre Kis mrs x8, isr_el1 437626ed510SSoby Mathew bl str_in_crash_buf_print 438a43d431bSSoby Mathew 439c424b91eSImre Kis#if CTX_INCLUDE_AARCH32_REGS 440c424b91eSImre Kis /* Print the AArch32 registers */ 441c424b91eSImre Kis adr x6, aarch32_regs 442c424b91eSImre Kis mrs x8, dacr32_el2 443c424b91eSImre Kis mrs x9, ifsr32_el2 444c424b91eSImre Kis bl str_in_crash_buf_print 445c424b91eSImre Kis#endif /* CTX_INCLUDE_AARCH32_REGS */ 446c424b91eSImre Kis 447d3f70af6SSoby Mathew /* Get the cpu specific registers to report */ 448d3f70af6SSoby Mathew bl do_cpu_reg_dump 449d3f70af6SSoby Mathew bl str_in_crash_buf_print 4508c106902SSoby Mathew 4519ff67fa6SGerald Lejeune /* Print some platform registers */ 4529ff67fa6SGerald Lejeune plat_crash_print_regs 4538c106902SSoby Mathew 454801cf93cSAntonio Nino Diaz bl plat_crash_console_flush 455801cf93cSAntonio Nino Diaz 456626ed510SSoby Mathew /* Done reporting */ 457a806dad5SJeenu Viswambharan no_ret plat_panic_handler 458*f300ef66SGovindraj Rajaendfunc report_el3_panic 459a43d431bSSoby Mathew 460626ed510SSoby Mathew#else /* CRASH_REPORTING */ 461626ed510SSoby Mathewfunc report_unhandled_exception 462626ed510SSoby Mathewreport_unhandled_interrupt: 463a806dad5SJeenu Viswambharan no_ret plat_panic_handler 4648b779620SKévin Petitendfunc report_unhandled_exception 4651645d3eeSSandrine Bailleux#endif /* CRASH_REPORTING */ 4669c22b323SAndrew Thoelke 467626ed510SSoby Mathewfunc crash_panic 468a806dad5SJeenu Viswambharan no_ret plat_panic_handler 4698b779620SKévin Petitendfunc crash_panic 470