[BUG] [ARC SEM] Memory Read Protection Violation from Secure MPU on exit from interrupt
Les mainteneurs répondent en général sous 3 jours
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 18/100
- Type d'issue
- Bug
- Clarté
- Plutôt claire
- Activité
- À l'abandon
- Stack technique
- c
- Domaine
- embedded-iot, operating-systems
Piste de recherche
Start in portable/ThirdParty/GCC/ARC_EM_HS/arc_support.s, around the bl dispatcher call (line 207) and the rtie at line 519, and compare with the interrupt entry/exit macros the reporter cites from embarc_bsp's arc_asm_common.h. The fix must keep SEC_STAT.IRM set across interrupt return, which needs ARC secure-mode knowledge and ARC SEM hardware to verify. Done means that returning from an interrupt after a context switch no longer raises the Secure MPU read violation.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
What I observe is that in some circumstances (it started appearing after enabling few more interrupts and threads) CPU ends up catching Memory Read Protection Violation from Secure MPU exception on exit from interrupt in arc_support.s
portable/ThirdParty/GCC/ARC_EM_HS/arc_support.s
519: rtie
Contents of some debug registers once in the exception handler:
EFA: 0x00000000
ECR: 0x00060124
MPU_ECR (0x420) = 0x605FF, meaning below:
- bits 31:16 -> EC_CODE = 0x6 -> vector number of the EV_ProtV exception
- bits 15:12 reserved
- bits 11:10 -> SEC = 0x01 -> Secure violation has occurred; secure resources are being accessed in the normal mode
- bits 9:8 -> VT = 0x01 -> Data Read Violation
- bits 7:0 -> MR = 0xFF -> Access missed all regions
Debugging with gdb reveals that SEC_STAT.IRM bit is being reset to 0 after call to dispatcher from interrupt context
portable/ThirdParty/GCC/ARC_EM_HS/arc_support.s
207: bl dispatcher /* r0->pxCurrentTCB */
After IRM is set to 0, the exit from interrupt (RTIE instruction) results in mode switch from secure kernel to normal kernel mode. In my case all memory is marked in MPU as “secure” so this results in CPU exception.
I can see that a similar sounding bug was raised for Zephyr and fixed:
https://github.com/zephyrproject-rtos/zephyr/issues/18725
I tried applying a similar fix for FreeRTOS and the following changes in interrupt entry/exit macros resolve my issue:
arc_asm_common.h from https://github.com/foss-for-synopsys-dwc-arc-processors/embarc_bsp/blob/topic-freertos-demo/include/arc/v2/arc_asm_common.h
--- arc_asm_common.h
+++ arc_asm_common.h
@@ -516,6 +516,9 @@ PUSH gp
PUSH fp
PUSH ilink
PUSH r30
+lr r3, [0x09] /* store SEC_STAT.IRM */
+and r3, r3, 0x8
+PUSH r3
[…]
.macro INTERRUPT_EPILOGUE
add sp, sp, 4 /* skip bta */
+POP r3 /* restore SEC_STAT.IRM */
+sflag r3
POP r30
POP ilink
POP fp
Please note this is simplified fix as the IRM is stored/restored on interrupt entry/exit. I suspect that proper fix would do that on task context store/restore.
Compiler: Synopsys ARC GCC 2020.03, but it seems irrelevant
Platform: Synopsys ARC SEM
- Langage dominant
- C
- Étoiles
- 4.6k
- Forks
- 1.6k
- Merge moyen
- 2 j 22 h
- PR mergées (30 j)
- 4
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de FreeRTOS/FreeRTOS-Kernel
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
FreeRTOS/FreeRTOS-Kernel#1542 ·
Les mainteneurs répondent en général sous 3 jours
-
[BUG] Release asset FreeRTOS-KernelV11.3.2.zip has the files of main, not of the tag V11.3.2Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
FreeRTOS/FreeRTOS-Kernel#1520 ·
Les mainteneurs répondent en général sous 3 jours
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
FreeRTOS/FreeRTOS-Kernel#1494 · 3 commentaires ·
Les mainteneurs répondent en général sous 3 jours
-
enhancement
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 25/100
FreeRTOS/FreeRTOS-Kernel#1554 ·
Les mainteneurs répondent en général sous 3 jours
-
[BUG] event_wait_timed can't return falsePeut-être pris @TedLyngmo l’a pris il y a 39 jours. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 38/100
FreeRTOS/FreeRTOS-Kernel#1546 ·
Les mainteneurs répondent en général sous 3 jours
Toutes les issues de FreeRTOS/FreeRTOS-Kernel
Issues similaires
-
RecompLauncher supportOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
shinyquagsire23/OpenJKDF2#540 ·
Les mainteneurs répondent en général sous 12 jours
-
Prison work hall: laundry and kitchen stations stand at bare walls, the hatch has no counter or signOuverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Life-Framework/Life-Framework#5939 ·
Les mainteneurs répondent en général sous 1 jour
-
autoconf failes to find libsodium even when present due to implicit function declarationPeut-être pris @coderjoe l’a pris aujourd’hui. Ouvertebug
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 13 jours
-
SessionInterfaceHandler is throwing a deprecation notice as a warning instead of a deprecationOuverteBug Status: Needs Triage
Difficulté 1/5 Moins d'une heure Accessibilité débutants 74/100
Les mainteneurs répondent en général sous 1 jour
-
enhancement_package: a site operand of another JSON type raises TypeError, not a named refusalOuvertebug python
Difficulté 2/5 1-3 heures Accessibilité débutants 87/100
Jstar269/nakagawa-recomp#3521 ·
Les mainteneurs répondent en général sous 1 jour