Summer Qin | 90602de | 2020-08-04 10:23:39 +0800 | [diff] [blame] | 1 | /* |
Summer Qin | dea1f2c | 2021-01-11 14:46:34 +0800 | [diff] [blame] | 2 | * Copyright (c) 2018-2021, Arm Limited. All rights reserved. |
Summer Qin | 90602de | 2020-08-04 10:23:39 +0800 | [diff] [blame] | 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | * |
| 6 | */ |
| 7 | |
Summer Qin | 9c1fba1 | 2020-08-12 15:49:12 +0800 | [diff] [blame] | 8 | #include "arch.h" |
Xinyu Zhang | 3a45324 | 2021-04-16 17:57:09 +0800 | [diff] [blame^] | 9 | #include "compiler_ext_defs.h" |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 10 | #include "exception_info.h" |
Summer Qin | 90602de | 2020-08-04 10:23:39 +0800 | [diff] [blame] | 11 | #include "tfm_secure_api.h" |
Summer Qin | 90602de | 2020-08-04 10:23:39 +0800 | [diff] [blame] | 12 | #include "tfm/tfm_spm_services.h" |
| 13 | |
TTornblom | 18b3bf0 | 2020-09-03 17:42:11 +0200 | [diff] [blame] | 14 | #if defined(__ICCARM__) |
Kevin Peng | 414523f | 2021-03-04 14:00:34 +0800 | [diff] [blame] | 15 | uint32_t tfm_core_svc_handler(uint32_t *msp, uint32_t *psp, uint32_t exc_return); |
Xinyu Zhang | 3a45324 | 2021-04-16 17:57:09 +0800 | [diff] [blame^] | 16 | #pragma required = tfm_core_svc_handler |
TTornblom | 18b3bf0 | 2020-09-03 17:42:11 +0200 | [diff] [blame] | 17 | #endif |
| 18 | |
Summer Qin | 90602de | 2020-08-04 10:23:39 +0800 | [diff] [blame] | 19 | nsfptr_t ns_entry; |
| 20 | |
| 21 | void jump_to_ns_code(void) |
| 22 | { |
| 23 | /* Calls the non-secure Reset_Handler to jump to the non-secure binary */ |
| 24 | ns_entry(); |
Ken Liu | 92e46a3 | 2020-07-25 22:58:00 +0800 | [diff] [blame] | 25 | |
| 26 | tfm_core_panic(); |
Summer Qin | 90602de | 2020-08-04 10:23:39 +0800 | [diff] [blame] | 27 | } |
| 28 | |
| 29 | __attribute__((naked)) |
| 30 | int32_t tfm_core_get_caller_client_id(int32_t *caller_client_id) |
| 31 | { |
| 32 | __ASM volatile( |
| 33 | "SVC %0\n" |
| 34 | "BX LR\n" |
| 35 | : : "I" (TFM_SVC_GET_CALLER_CLIENT_ID)); |
| 36 | } |
| 37 | |
| 38 | __attribute__((naked)) |
Mark Horvath | 4924cf8 | 2020-08-05 15:38:17 +0200 | [diff] [blame] | 39 | static int32_t tfm_spm_request(int32_t request_type) |
Summer Qin | 90602de | 2020-08-04 10:23:39 +0800 | [diff] [blame] | 40 | { |
| 41 | __ASM volatile( |
| 42 | "SVC %0\n" |
| 43 | "BX lr\n" |
| 44 | : : "I" (TFM_SVC_SPM_REQUEST)); |
| 45 | } |
| 46 | |
Summer Qin | 90602de | 2020-08-04 10:23:39 +0800 | [diff] [blame] | 47 | int32_t tfm_spm_request_reset_vote(void) |
| 48 | { |
Mark Horvath | 4924cf8 | 2020-08-05 15:38:17 +0200 | [diff] [blame] | 49 | return tfm_spm_request((int32_t)TFM_SPM_REQUEST_RESET_VOTE); |
Summer Qin | 90602de | 2020-08-04 10:23:39 +0800 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | __attribute__((naked)) |
| 53 | void tfm_enable_irq(psa_signal_t irq_signal) |
| 54 | { |
| 55 | __ASM("SVC %0\n" |
| 56 | "BX LR\n" |
| 57 | : : "I" (TFM_SVC_ENABLE_IRQ)); |
| 58 | } |
| 59 | |
| 60 | __attribute__((naked)) |
| 61 | void tfm_disable_irq(psa_signal_t irq_signal) |
| 62 | { |
| 63 | __ASM("SVC %0\n" |
| 64 | "BX LR\n" |
| 65 | : : "I" (TFM_SVC_DISABLE_IRQ)); |
| 66 | } |
| 67 | |
| 68 | __attribute__((naked)) |
| 69 | static psa_signal_t psa_wait_internal(psa_signal_t signal_mask, |
| 70 | uint32_t timeout) |
| 71 | { |
| 72 | __ASM("SVC %0\n" |
| 73 | "BX LR\n" |
| 74 | : : "I" (TFM_SVC_PSA_WAIT)); |
| 75 | } |
| 76 | |
| 77 | psa_signal_t psa_wait(psa_signal_t signal_mask, uint32_t timeout) |
| 78 | { |
| 79 | /* FIXME: By using the 'WFI' instruction this function blocks until an |
| 80 | * interrupt happens. It is necessary to do this here as tfm_core_psa_wait |
| 81 | * runs with the priority of the SVC, so it cannot be interrupted, so |
| 82 | * waiting in it for the required interrupt to happen is not an option. |
| 83 | */ |
| 84 | psa_signal_t actual_signal_mask; |
| 85 | |
| 86 | while (1) { |
| 87 | actual_signal_mask = psa_wait_internal(signal_mask, timeout); |
| 88 | if ((actual_signal_mask & signal_mask) != 0) { |
| 89 | return actual_signal_mask; |
| 90 | } |
| 91 | __WFI(); |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | __attribute__((naked)) |
| 96 | void psa_eoi(psa_signal_t irq_signal) |
| 97 | { |
| 98 | __ASM("SVC %0\n" |
| 99 | "BX LR\n" |
| 100 | : : "I" (TFM_SVC_PSA_EOI)); |
| 101 | } |
| 102 | |
| 103 | #if defined(__ARM_ARCH_8_1M_MAIN__) || defined(__ARM_ARCH_8M_MAIN__) |
Xinyu Zhang | 3a45324 | 2021-04-16 17:57:09 +0800 | [diff] [blame^] | 104 | __section("SFN") __naked |
Summer Qin | 90602de | 2020-08-04 10:23:39 +0800 | [diff] [blame] | 105 | int32_t tfm_core_sfn_request(const struct tfm_sfn_req_s *desc_ptr) |
| 106 | { |
| 107 | __ASM volatile( |
| 108 | "PUSH {r4-r12, lr} \n" |
| 109 | "SVC %[SVC_REQ] \n" |
| 110 | "MOV r4, #0 \n" |
| 111 | "MOV r5, r4 \n" |
| 112 | "MOV r6, r4 \n" |
| 113 | "MOV r7, r4 \n" |
| 114 | "MOV r8, r4 \n" |
| 115 | "MOV r9, r4 \n" |
| 116 | "MOV r10, r4 \n" |
| 117 | "MOV r11, r4 \n" |
| 118 | "BLX lr \n" |
| 119 | "SVC %[SVC_RET] \n" |
| 120 | "POP {r4-r12, pc} \n" |
| 121 | : : [SVC_REQ] "I" (TFM_SVC_SFN_REQUEST), |
| 122 | [SVC_RET] "I" (TFM_SVC_SFN_RETURN) |
| 123 | ); |
| 124 | } |
| 125 | |
Xinyu Zhang | 3a45324 | 2021-04-16 17:57:09 +0800 | [diff] [blame^] | 126 | __section("SFN") __naked |
Summer Qin | 90602de | 2020-08-04 10:23:39 +0800 | [diff] [blame] | 127 | void priv_irq_handler_main(uint32_t partition_id, uint32_t unpriv_handler, |
| 128 | uint32_t irq_signal, uint32_t irq_line) |
| 129 | { |
| 130 | __ASM( |
| 131 | /* Save the callee saved registers*/ |
| 132 | "PUSH {r4-r12, lr} \n" |
| 133 | /* Request SVC to configure environment for the unpriv IRQ handler */ |
| 134 | "SVC %[SVC_REQ] \n" |
| 135 | /* clear the callee saved registers to prevent information leak */ |
| 136 | "MOV r4, #0 \n" |
| 137 | "MOV r5, r4 \n" |
| 138 | "MOV r6, r4 \n" |
| 139 | "MOV r7, r4 \n" |
| 140 | "MOV r8, r4 \n" |
| 141 | "MOV r9, r4 \n" |
| 142 | "MOV r10, r4 \n" |
| 143 | "MOV r11, r4 \n" |
| 144 | /* Branch to the unprivileged handler */ |
| 145 | "BLX lr \n" |
| 146 | /* Request SVC to reconfigure the environment of the interrupted |
| 147 | * partition |
| 148 | */ |
| 149 | "SVC %[SVC_RET] \n" |
| 150 | /* restore callee saved registers and return */ |
| 151 | "POP {r4-r12, pc} \n" |
| 152 | : : [SVC_REQ] "I" (TFM_SVC_DEPRIV_REQ) |
| 153 | , [SVC_RET] "I" (TFM_SVC_DEPRIV_RET) |
| 154 | ); |
| 155 | } |
| 156 | #elif defined(__ARM_ARCH_8M_BASE__) |
Xinyu Zhang | 3a45324 | 2021-04-16 17:57:09 +0800 | [diff] [blame^] | 157 | __section("SFN") __naked |
Summer Qin | 90602de | 2020-08-04 10:23:39 +0800 | [diff] [blame] | 158 | int32_t tfm_core_sfn_request(const struct tfm_sfn_req_s *desc_ptr) |
| 159 | { |
| 160 | __ASM volatile( |
| 161 | "PUSH {lr} \n" |
| 162 | "PUSH {r4-r7} \n" |
| 163 | "MOV r4, r8 \n" |
| 164 | "MOV r5, r9 \n" |
| 165 | "MOV r6, r10 \n" |
| 166 | "MOV r7, r11 \n" |
| 167 | "PUSH {r4-r7} \n" |
| 168 | "MOV r4, r12 \n" |
| 169 | "PUSH {r4} \n" |
| 170 | "SVC %[SVC_REQ] \n" |
| 171 | "MOVS r4, #0 \n" |
| 172 | "MOV r5, r4 \n" |
| 173 | "MOV r6, r4 \n" |
| 174 | "MOV r7, r4 \n" |
| 175 | "MOV r8, r4 \n" |
| 176 | "MOV r9, r4 \n" |
| 177 | "MOV r10, r4 \n" |
| 178 | "MOV r11, r4 \n" |
| 179 | "BLX lr \n" |
| 180 | "SVC %[SVC_RET] \n" |
| 181 | "POP {r4} \n" |
| 182 | "MOV r12, r4 \n" |
| 183 | "POP {r4-r7} \n" |
| 184 | "MOV r8, r4 \n" |
| 185 | "MOV r9, r5 \n" |
| 186 | "MOV r10, r6 \n" |
| 187 | "MOV r11, r7 \n" |
| 188 | "POP {r4-r7} \n" |
| 189 | "POP {pc} \n" |
| 190 | : : [SVC_REQ] "I" (TFM_SVC_SFN_REQUEST), |
| 191 | [SVC_RET] "I" (TFM_SVC_SFN_RETURN) |
| 192 | ); |
| 193 | } |
| 194 | |
Xinyu Zhang | 3a45324 | 2021-04-16 17:57:09 +0800 | [diff] [blame^] | 195 | __section("SFN") __naked |
Summer Qin | 90602de | 2020-08-04 10:23:39 +0800 | [diff] [blame] | 196 | void priv_irq_handler_main(uint32_t partition_id, uint32_t unpriv_handler, |
| 197 | uint32_t irq_signal, uint32_t irq_line) |
| 198 | { |
| 199 | __ASM( |
| 200 | /* Save the callee saved registers*/ |
| 201 | "PUSH {r4-r7, lr} \n" |
| 202 | "MOV r4, r8 \n" |
| 203 | "MOV r5, r9 \n" |
| 204 | "MOV r6, r10 \n" |
| 205 | "MOV r7, r11 \n" |
| 206 | "PUSH {r4-r7} \n" |
| 207 | "MOV r4, r12 \n" |
| 208 | "PUSH {r4} \n" |
| 209 | /* Request SVC to configure environment for the unpriv IRQ handler */ |
| 210 | "SVC %[SVC_REQ] \n" |
| 211 | /* clear the callee saved registers to prevent information leak */ |
| 212 | "MOVS r4, #0 \n" |
| 213 | "MOV r5, r4 \n" |
| 214 | "MOV r6, r4 \n" |
| 215 | "MOV r7, r4 \n" |
| 216 | "MOV r8, r4 \n" |
| 217 | "MOV r9, r4 \n" |
| 218 | "MOV r10, r4 \n" |
| 219 | "MOV r11, r4 \n" |
| 220 | /* Branch to the unprivileged handler */ |
| 221 | "BLX lr \n" |
| 222 | /* Request SVC to reconfigure the environment of the interrupted |
| 223 | * partition |
| 224 | */ |
| 225 | "SVC %[SVC_RET] \n" |
| 226 | /* restore callee saved registers and return */ |
| 227 | "POP {r4} \n" |
| 228 | "MOV r12, r4 \n" |
| 229 | "POP {r4-r7} \n" |
| 230 | "MOV r8, r4 \n" |
| 231 | "MOV r9, r5 \n" |
| 232 | "MOV r10, r6 \n" |
| 233 | "MOV r11, r7 \n" |
| 234 | "POP {r4-r7, pc} \n" |
| 235 | : : [SVC_REQ] "I" (TFM_SVC_DEPRIV_REQ) |
| 236 | , [SVC_RET] "I" (TFM_SVC_DEPRIV_RET) |
| 237 | ); |
| 238 | } |
| 239 | #endif |
| 240 | |
| 241 | #if defined(__ARM_ARCH_8_1M_MAIN__) || \ |
| 242 | defined(__ARM_ARCH_8M_MAIN__) || defined(__ARM_ARCH_8M_BASE__) |
Ken Liu | 50e2109 | 2020-10-14 16:42:15 +0800 | [diff] [blame] | 243 | void tfm_arch_set_secure_exception_priorities(void) |
Summer Qin | 90602de | 2020-08-04 10:23:39 +0800 | [diff] [blame] | 244 | { |
| 245 | uint32_t VECTKEY; |
| 246 | SCB_Type *scb = SCB; |
| 247 | uint32_t AIRCR; |
| 248 | |
| 249 | /* Set PRIS flag in AIRCR */ |
| 250 | AIRCR = scb->AIRCR; |
| 251 | VECTKEY = (~AIRCR & SCB_AIRCR_VECTKEYSTAT_Msk); |
| 252 | scb->AIRCR = SCB_AIRCR_PRIS_Msk | |
| 253 | VECTKEY | |
| 254 | (AIRCR & ~SCB_AIRCR_VECTKEY_Msk); |
Summer Qin | 90602de | 2020-08-04 10:23:39 +0800 | [diff] [blame] | 255 | |
Ken Liu | 50e2109 | 2020-10-14 16:42:15 +0800 | [diff] [blame] | 256 | #ifndef __ARM_ARCH_8M_BASE__ |
Jamie Fox | 3ede971 | 2020-09-28 23:14:54 +0100 | [diff] [blame] | 257 | NVIC_SetPriority(MemoryManagement_IRQn, 0); |
| 258 | NVIC_SetPriority(BusFault_IRQn, 0); |
Jamie Fox | 3ede971 | 2020-09-28 23:14:54 +0100 | [diff] [blame] | 259 | NVIC_SetPriority(SecureFault_IRQn, 0); |
| 260 | #endif |
Ken Liu | 50e2109 | 2020-10-14 16:42:15 +0800 | [diff] [blame] | 261 | |
| 262 | /* |
| 263 | * Function based model needs no PendSV for scheduling, |
| 264 | * set its priority just higher than thread mode. |
| 265 | */ |
| 266 | NVIC_SetPriority(SVCall_IRQn, 0); |
| 267 | NVIC_SetPriority(PendSV_IRQn, (1 << __NVIC_PRIO_BITS) - 1); |
Jamie Fox | 3ede971 | 2020-09-28 23:14:54 +0100 | [diff] [blame] | 268 | } |
Ken Liu | 50e2109 | 2020-10-14 16:42:15 +0800 | [diff] [blame] | 269 | #else |
| 270 | #error Function based model works on V8M series only. |
| 271 | #endif |
Jamie Fox | 3ede971 | 2020-09-28 23:14:54 +0100 | [diff] [blame] | 272 | |
Summer Qin | dea1f2c | 2021-01-11 14:46:34 +0800 | [diff] [blame] | 273 | void tfm_arch_config_extensions(void) |
Jamie Fox | 4558767 | 2020-08-17 18:31:14 +0100 | [diff] [blame] | 274 | { |
Xinyu Zhang | 3a45324 | 2021-04-16 17:57:09 +0800 | [diff] [blame^] | 275 | #if defined(__FPU_PRESENT) && (__FPU_PRESENT == 1U) |
Jamie Fox | 4558767 | 2020-08-17 18:31:14 +0100 | [diff] [blame] | 276 | /* Configure Secure access to the FPU only if the secure image is being |
| 277 | * built with the FPU in use. This avoids introducing extra interrupt |
| 278 | * latency when the FPU is not used by the SPE. |
| 279 | */ |
Xinyu Zhang | 3a45324 | 2021-04-16 17:57:09 +0800 | [diff] [blame^] | 280 | #if defined(__FPU_USED) && (__FPU_USED == 1U) |
Jamie Fox | 4558767 | 2020-08-17 18:31:14 +0100 | [diff] [blame] | 281 | /* Enable Secure privileged and unprivilged access to the FP Extension */ |
| 282 | SCB->CPACR |= (3U << 10U*2U) /* enable CP10 full access */ |
| 283 | | (3U << 11U*2U); /* enable CP11 full access */ |
| 284 | |
| 285 | #if defined(__ARM_ARCH_8_1M_MAIN__) || defined(__ARM_ARCH_8M_MAIN__) |
| 286 | /* If the SPE will ever use the floating-point registers for sensitive data, |
| 287 | * then FPCCR.TS, FPCCR.CLRONRET and FPCCR.CLRONRETS must be set at |
| 288 | * initialisation and not changed again afterwards. |
| 289 | */ |
| 290 | FPU->FPCCR |= FPU_FPCCR_TS_Msk |
| 291 | | FPU_FPCCR_CLRONRET_Msk |
| 292 | | FPU_FPCCR_CLRONRETS_Msk; |
| 293 | #endif |
| 294 | #endif |
| 295 | |
| 296 | #if defined(__ARM_ARCH_8_1M_MAIN__) || defined(__ARM_ARCH_8M_MAIN__) |
| 297 | /* Permit Non-secure access to the Floating-point Extension. |
| 298 | * Note: It is still necessary to set CPACR_NS to enable the FP Extension in |
| 299 | * the NSPE. This configuration is left to NS privileged software. |
| 300 | */ |
| 301 | SCB->NSACR |= SCB_NSACR_CP10_Msk | SCB_NSACR_CP11_Msk; |
| 302 | #endif |
Summer Qin | dea1f2c | 2021-01-11 14:46:34 +0800 | [diff] [blame] | 303 | |
| 304 | #if defined(__ARM_ARCH_8_1M_MAIN__) |
| 305 | SCB->CCR |= SCB_CCR_TRD_Msk; |
| 306 | #endif |
Jamie Fox | 4558767 | 2020-08-17 18:31:14 +0100 | [diff] [blame] | 307 | #endif |
| 308 | } |
| 309 | |
Xinyu Zhang | 3a45324 | 2021-04-16 17:57:09 +0800 | [diff] [blame^] | 310 | #if defined(__ARM_ARCH_8M_BASE__) || \ |
| 311 | defined(__ARM_ARCH_8_1M_MAIN__) || \ |
| 312 | defined(__ARM_ARCH_8M_MAIN__) |
Summer Qin | 90602de | 2020-08-04 10:23:39 +0800 | [diff] [blame] | 313 | __attribute__((naked)) void SVC_Handler(void) |
| 314 | { |
| 315 | __ASM volatile( |
Ken Liu | e0af44c | 2020-07-25 22:51:30 +0800 | [diff] [blame] | 316 | #if !defined(__ICCARM__) |
| 317 | ".syntax unified \n" |
| 318 | #endif |
Kevin Peng | 414523f | 2021-03-04 14:00:34 +0800 | [diff] [blame] | 319 | "MRS r0, MSP \n" |
| 320 | "MOV r2, lr \n" |
| 321 | "MOVS r3, #8 \n" |
| 322 | "TST r2, r3 \n" |
Ken Liu | e0af44c | 2020-07-25 22:51:30 +0800 | [diff] [blame] | 323 | "BNE from_thread \n" |
| 324 | /* |
| 325 | * This branch is taken when the code is being invoked from handler mode. |
| 326 | * This happens when a de-privileged interrupt handler is to be run. Seal |
| 327 | * the stack before de-privileging. |
| 328 | */ |
Kevin Peng | 414523f | 2021-03-04 14:00:34 +0800 | [diff] [blame] | 329 | "LDR r1, =0xFEF5EDA5 \n" |
| 330 | "MOVS r3, r1 \n" |
| 331 | "PUSH {r1, r3} \n" |
Ken Liu | e0af44c | 2020-07-25 22:51:30 +0800 | [diff] [blame] | 332 | "from_thread: \n" |
Kevin Peng | 414523f | 2021-03-04 14:00:34 +0800 | [diff] [blame] | 333 | "MRS r1, PSP \n" |
Summer Qin | 90602de | 2020-08-04 10:23:39 +0800 | [diff] [blame] | 334 | "BL tfm_core_svc_handler \n" |
Kevin Peng | 414523f | 2021-03-04 14:00:34 +0800 | [diff] [blame] | 335 | "MOVS r1, #8 \n" |
Ken Liu | e0af44c | 2020-07-25 22:51:30 +0800 | [diff] [blame] | 336 | "TST r1, r0 \n" |
| 337 | "BNE to_thread \n" |
| 338 | /* |
| 339 | * This branch is taken when the code is going to return to handler mode. |
| 340 | * This happens after a de-privileged interrupt handler had been run. Pop |
| 341 | * the sealing from the stack. |
| 342 | */ |
| 343 | "POP {r1, r2} \n" |
| 344 | "to_thread: \n" |
Summer Qin | 90602de | 2020-08-04 10:23:39 +0800 | [diff] [blame] | 345 | "BX r0 \n" |
| 346 | ); |
| 347 | } |
| 348 | #elif defined(__ARM_ARCH_6M__) || defined(__ARM_ARCH_7M__) || \ |
| 349 | defined(__ARM_ARCH_7EM__) |
| 350 | __attribute__((naked)) void SVC_Handler(void) |
| 351 | { |
| 352 | __ASM volatile( |
Kevin Peng | 414523f | 2021-03-04 14:00:34 +0800 | [diff] [blame] | 353 | "MRS r0, MSP \n" |
| 354 | "MRS r1, PSP \n" |
| 355 | "MOV r2, lr \n" |
| 356 | "BL tfm_core_svc_handler \n" |
| 357 | "BX r0 \n" |
Summer Qin | 90602de | 2020-08-04 10:23:39 +0800 | [diff] [blame] | 358 | ); |
| 359 | } |
| 360 | #endif |
Jamie Fox | b78795a | 2020-09-28 20:39:06 +0100 | [diff] [blame] | 361 | |
| 362 | __attribute__((naked)) void HardFault_Handler(void) |
| 363 | { |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 364 | EXCEPTION_INFO(EXCEPTION_TYPE_HARDFAULT); |
| 365 | |
Jamie Fox | b78795a | 2020-09-28 20:39:06 +0100 | [diff] [blame] | 366 | /* A HardFault may indicate corruption of secure state, so it is essential |
| 367 | * that Non-secure code does not regain control after one is raised. |
| 368 | * Returning from this exception could allow a pending NS exception to be |
| 369 | * taken, so the current solution is not to return. |
| 370 | */ |
| 371 | __ASM volatile("b ."); |
| 372 | } |
| 373 | |
| 374 | __attribute__((naked)) void MemManage_Handler(void) |
| 375 | { |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 376 | EXCEPTION_INFO(EXCEPTION_TYPE_MEMFAULT); |
| 377 | |
Jamie Fox | b78795a | 2020-09-28 20:39:06 +0100 | [diff] [blame] | 378 | /* A MemManage fault may indicate corruption of secure state, so it is |
| 379 | * essential that Non-secure code does not regain control after one is |
| 380 | * raised. Returning from this exception could allow a pending NS exception |
| 381 | * to be taken, so the current solution is not to return. |
| 382 | */ |
| 383 | __ASM volatile("b ."); |
| 384 | } |
| 385 | |
| 386 | __attribute__((naked)) void BusFault_Handler(void) |
| 387 | { |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 388 | EXCEPTION_INFO(EXCEPTION_TYPE_BUSFAULT); |
| 389 | |
Jamie Fox | b78795a | 2020-09-28 20:39:06 +0100 | [diff] [blame] | 390 | /* A BusFault may indicate corruption of secure state, so it is essential |
| 391 | * that Non-secure code does not regain control after one is raised. |
| 392 | * Returning from this exception could allow a pending NS exception to be |
| 393 | * taken, so the current solution is not to return. |
| 394 | */ |
| 395 | __ASM volatile("b ."); |
| 396 | } |
| 397 | |
| 398 | __attribute__((naked)) void SecureFault_Handler(void) |
| 399 | { |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 400 | EXCEPTION_INFO(EXCEPTION_TYPE_SECUREFAULT); |
| 401 | |
Jamie Fox | b78795a | 2020-09-28 20:39:06 +0100 | [diff] [blame] | 402 | /* A SecureFault may indicate corruption of secure state, so it is essential |
| 403 | * that Non-secure code does not regain control after one is raised. |
| 404 | * Returning from this exception could allow a pending NS exception to be |
| 405 | * taken, so the current solution is not to return. |
| 406 | */ |
| 407 | __ASM volatile("b ."); |
| 408 | } |
Øyvind Rønningstad | f2c8dad | 2021-01-15 15:33:33 +0100 | [diff] [blame] | 409 | |
| 410 | __attribute__((naked)) void UsageFault_Handler(void) |
| 411 | { |
| 412 | EXCEPTION_INFO(EXCEPTION_TYPE_USAGEFAULT); |
| 413 | __ASM volatile("b ."); |
| 414 | } |