#RISCV "Wait for Interrupt instruction (WFI) provides a hint to the implementation that the current hart can be stalled until an interrupt ... so a legal implementation is to simply implement WFI as a NOP" 🤔
Source: https://github.com/riscv/riscv-isa-manual/releases/download/Priv-v1.12/riscv-privileged-20211203.pdf
@exa I have some code that assumes WFI will loop forever. I suppose that's incorrect 🤔
@lupyuen if by "loop forever" you mean "the hart isn't going to execute past the WFI instruction", then yeah that code might be wrong
@exa Cool thanks! :-)
@lupyuen anyway I guess fixing this with 1 extra instruction that loops forever over the WFI is quite valid. I assume your interrupt handler will be able to jump over that, right?
@lupyuen Yes this is legal, just not green.
@icenowy Yep thanks! I just realised that Linux Boot Code uses WFI + Loop together: https://github.com/torvalds/linux/blob/f6cef5f8c37f58a3bc95b3754c3ae98e086631ca/arch/riscv/kernel/head.S#L185-L188
@lupyuen Too bad they didn't call it "May Wait For Interrupt" (MWFI). :/
@lupyuen Wait For Interrupt would be a conditional NOP wouldn't it? Perhaps it's fine, but it just seems wrong to use it like that. Not wrong as in it won't work but wrong as in it works and that's fine.
@lupyuen ...what's wrong with that?