@@ -10,6 +10,10 @@ intended audience is BOLT developers. The document is an updated version of the
1010in assembly, or ` OpNegateRAState ` in BOLT sources. In this document, I will use
1111** negate-ra-state** as a shorthand.
1212
13+ Note: there are two resolutions for CFI:
14+ - Call Frame Instruction: individual DWARF instruction, e.g. negate-ra-state
15+ - Control Flow Integrity: a security mechanism, e.g. pointer authentication.
16+
1317## Introduction
1418
1519### Pointer Authentication
@@ -104,9 +108,9 @@ negate-ra-state CFIs will become invalid during BasicBlock reordering.
104108## Solution design
105109
106110The implementation introduces two new passes:
107- 1 . ` MarkRAStatesPass ` : assigns the RA state to each instruction based on the CFIs
108- in the input binary
109- 2 . ` InsertNegateRAStatePass ` : reads those assigned instruction RA states after
111+ 1 . ` PointerAuthCFIAnalyzer ` : assigns the RA state to each instruction based on
112+ the CFIs in the input binary
113+ 2 . ` PointerAuthCFIFixup ` : reads those assigned instruction RA states after
110114 optimizations, and emits ` DW_CFA_AARCH64_negate_ra_state ` CFIs at the correct
111115 places: wherever there is a state change between two consecutive instructions
112116 in the layout order.
@@ -129,7 +133,7 @@ instruction.
129133This special case is handled by adding an ` initialRAState ` bool to each BinaryFunction.
130134If the ` Offset ` the CFI refers to is zero, we don't store an annotation, but set
131135the ` initialRAState ` in ` FillCFIInfoFor ` . This information is then used in
132- ` MarkRAStates ` .
136+ ` PointerAuthCFIAnalyzer ` .
133137
134138### Binaries without DWARF info
135139
@@ -146,7 +150,7 @@ In summary:
146150- pointer auth is used, and we have DWARF CFIs: passes run, and rewrite the
147151 negate-ra-state CFI.
148152
149- ### MarkRAStates pass
153+ ### PointerAuthCFIAnalyzer pass
150154
151155This pass runs before optimizations reorder anything.
152156
@@ -173,9 +177,9 @@ what we have before the pass, and after it.
173177| autiasp | negate-ra-state | signed |
174178| ret | | unsigned |
175179
176- ##### Error handling in MarkRAState Pass :
180+ ##### Error handling in PointerAuthCFIAnalyzer pass :
177181
178- Whenever the MarkRAStates pass finds inconsistencies in the current
182+ Whenever the PointerAuthCFIAnalyzer pass finds inconsistencies in the current
179183BinaryFunction, it marks the function as ignored using ` BF.setIgnored() ` . BOLT
180184will not optimize this function but will emit it unchanged in the original section
181185(` .bolt.org.text ` ).
@@ -188,16 +192,17 @@ The inconsistencies are as follows:
188192Users will be informed about the number of ignored functions in the pass, the
189193exact functions ignored, and the found inconsistency.
190194
191- ### InsertNegateRAStatePass
195+ ### PointerAuthCFIFixup
192196
193- This pass runs after optimizations. It performns the _ inverse_ of MarkRAState pa s:
197+ This pass runs after optimizations. It performs the _ inverse_ of PointerAuthCFIAnalyzer
198+ pass:
1941991 . it reads the RA state annotations attached to the instructions, and
1952002 . whenever the state changes, it adds a PseudoInstruction that holds an
196201 OpNegateRAState CFI.
197202
198203##### Covering newly generated instructions:
199204
200- Some BOLT passes can add new Instructions. In InsertNegateRAStatePass , we have
205+ Some BOLT passes can add new Instructions. In PointerAuthCFIFixup , we have
201206to know what RA state these have.
202207
203208> [ !important]
@@ -224,7 +229,7 @@ freely. The only special case is function splitting. When a function is split,
224229the split part becomes a new function in the emitted binary. For unwinding to
225230work, it needs to "replay" all CFIs that lead up to the split point. BOLT does
226231this for other CFIs. As negate-ra-state is not read (only stored as an Annotation),
227- we have to do this manually in InsertNegateRAStatePass . Here, if the split part
232+ we have to do this manually in PointerAuthCFIFixup . Here, if the split part
228233starts with an instruction that has Signed RA state, we add a negate-ra-state CFI
229234to indicate this.
230235
0 commit comments