[llvm] [LFI][Doc] Update documentation for planned features (PR #192128)

Nick Desaulniers via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 14 13:57:20 PDT 2026


================
@@ -60,29 +60,87 @@ These rewrites (also called "expansions") are applied at the very end of the
 LLVM compilation pipeline (during the assembler step). This allows the rewrites
 to be applied to hand-written assembly, including inline assembly.
 
+Context Register
+++++++++++++++++
+
+Both architectures designate a context register that points to a block of
+thread-local memory managed by the LFI runtime. The context register is ``x25``
+on AArch64 and ``r15`` on X86-64. The layout is as follows:
+
++--------+--------+----------------------------------------------+
+| Offset | Size   | Description                                  |
++--------+--------+----------------------------------------------+
+| 0      | 8      | Reserved for future use.                     |
++--------+--------+----------------------------------------------+
+| 8      | 8      | Reserved for use by the LFI runtime.         |
++--------+--------+----------------------------------------------+
+| 16     | 8      | Virtual thread pointer (used for TP access). |
++--------+--------+----------------------------------------------+
+
+Linker Support
+++++++++++++++
+
+In the initial version, LFI only supports static linking, and only supports
+creating ``static-pie`` binaries. There is nothing that fundamentally precludes
+support for dynamic linking on the LFI target, but such support would require
+that the code generated by the linker for PLT entries be slightly modified in
+order to conform to the LFI architecture subset.
+
+Assembler Directives
+++++++++++++++++++++
+
+The LFI assembler supports the following directives for controlling the
+rewriter.
+
+``.lfi_rewrite_disable``
+========================
+
+Disables LFI assembly rewrites for all subsequent instructions, until
+``.lfi_rewrite_enable`` is used. This can be useful for hand-written assembly
+that is already safe and should not be modified by the rewriter.
+
+``.lfi_rewrite_enable``
+=======================
+
+Re-enables LFI assembly rewrites after a previous ``.lfi_rewrite_disable``.
+
+Example:
+
+.. code-block:: gas
+
+  .lfi_rewrite_disable
+  // No rewrites applied here.
+  ldr x0, [x27, w1, uxtw]
+  .lfi_rewrite_enable
+
 Compiler Options
-================
+++++++++++++++++
 
 **Note**: these options are not yet implemented.
 
-The LFI target has several configuration options.
+The LFI target has several configuration options, specified via ``-mattr=``:
 
-* ``+lfi-loads``: enable sandboxing for loads (default: true).
-* ``+lfi-stores``: enable sandboxing for stores (default: true).
+* ``+no-lfi-loads``: Disable sandboxing for load instructions (stores-only mode).
+* ``+no-lfi-stores``: Disable sandboxing for store instructions.
 
-Use ``+nolfi-loads`` to create a "stores-only" sandbox that may read, but not
+Use ``+no-lfi-loads`` to create a "stores-only" sandbox that may read, but not
 write, outside the sandbox region.
 
-Use ``+nolfi-loads,+nolfi-stores`` to create a "jumps-only" sandbox that may
+Use ``+no-lfi-loads,+no-lfi-stores`` to create a "jumps-only" sandbox that may
 read/write outside the sandbox region but may not transfer control outside
 (e.g., may not execute system calls directly). This is primarily useful in
 combination with some other form of memory sandboxing, such as Intel MPK.
 
+AArch64
++++++++
+
+The AArch64 LFI target is ``aarch64_lfi``.
----------------
nickdesaulniers wrote:

```suggestion
The AArch64 LFI target is ``aarch64_lfi``.  This is the first part of a target triple that can be used with ``--triple=aarch64_lfi-<rest of triple>``.
```

https://github.com/llvm/llvm-project/pull/192128


More information about the llvm-commits mailing list