Skip to content

Commit 632954d

Browse files
committed
Add Tag_RISCV_cfi_encoding for CFI instruction interpretation
CFI extensions use NOP or MOP (Maybe Operation) instructions to ensure correct program execution even when hardware doesn't implement CFI. However, this design conflicts with current toolchain conventions, where X extension instructions are only usable when the X extension is enabled: assemblers accept corresponding mnemonics and disassemblers decode instructions only when the extension is active. The CFI use case requires different behavior: - Zicfiss instructions should be available when Zimop extension is present - Zicfilp instructions should be usable even without explicit enabling (since auipc is in baseline ISA) Following conventional toolchain behavior would force compilers to generate 'mop' instructions and 'auipc x0, <lpad-value>' instead of 'sspush/sspop' and 'lpad <lpad-value>', causing user confusion. While this could be addressed at the ISA specification level, such changes involve complex and time-consuming procedures. Therefore, this psABI defines Tag_RISCV_cfi_encoding to provide toolchain implementations with clear guidance. This tag indicates when instruction encodings should be reinterpreted for CFI extensions: Zimop encodings as Zicfiss instructions and 'auipc x0, <value>' as 'lpad <value>' (Zicfilp), regardless of whether these extensions are explicitly enabled.
1 parent 712449f commit 632954d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

riscv-elf.adoc

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,6 +1272,7 @@ non-standard ABI extensions.
12721272
| Tag_RISCV_priv_spec_revision | 12 | uleb128 | *Deprecated*, indicates the revision version of the privileged specification.
12731273
| Tag_RISCV_atomic_abi | 14 | uleb128 | Indicates which version of the atomics ABI is being used.
12741274
| Tag_RISCV_x3_reg_usage | 16 | uleb128 | Indicates the usage definition of the X3 register.
1275+
| Tag_RISCV_cfi_encoding | 18 | uleb128 | Indicates the reinterpretation of instruction encodings for CFI extensions.
12751276
| Reserved for non-standard attribute | >= 32768 | - | -
12761277
|===
12771278

@@ -1437,6 +1438,29 @@ value. After the merge, the resulting value will be the non-zero one.
14371438

14381439
--
14391440

1441+
===== Tag_RISCV_cfi_encoding, 18, uleb128=value
1442+
1443+
Tag_RISCV_cfi_encoding indicates the reinterpretation of instruction encodings for Control
1444+
Flow Integrity extensions within this object. This covers both Zicfiss instructions using
1445+
Zimop encoding space and Zicfilp instructions using baseline ISA encodings
1446+
(specifically `auipc x0, <value>` as `lpad <value>`).
1447+
1448+
[horizontal]
1449+
0:: This object's reinterpretation of instruction encodings for CFI extensions is unknown.
1450+
1:: This object contains instructions that must be interpreted according to Zicfiss/Zicfilp CFI extensions.
1451+
1452+
--
1453+
1454+
Merge policy:::
1455+
Value `0` can merge with any value, and the result will be the non-zero value.
1456+
Non-zero values merged with any unequal non-zero value will report an error.
1457+
1458+
--
1459+
1460+
NOTE: When this attribute is set to 1, toolchains must disassemble instructions according
1461+
to CFI extensions: Zimop encodings as Zicfiss instructions and `auipc x0, <value>` as
1462+
`lpad <value>` (Zicfilp), regardless of whether these extensions are enabled.
1463+
14401464
=== Program Property
14411465

14421466
Program properties are used to record information about an object file or binary

0 commit comments

Comments
 (0)