LPAD

RISC-V LPAD Instruction Details

Instruction ManualI-type

Zicfilp landing-pad instruction; validates indirect jump/call targets when forward-edge CFI is enabled.

Instruction Syntax

lpad label
Operand Breakdown
Destination rd: general-purpose register receiving the result.
Source rs1: register holding the first operand.
Immediate imm: 12-bit signed value, sign-extended before operation with rs1.
ZicfilpSecurity Mechanisms

Instruction Behavior

Beginner view: with forward-edge CFI enabled, indirect calls/jumps must land on LPAD or raise a software-check exception. LPAD can carry a 20-bit label; when Zicfilp is inactive it is compatible as a no-op.

Quick Understanding & Search Notes

LPAD belongs to the RISC-V Zicfilp forward-edge CFI instructions; behavior depends on whether Zicfilp is enabled and on environment configuration.

LPAD uses AUIPC HINT code points and has no architectural effect when inactive.
Do not mistake MOP compatibility for always-active security checks; inactive cases may degrade to no-op or zero-result behavior.

Common Usage Scenarios

Forward-edge CFI

Understand this scenario with real code like «lpad 0».

Indirect call/jump marking

Understand this scenario with real code like «lpad 0».

Security hardening

Understand this scenario with real code like «lpad 0».

Pre-Use Checklist

Syntax Check
  • Confirm the current instruction format is I-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

LPAD provides protection only when Zicfilp forward-edge CFI state is enabled; otherwise it acts as a no-op.
Trap behavior depends on privilege level, environment configuration CSRs, and page attributes.
LPAD targets require 4-byte alignment; a nonzero label must match the expected label in x7.
When Zicfilp is inactive LPAD is a no-op; when enabled with ELP=LP_EXPECTED it checks 4-byte alignment and label match.

FAQ

What happens if the related CFI feature is inactive for LPAD?

LPAD executes as a no-op.

What official rule defines LPAD?

The Control-Flow Integrity chapter of the RISC-V Unprivileged ISA defines LPAD, SSPUSH, SSPOPCHK, SSRDP, and SSAMOSWAP.