[BUG] [ARC SEM] Memory Read Protection Violation from Secure MPU on exit from interrupt
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 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時間
- マージ済み PR(30日)
- 4
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- 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 1週間以上 初心者へのやさしさ 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
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
shinyquagsire23/OpenJKDF2#540 ·
メンテナーはふだん 12 日以内に返信
-
Prison work hall: laundry and kitchen stations stand at bare walls, the hatch has no counter or signオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
Life-Framework/Life-Framework#5939 ·
メンテナーはふだん 1 日以内に返信
-
autoconf failes to find libsodium even when present due to implicit function declaration対応中かも @coderjoe が今日担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 13 日以内に返信
-
Bug Status: Needs Triage
難易度 1/5 1時間未満 初心者へのやさしさ 74/100
メンテナーはふだん 1 日以内に返信
-
bug python
難易度 2/5 1〜3時間 初心者へのやさしさ 87/100
Jstar269/nakagawa-recomp#3521 ·
メンテナーはふだん 1 日以内に返信