microsoft / cheriot-ibex

cheriot-ibex is a RTL implementation of CHERIoT ISA based on LowRISC's Ibex core.
Apache License 2.0
73 stars 14 forks source link

WFI should be illegal in User mode #37

Closed mndstrmr closed 1 month ago

mndstrmr commented 4 months ago

According to the Sail, WFI should be illegal when invoked in user mode:

https://github.com/CHERIoT-Platform/sail-riscv/blob/cf541bea6be2d612c9bc91af032ab277a3756512/model/riscv_insts_base.sail#L764-L771

Currently the controller has this: https://github.com/microsoft/cheriot-ibex/blob/4a739b4f4bcf0324633ba4d7a0286fa6dfd9a04f/rtl/ibex_controller.sv#L235-L237

The csr_mstatus_tw_i would be necessary for supervisor mode (which is not implemented), but is not for user mode.

marnovandermaas commented 4 months ago

From my reading of the privileged spec, TW also applies in user mode: image

If you agree this issue should be opened on the Sail repository.

kliuMsft commented 3 months ago

@rmn30 , do you know whether we differ with the upstream sail over how to handle WFI and TW bit?

rmn30 commented 1 month ago

Looks like upstream sail-riscv is exactly the same so should probably file an issue there. Of course doesn't make any difference to CHERIoT since there is no User mode. Do we make mstatus.TW read only?

mndstrmr commented 1 month ago

Since I am now using a modified version of the specification which fixes this issue, this proves, so I will close this for now.