[BUG] [ARC SEM] Memory Read Protection Violation from Secure MPU on exit from interrupt
维护者通常 3 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 18/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- c
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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
- 主要语言
- C
- 星标
- 4.6k
- 派生
- 1.6k
- 平均合并
- 2 天 22 小时
- 30 天内合并 PR
- 4
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
FreeRTOS/FreeRTOS-Kernel 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
FreeRTOS/FreeRTOS-Kernel#1542 ·
维护者通常 3 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
FreeRTOS/FreeRTOS-Kernel#1520 ·
维护者通常 3 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 62/100
FreeRTOS/FreeRTOS-Kernel#1494 · 3 条评论 ·
维护者通常 3 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 25/100
FreeRTOS/FreeRTOS-Kernel#1554 ·
维护者通常 3 天内回复
-
[BUG] event_wait_timed can't return false可能已有人在做 @TedLyngmo 于 39 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 38/100
FreeRTOS/FreeRTOS-Kernel#1546 ·
维护者通常 3 天内回复
查看 FreeRTOS/FreeRTOS-Kernel 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 72/100
-
bug
难度 1/5 1 小时以内 新手友好度 63/100
FreeRTOS/FreeRTOS-Plus-TCP#1395 ·
-
难度 2/5 1-3 小时 新手友好度 72/100
qoretechnologies/qore#8222 ·
维护者通常 1 天内回复
-
c easy first-contributor first-contributors good first issue help wanted up-for-grabs
难度 1/5 1-3 小时 新手友好度 96/100
fork-commit-merge/fork-commit-merge#8696 ·
维护者通常 1 天内回复