Home/Instructions/SFENCE-INVAL-IR
SFENCE.INVAL.IR

RISC-V SFENCE.INVAL.IR Instruction Details

Instruction ManualR-type

Svinval ordering instruction: orders prior SINVAL/HINVAL invalidations before subsequent implicit page-table references.

Instruction Syntax

sfence.inval.ir
Operand Breakdown
Destination rd: register receiving the operation result.
Source rs1: register holding the first operand.
Source rs2: register holding the second operand.
PrivilegedSvinvalMemory Management

Instruction Behavior

SFENCE.INVAL.IR is a Svinval ordering instruction with no architectural operands. It guarantees that prior SINVAL.VMA, HINVAL.VVMA, or HINVAL.GVMA invalidations by the current hart are ordered before subsequent implicit references by that hart to memory-management data structures. The typical sequence is SFENCE.W.INVAL -> a series of SINVAL/HINVAL instructions -> SFENCE.INVAL.IR.

Quick Understanding & Search Notes

SFENCE.INVAL.IR is a system-level instruction defined by the privileged architecture. This page covers architectural semantics only, not platform firmware policy.

The instruction affects address translation or invalidation ordering; it is not a generic data-cache flush.
Executing at an unsupported privilege level or without the required extension raises the specified exception.

Common Usage Scenarios

Memory Management

Understand this scenario with real code like «sfence.inval.ir».

Translation Invalidation

Understand this scenario with real code like «sfence.inval.ir».

TLB Shootdown

Understand this scenario with real code like «sfence.inval.ir».

Pre-Use Checklist

Syntax Check
  • Confirm the current instruction format is R-type.
  • Confirm the operand order matches the example.
Semantic Check
  • Ensure the destination register usage is compatible with the calling convention.
  • Confirm this is not the lower-level form of a pseudo-instruction expansion.

Pitfalls / Common Confusions

U-mode execution raises illegal-instruction; VU-mode execution raises virtual-instruction.
Unaffected by mstatus.TVM and hstatus.VTVM; permitted in S-mode and VS-mode.
Orders prior SINVAL/HINVAL invalidations before subsequent implicit page-table references.

FAQ

Is it a normal user-mode instruction?

No. These instructions are constrained by privilege level and extension support; user-mode legality must follow the privileged rules.

Does it replace ordinary memory fences?

No. Address translation, instruction fetch, and data-memory ordering use different fence/invalidation instructions.