`misa` reports U-mode support, but `mret` with `mstatus.MPP=00` does not enter U-mode
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 22/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 領域
- embedded-iot
調査の方向性
Start from the CSR/trap logic that implements mret and the fixed misa image the report cites, then check how mstatus.MPP writes are masked. Reproduce by running the attached mret-to-u.zip ELF on rtlsim at XLEN=32 and reading mcause/mepc/mstatus. Read docs/designs/trap_and_exception_foundation.md for the intended privilege model. Done means either misa.U reads 0 with MPP restricted to 11, or mret with MPP=00 enters U-mode and the ecall reports cause 8, plus a test.
索引モデルが issue の本文から書いたものです。
説明
Description
On rtlsim at XLEN=32 (commit 1061088aa), misa reads 0x40901120: MXL=1 in the top two bits and I (bit 8), M (bit 12), F (bit 5), X (bit 23), U (bit 20) in the standard field. The U bit comes from the fixed misa image, not from a configuration knob.
The attached ELF returns mstatus.MPP to U-mode and then traps:
8000001c: 30200073 mret # mstatus.MPP was written as 00
80000020: 00000073 ecall # executed with MPP=00 in effect
80000024: 34202473 csrr s0, mcause # s0 = 0x0000000b (11, environment call from M-mode)
80000028: 341024f3 csrr s1, mepc # s1 = 0x80000020
8000002c: 30002973 csrr s2, mstatus # s2 = 0x00000000
mepc and mstatus hold what software programmed; the mode change the mret asked for does not happen, and the exception is attributed to machine mode. That is the correct cause only if the core never left M-mode.
As specified in the RISC-V Privileged ISA, misa:
The U bit indicates whether user mode is supported.
and in "Privilege and Global Interrupt-Enable Stack in mstatus":
When executing an xRET instruction, supposing xPP holds the value y, xIE is set to xPIE; the privilege mode is changed to y; xPIE is set to 1; and xPP is set to the least-privileged supported mode (U if U-mode is implemented, else M).
So misa reports U-mode as implemented, which would require mret with MPP=00 to enter it, while the core behaves as if it is not implemented, which would require MPP=00 not to be accepted at all. Both cannot hold at the same time.
The attached ELF is as follows:
Expect Behavior
Either misa.U reads 0, in which case mstatus.MPP would be WARL with 11 as its only legal value and cause 11 would be the correct result for the ecall; or U-mode is supported, in which case mret should enter U-mode when MPP=00 and the ecall should report cause 8.
I could not tell which of the two is intended. If machine-only operation is the intent, would clearing misa.U, or noting the limitation in docs/designs/trap_and_exception_foundation.md, be acceptable? Happy to adjust this report if I have misread either side.
- 主要言語
- Verilog
- スター
- 2.4k
- フォーク
- 563
- 平均マージ
- 2日 12時間
- マージ済み PR(30日)
- 33
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
vortexgpgpu/vortex のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
vortexgpgpu/vortex#501 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
vortexgpgpu/vortex#499 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 28/100
vortexgpgpu/vortex#504 ·
メンテナーはふだん 1 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 22/100
vortexgpgpu/vortex#503 ·
メンテナーはふだん 1 日以内に返信
-
難易度 4/5 3〜5日 初心者へのやさしさ 55/100
vortexgpgpu/vortex#500 ·
メンテナーはふだん 1 日以内に返信
vortexgpgpu/vortex の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 61/100
-
mass-storage-gadget64: eMMC is exported as removable media, so Windows cannot write a GPT imageオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
raspberrypi/usbboot#419 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
bug triage
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
crosspoint-reader/crosspoint-reader#4595 · コメント 4 件 ·
メンテナーはふだん 1 日以内に返信