`misa` reports U-mode support, but `mret` with `mstatus.MPP=00` does not enter U-mode
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 22/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- embedded-iot
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Verilog
- Stars
- 2.4k
- Forks
- 563
- Avg merge
- 1d 7h
- Merged PRs (30d)
- 71
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from vortexgpgpu/vortex
-
RV64 signed DIV/REM restores the sign from bit 31Possibly taken @zzf2024 claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
vortexgpgpu/vortex#501 · 1 comment ·
Maintainers usually reply within 1 day
-
fpu: sign-extend RV64 FCVT.WU positive overflow resultsPossibly taken @zzf2024 claimed this 3 days ago. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
vortexgpgpu/vortex#499 · 1 comment ·
Maintainers usually reply within 1 day
-
WGMMA: the next kernel can compute with the previous kernel's B row left in the B buffer (rtlsim)Possibly taken @youzi27 claimed this 2 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
vortexgpgpu/vortex#558 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
vortexgpgpu/vortex#521 ·
Maintainers usually reply within 1 day
-
WGMMA: a block-major B tile can read K-major data left in the B buffer (rtlsim)Possibly taken @youzi27 claimed this 5 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 35/100
vortexgpgpu/vortex#518 ·
Maintainers usually reply within 1 day
All issues in vortexgpgpu/vortex
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
espressif/esp-iot-solution#856 ·
Maintainers usually reply within 1 day
-
Add keycodes for Voice Dictation (HUTRR99) and AI assistant consumer usages (HUTRR89, HUTRR119)Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
zmkfirmware/zmk#3573 ·
Maintainers usually reply within 4 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
protocomm: Security 2 nonce storage does not guarantee counter alignment (IDFGH-18841)Possibly taken @kPatch claimed this today. OpenStatus: Opened
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Maintainers usually reply within 1 day
-
Arch: ARM/AArch64 BSP BSP: GD32 bug Component component: drivers
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
RT-Thread/rt-thread#12109 · 3 comments ·
Maintainers usually reply within 2 days