Skip to content

UPSTREAM PR #30501: riscv: Add lpad instructions for CFI support#678

Open
loci-dev wants to merge 2 commits into
mainfrom
loci/pr-30501-phoebe-rvv-cfi
Open

UPSTREAM PR #30501: riscv: Add lpad instructions for CFI support#678
loci-dev wants to merge 2 commits into
mainfrom
loci/pr-30501-phoebe-rvv-cfi

Conversation

@loci-dev
Copy link
Copy Markdown

Note

Source pull request: openssl/openssl#30501

Add 'lpad 0' (landing pad) instructions at the beginning of all RISC-V assembly functions to support Forward Control Flow Integrity (Zicfilp extension).

The lpad instruction is encoded as AUIPC x0, <lpl>, which is harmless on hardware without Zicfilp support (writes to zero register) and provides CFI protection on hardware with Zicfilp support.

The instruction encoding(0x00000017 | (lpl << 12))is directly emitted as .word, making it compatible with all toolchains.

Add 'lpad 0' (landing pad) instructions at the beginning of all
RISC-V assembly functions to support Forward Control Flow Integrity
(Zicfilp extension).

The lpad instruction is encoded as AUIPC x0, <lpl>, which is harmless
on hardware without Zicfilp support (writes to zero register) and
provides CFI protection on hardware with Zicfilp support.

The instruction encoding (0x00000017 | (lpl << 12)) is directly
emitted as .word, making it compatible with all toolchains.
Implement correct placement policy for lpad (landing pad) instructions
according to RISC-V Zicfilp specification:
- Add lpad ONLY to global symbols (exported functions)
- Remove lpad from local labels (internal jump targets)

Signed-off-by: Phoebe Chen <phoebe.chen@sifive.com>
@loci-dev loci-dev force-pushed the main branch 5 times, most recently from 421b135 to 770bf14 Compare April 28, 2026 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants