Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2021, Nordic Semiconductor ASA. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <string.h> |
| 8 | #include "tfm_arch.h" |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 9 | #include "tfm_log.h" |
Dávid Házi | be7f0de | 2023-07-19 11:25:38 +0200 | [diff] [blame] | 10 | /* "exception_info.h" must be the last include because of the IAR pragma */ |
| 11 | #include "exception_info.h" |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 12 | |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 13 | static struct exception_info_t exception_info; |
| 14 | |
| 15 | /** |
| 16 | * \brief Check whether the exception was triggered in thread or handler mode. |
| 17 | * |
| 18 | * \param[in] lr LR register containing the EXC_RETURN value. |
| 19 | * |
| 20 | * \retval true The exception will return to thread mode. |
| 21 | */ |
| 22 | __STATIC_INLINE bool is_return_thread_mode(uint32_t lr) |
| 23 | { |
| 24 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) |
| 25 | return !((lr == EXC_RETURN_HANDLER) || (lr == EXC_RETURN_HANDLER_FPU)); |
| 26 | #elif defined(__ARM_ARCH_8M_BASE__) || defined(__ARM_ARCH_8M_MAIN__) \ |
| 27 | || defined(__ARM_ARCH_8_1M_MAIN__) |
| 28 | return (lr & EXC_RETURN_MODE); |
| 29 | #else |
| 30 | return !(lr == EXC_RETURN_HANDLER); |
| 31 | #endif |
| 32 | } |
| 33 | |
| 34 | /** |
| 35 | * \brief Check whether the PSP or MSP is used to restore stack frame on |
| 36 | * exception return. |
| 37 | * |
| 38 | * \param[in] lr LR register containing the EXC_RETURN value. |
| 39 | * |
| 40 | * \retval true The exception frame is on the PSP |
| 41 | */ |
| 42 | __STATIC_INLINE bool is_return_psp(uint32_t lr) |
| 43 | { |
| 44 | #if defined(__ARM_ARCH_7M__) || defined(__ARM_ARCH_7EM__) |
| 45 | return ((lr == EXC_RETURN_THREAD_PSP) || (lr == EXC_RETURN_THREAD_PSP_FPU)); |
| 46 | #elif defined(__ARM_ARCH_8M_BASE__) || defined(__ARM_ARCH_8M_MAIN__) \ |
| 47 | || defined(__ARM_ARCH_8_1M_MAIN__) |
Roman Mazurak | a780d10 | 2024-02-05 21:38:34 +0200 | [diff] [blame] | 48 | if (is_return_secure_stack(lr)) { |
| 49 | /* PSP is used only if SPSEL is set, and we came from thread mode. */ |
| 50 | return ((lr & EXC_RETURN_SPSEL) && is_return_thread_mode(lr)); |
| 51 | } else { |
| 52 | /* PSP is used only if CONTROL_NS.SPSEL is set, and we came from thread mode. */ |
| 53 | bool sp_sel = _FLD2VAL(CONTROL_SPSEL, __TZ_get_CONTROL_NS()) != 0; |
| 54 | return (sp_sel && is_return_thread_mode(lr)); |
| 55 | } |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 56 | #else |
| 57 | return (lr == EXC_RETURN_THREAD_PSP); |
| 58 | #endif |
| 59 | } |
| 60 | |
| 61 | /** |
| 62 | * \brief Get a pointer to the current exception frame |
| 63 | * |
| 64 | * \param[in] lr LR register containing the EXC_RETURN value. |
| 65 | * \param[in] msp The MSP at the start of the exception handler. |
| 66 | * \param[in] psp The PSP at the start of the exception handler. |
| 67 | * |
| 68 | * \return A pointer to the current exception frame. |
| 69 | */ |
| 70 | __STATIC_INLINE |
| 71 | uint32_t *get_exception_frame(uint32_t lr, uint32_t msp, uint32_t psp) |
| 72 | { |
| 73 | #if defined(__ARM_ARCH_8M_BASE__) || defined(__ARM_ARCH_8M_MAIN__) \ |
| 74 | || defined(__ARM_ARCH_8_1M_MAIN__) |
| 75 | bool is_psp = is_return_psp(lr); |
| 76 | |
| 77 | return (uint32_t *)(is_return_secure_stack(lr) |
| 78 | ? (is_psp ? psp : msp) |
| 79 | : (is_psp ? __TZ_get_PSP_NS() : __TZ_get_MSP_NS())); |
| 80 | #else |
| 81 | return (uint32_t *)(is_return_psp(lr) ? psp : msp); |
| 82 | #endif |
| 83 | } |
| 84 | |
Joakim Andersson | a4066d8 | 2022-04-06 16:32:09 +0200 | [diff] [blame] | 85 | static void dump_exception_info(bool stack_error, |
Joakim Andersson | 90e0c06 | 2023-11-13 13:48:08 +0100 | [diff] [blame] | 86 | const struct exception_info_t *ctx) |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 87 | { |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 88 | VERBOSE_RAW("Here is some context for the exception:\n"); |
| 89 | VERBOSE_RAW(" EXC_RETURN (LR): 0x%08x\n", ctx->EXC_RETURN); |
| 90 | VERBOSE_RAW(" Exception came from"); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 91 | #ifdef TRUSTZONE_PRESENT |
| 92 | if (is_return_secure_stack(ctx->EXC_RETURN)) { |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 93 | VERBOSE_RAW(" secure FW in"); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 94 | } else { |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 95 | VERBOSE_RAW(" non-secure FW in"); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 96 | } |
| 97 | #endif |
| 98 | |
| 99 | if (is_return_thread_mode(ctx->EXC_RETURN)) { |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 100 | VERBOSE_RAW(" thread mode.\n"); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 101 | } else { |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 102 | VERBOSE_RAW(" handler mode.\n"); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 103 | } |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 104 | VERBOSE_RAW(" xPSR: 0x%08x\n", ctx->xPSR); |
| 105 | VERBOSE_RAW(" MSP: 0x%08x\n", ctx->MSP); |
| 106 | VERBOSE_RAW(" PSP: 0x%08x\n", ctx->PSP); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 107 | #ifdef TRUSTZONE_PRESENT |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 108 | VERBOSE_RAW(" MSP_NS: 0x%08x\n", __TZ_get_MSP_NS()); |
| 109 | VERBOSE_RAW(" PSP_NS: 0x%08x\n", __TZ_get_PSP_NS()); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 110 | #endif |
| 111 | |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 112 | VERBOSE_RAW(" Exception frame at: 0x%08x\n", (uint32_t)ctx->EXC_FRAME); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 113 | if (stack_error) { |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 114 | VERBOSE_RAW( |
Joakim Andersson | 5383143 | 2021-11-03 15:44:28 +0100 | [diff] [blame] | 115 | " (Note that the exception frame may be corrupted for this type of error.)\r\n"); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 116 | } |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 117 | VERBOSE_RAW(" R0: 0x%08x\n", ctx->EXC_FRAME_COPY[0]); |
| 118 | VERBOSE_RAW(" R1: 0x%08x\n", ctx->EXC_FRAME_COPY[1]); |
| 119 | VERBOSE_RAW(" R2: 0x%08x\n", ctx->EXC_FRAME_COPY[2]); |
| 120 | VERBOSE_RAW(" R3: 0x%08x\n", ctx->EXC_FRAME_COPY[3]); |
| 121 | VERBOSE_RAW(" R12: 0x%08x\n", ctx->EXC_FRAME_COPY[4]); |
| 122 | VERBOSE_RAW(" LR: 0x%08x\n", ctx->EXC_FRAME_COPY[5]); |
| 123 | VERBOSE_RAW(" PC: 0x%08x\n", ctx->EXC_FRAME_COPY[6]); |
| 124 | VERBOSE_RAW(" xPSR: 0x%08x\n", ctx->EXC_FRAME_COPY[7]); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 125 | |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 126 | VERBOSE_RAW(" Callee saved register state:\n"); |
| 127 | VERBOSE_RAW(" R4: 0x%08x\n", ctx->CALLEE_SAVED_COPY[0]); |
| 128 | VERBOSE_RAW(" R5: 0x%08x\n", ctx->CALLEE_SAVED_COPY[1]); |
| 129 | VERBOSE_RAW(" R6: 0x%08x\n", ctx->CALLEE_SAVED_COPY[2]); |
| 130 | VERBOSE_RAW(" R7: 0x%08x\n", ctx->CALLEE_SAVED_COPY[3]); |
| 131 | VERBOSE_RAW(" R8: 0x%08x\n", ctx->CALLEE_SAVED_COPY[4]); |
| 132 | VERBOSE_RAW(" R9: 0x%08x\n", ctx->CALLEE_SAVED_COPY[5]); |
| 133 | VERBOSE_RAW(" R10: 0x%08x\n", ctx->CALLEE_SAVED_COPY[6]); |
| 134 | VERBOSE_RAW(" R11: 0x%08x\n", ctx->CALLEE_SAVED_COPY[7]); |
Joakim Andersson | dbdcfa0 | 2023-11-14 14:49:26 +0100 | [diff] [blame] | 135 | |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 136 | #ifdef FAULT_STATUS_PRESENT |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 137 | VERBOSE_RAW(" CFSR: 0x%08x\n", ctx->CFSR); |
| 138 | VERBOSE_RAW(" BFSR: ", |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 139 | (ctx->CFSR & SCB_CFSR_BUSFAULTSR_Msk) >> SCB_CFSR_BUSFAULTSR_Pos); |
| 140 | if (ctx->BFARVALID) { |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 141 | VERBOSE_RAW(" BFAR: 0x%08x\n", ctx->BFAR); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 142 | } else { |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 143 | VERBOSE_RAW(" BFAR: Not Valid\n"); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 144 | } |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 145 | VERBOSE_RAW(" MMFSR: ", |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 146 | (ctx->CFSR & SCB_CFSR_MEMFAULTSR_Msk) >> SCB_CFSR_MEMFAULTSR_Pos); |
| 147 | if (ctx->MMARVALID) { |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 148 | VERBOSE_RAW(" MMFAR: 0x%08x\n", ctx->MMFAR); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 149 | } else { |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 150 | VERBOSE_RAW(" MMFAR: Not Valid\n"); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 151 | } |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 152 | VERBOSE_RAW(" UFSR: 0x%08x\n", |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 153 | (ctx->CFSR & SCB_CFSR_USGFAULTSR_Msk) >> SCB_CFSR_USGFAULTSR_Pos); |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 154 | VERBOSE_RAW(" HFSR: 0x%08x\n", ctx->HFSR); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 155 | #ifdef TRUSTZONE_PRESENT |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 156 | VERBOSE_RAW(" SFSR: 0x%08x\n", ctx->SFSR); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 157 | if (ctx->SFARVALID) { |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 158 | VERBOSE_RAW(" SFAR: 0x%08x\n", ctx->SFAR); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 159 | } else { |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 160 | VERBOSE_RAW(" SFAR: Not Valid\n"); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 161 | } |
| 162 | #endif |
| 163 | |
| 164 | #endif |
| 165 | } |
| 166 | |
Joakim Andersson | 90e0c06 | 2023-11-13 13:48:08 +0100 | [diff] [blame] | 167 | static void dump_error(const struct exception_info_t *ctx) |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 168 | { |
| 169 | bool stack_error = false; |
| 170 | |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 171 | ERROR_RAW("FATAL ERROR: "); |
Joakim Andersson | 90e0c06 | 2023-11-13 13:48:08 +0100 | [diff] [blame] | 172 | switch (ctx->VECTACTIVE) { |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 173 | case EXCEPTION_TYPE_HARDFAULT: |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 174 | ERROR_RAW("HardFault\n"); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 175 | break; |
Joakim Andersson | 90e0c06 | 2023-11-13 13:48:08 +0100 | [diff] [blame] | 176 | #ifdef FAULT_STATUS_PRESENT |
| 177 | case EXCEPTION_TYPE_MEMMANAGEFAULT: |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 178 | ERROR_RAW("MemManage fault\n"); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 179 | stack_error = true; |
| 180 | break; |
| 181 | case EXCEPTION_TYPE_BUSFAULT: |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 182 | ERROR_RAW("BusFault\n"); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 183 | stack_error = true; |
| 184 | break; |
| 185 | case EXCEPTION_TYPE_USAGEFAULT: |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 186 | ERROR_RAW("UsageFault\n"); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 187 | stack_error = true; |
| 188 | break; |
Joakim Andersson | 90e0c06 | 2023-11-13 13:48:08 +0100 | [diff] [blame] | 189 | #ifdef TRUSTZONE_PRESENT |
| 190 | case EXCEPTION_TYPE_SECUREFAULT: |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 191 | ERROR_RAW("SecureFault\n"); |
Joakim Andersson | 90e0c06 | 2023-11-13 13:48:08 +0100 | [diff] [blame] | 192 | break; |
| 193 | #endif |
| 194 | #endif |
| 195 | /* Platform specific external interrupt secure handler. */ |
| 196 | default: |
| 197 | if (ctx->VECTACTIVE < 16) { |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 198 | ERROR_RAW("Reserved Exception 0x%08x\n", ctx->VECTACTIVE); |
Joakim Andersson | 90e0c06 | 2023-11-13 13:48:08 +0100 | [diff] [blame] | 199 | } else { |
Jackson Cooper-Driver | af54602 | 2025-03-13 15:14:27 +0000 | [diff] [blame^] | 200 | ERROR_RAW("Platform external interrupt (IRQn): 0x%08x\n", ctx->VECTACTIVE - 16); |
Joakim Andersson | 90e0c06 | 2023-11-13 13:48:08 +0100 | [diff] [blame] | 201 | } |
Joakim Andersson | a4066d8 | 2022-04-06 16:32:09 +0200 | [diff] [blame] | 202 | /* Depends on the platform, assume it may cause stack error */ |
| 203 | stack_error = true; |
| 204 | break; |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 205 | } |
Joakim Andersson | a4066d8 | 2022-04-06 16:32:09 +0200 | [diff] [blame] | 206 | |
Joakim Andersson | 90e0c06 | 2023-11-13 13:48:08 +0100 | [diff] [blame] | 207 | dump_exception_info(stack_error, ctx); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 208 | } |
| 209 | |
Chris Coleman | 9dd58c9 | 2023-10-08 13:49:23 -0400 | [diff] [blame] | 210 | void tfm_exception_info_get_context(struct exception_info_t *ctx) |
| 211 | { |
| 212 | memcpy(ctx, &exception_info, sizeof(exception_info)); |
| 213 | } |
| 214 | |
Joakim Andersson | dbdcfa0 | 2023-11-14 14:49:26 +0100 | [diff] [blame] | 215 | void store_and_dump_context(uint32_t MSP_in, uint32_t PSP_in, uint32_t LR_in, |
| 216 | uint32_t *callee_saved) |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 217 | { |
| 218 | struct exception_info_t *ctx = &exception_info; |
| 219 | |
Joakim Andersson | 90e0c06 | 2023-11-13 13:48:08 +0100 | [diff] [blame] | 220 | ctx->VECTACTIVE = SCB->ICSR & SCB_ICSR_VECTACTIVE_Msk; |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 221 | ctx->xPSR = __get_xPSR(); |
| 222 | ctx->EXC_RETURN = LR_in; |
| 223 | ctx->MSP = MSP_in; |
| 224 | ctx->PSP = PSP_in; |
| 225 | ctx->EXC_FRAME = get_exception_frame(ctx->EXC_RETURN, ctx->MSP, ctx->PSP); |
Ken Liu | b671d68 | 2022-05-12 20:39:29 +0800 | [diff] [blame] | 226 | memcpy(ctx->EXC_FRAME_COPY, ctx->EXC_FRAME, sizeof(ctx->EXC_FRAME_COPY)); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 227 | |
Joakim Andersson | dbdcfa0 | 2023-11-14 14:49:26 +0100 | [diff] [blame] | 228 | if (callee_saved) { |
| 229 | memcpy(ctx->CALLEE_SAVED_COPY, callee_saved, sizeof(ctx->CALLEE_SAVED_COPY)); |
| 230 | } |
| 231 | |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 232 | #ifdef FAULT_STATUS_PRESENT |
| 233 | ctx->CFSR = SCB->CFSR; |
| 234 | ctx->HFSR = SCB->HFSR; |
| 235 | ctx->BFAR = SCB->BFAR; |
| 236 | ctx->BFARVALID = ctx->CFSR & SCB_CFSR_BFARVALID_Msk; |
| 237 | ctx->MMFAR = SCB->MMFAR; |
| 238 | ctx->MMARVALID = ctx->CFSR & SCB_CFSR_MMARVALID_Msk; |
| 239 | SCB->CFSR = ctx->CFSR; /* Clear bits. CFSR is write-one-to-clear. */ |
| 240 | SCB->HFSR = ctx->HFSR; /* Clear bits. HFSR is write-one-to-clear. */ |
| 241 | #ifdef TRUSTZONE_PRESENT |
| 242 | ctx->SFSR = SAU->SFSR; |
| 243 | ctx->SFAR = SAU->SFAR; |
| 244 | ctx->SFARVALID = ctx->SFSR & SAU_SFSR_SFARVALID_Msk; |
| 245 | SAU->SFSR = ctx->SFSR; /* Clear bits. SFSR is write-one-to-clear. */ |
| 246 | #endif |
| 247 | #endif |
| 248 | |
Joakim Andersson | 90e0c06 | 2023-11-13 13:48:08 +0100 | [diff] [blame] | 249 | dump_error(ctx); |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 250 | } |