Does WFI always put the processor into low-power sleep?
No. WFI is not a HINT instruction, but its official semantics still allow an implementation to stall or to legally continue as a NOP.
Wait-for-interrupt instruction: an implementation may stall the hart until an interrupt might need service, or legally avoid stalling and continue as a NOP.
WFI informs the implementation that the current hart may be stalled until an interrupt might need service. It is not a HINT instruction and does not provide a portable low-power guarantee: an implementation may avoid stalling and return as if WFI were a NOP. If a locally enabled interrupt is already pending or later becomes pending, WFI may resume and the corresponding interrupt trap is taken on a following instruction boundary. The privileged architecture also defines the mstatus.TW restriction for lower-privilege WFI execution: an implementation may raise an illegal-instruction exception after an implementation-specific bounded time, and may choose to trap immediately. When S-mode is implemented, U-mode WFI raises an illegal-instruction exception regardless of TW unless it completes within that implementation-specific bounded time.
Shows the fixed SYSTEM encoding, TW restriction, and ISA-visible WFI behavior: it may stall or may return as a NOP.
This animation does not promise sleep duration, power reduction, wake latency, or scheduling policy; those are not portable WFI ISA semantics.
WFI can wait for an interrupt but does not guarantee sleep. It is not a HINT instruction, has no explicit operands, and has a fixed encoding; execution may stall the hart or may immediately continue as a NOP. Portable software must recheck the wait condition after WFI returns.
Understand this scenario with real code like «wfi # Wait for interrupt».
Understand this scenario with real code like «wfi # Wait for interrupt».
No. WFI is not a HINT instruction, but its official semantics still allow an implementation to stall or to legally continue as a NOP.
Software should recheck its wait condition or pending state, because WFI may resume for any reason and resumption alone does not guarantee the intended event has been handled.