Skip to content

Commit 65f35a2

Browse files
Minor update to ARM_FaultSave function (#74)
- fixed R4 .. R7 restoring for TrustZone device if additional state context was saved
1 parent d1b8295 commit 65f35a2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Fault/Source/ARM_FaultStorage.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -571,10 +571,11 @@ __NAKED void ARM_FaultSave (void) {
571571

572572
/* If additional state information is available then clear the R4 .. R7 */
573573
#if (ARM_FAULT_ARCH_ARMV8x_M != 0) // If arch is Armv8/8.1-M
574-
"ldrh r0, [r4,%[Content_ofs]]\n" // Load Content value
574+
"ldr r0, =%c[Content_addr]\n" // Load Content address
575+
"ldrh r0, [r0]\n" // Load Content value
575576
"movs r1, %[AdditionalContext_bit]\n" // Load AdditionalContext bit
576577
"ands r0, r1\n" // AND Content with AdditionalContext bit to determine if additional state context was saved
577-
"bne restore_regs_done\n" // If additional state context was not saved, do not clear R4 .. R7 and exit section
578+
"beq restore_regs_done\n" // If additional state context was not saved, do not clear R4 .. R7 and exit section
578579
"movs r4, #0\n" // Else if additional state context was saved, clear R4 .. R7
579580
"movs r5, #0\n"
580581
"movs r6, #0\n"
@@ -593,7 +594,7 @@ __NAKED void ARM_FaultSave (void) {
593594
, [MagicNumber_ofs] "i" (offsetof(ARM_FaultInfo_t, MagicNumber))
594595
, [MagicNumber_val] "i" (ARM_FAULT_MAGIC_NUMBER)
595596
, [CRC32_ofs] "i" (offsetof(ARM_FaultInfo_t, CRC32))
596-
, [Content_ofs] "i" (offsetof(ARM_FaultInfo_t, Content))
597+
, [Content_addr] "i" (&ARM_FaultInfo.Content)
597598
, [AdditionalContext_bit] "i" (1U << 6)
598599
, [R4_addr] "i" (&ARM_FaultInfo.Registers.R4)
599600
, [crc_init_val] "i" (ARM_FAULT_CRC32_INIT_VAL)

0 commit comments

Comments
 (0)