SmpCluster: add mstatush, required by OpenSBI >= 1.6 on RV32 - #480
Conversation
SpinalHDL#468 added MstatushPlugin but nothing instantiates it, so every SMP cluster still lacks CSR 0x310. RV32 OpenSBI 1.6 and later clear MSTATUSH_MDT unconditionally in the trap entry and restore paths -- CLEAR_MDT in firmware/fw_base.S, which expands to `csrc CSR_MSTATUSH, t0` with no runtime guard. On a core without the CSR the first trap takes an illegal instruction exception inside the trap handler, before a console exists to report it. That is what keeps linux-on-litex-vexriscv pinned to the litex-hub OpenSBI fork at 1.3.1. Gated on a parameter defaulting to true and added the way FpuPlugin is, so an existing configuration can opt out. readOnly = false so the write is accepted and discarded: readOnly = true happens to tolerate the csrc OpenSBI uses, because csrc asserts CSR_READ_OPCODE, but a csrw to the same CSR would still trap, which is too fragile a distinction to depend on. Verified by generating a cluster netlist and testing for the CSR decode: the plugin registers an anonymous U(0, 32 bits), so no signal carries the name and `grep mstatush` gives a false negative -- `grep -c "12'h310"` is the test.
|
Thanks ^^ |
|
Are you sure about the readOnly = false ? |
|
I'm pretty sure it is correct. The spec says it's a read/write register:
and the address encoding also implies read/write: bits [11:10] of 0x310 are 00. Also, OpenSBI writes to https://github.com/riscv-software-src/opensbi/blob/master/lib/sbi/sbi_hart.c#L87 As I understand it, feature detection works by writing to the register and then checking that the value holds. The plugin discards the written value, and every field reads back zero, which is the correct answer for MBE/SBE (VexRiscv is little-endian), MPV/GVA (no H) and MDT/MPELP (no Smdbltrp/Zicfilp). I'm happy to take your steer though. Would you prefer it selectable through a parameter? |
|
Hey @Dolu1990, I just noticed a slight subtlety with this. pythondata-cpu-vexriscv-smp is currently pointed at the What's your approach here? Do you periodically merge Thanks loads for your help. |
|
Hey @Dolu1990 did you have an opinion on the above? I've got some time this weekend and will be more than happy to make any changes you'd like! |
Ahhh yes you are right ^^ |
|
Hi ^^
Yes that is the normal flow.
Yes normaly, but that is not too bad ^^
Do not hesitate to ping when i'm so unreactive XD |
#468 added MstatushPlugin but nothing instantiates it, so every SMP cluster still lacks CSR 0x310.
RV32 OpenSBI 1.6 and later clear MSTATUSH_MDT unconditionally in the trap entry and restore paths. CLEAR_MDT in firmware/fw_base.S, which expands to
csrc CSR_MSTATUSH, t0with no runtime guard. On a core without the CSR the first trap takes an illegal instruction exception inside the trap handler, before a console exists to report it. That is what keeps linux-on-litex-vexriscv pinned to the litex-hub OpenSBI fork at 1.3.1.Verified by generating a cluster netlist and testing for the CSR decode: the plugin registers an anonymous U(0, 32 bits), so no signal carries the name and
grep mstatushgives a false negative --grep -c "12'h310"is the test.