LLVM 20.0.0git
Enumerations | Functions
llvm::AArch64PAuth Namespace Reference

Enumerations

enum class  AuthCheckMethod { None , DummyLoad , HighBitsNoTBI , XPACHint }
 Variants of check performed on an authenticated pointer. More...
 

Functions

void checkAuthenticatedRegister (MachineBasicBlock::iterator MBBI, AuthCheckMethod Method, Register AuthenticatedReg, Register TmpReg, bool UseIKey, unsigned BrkImm)
 Explicitly checks that pointer authentication succeeded.
 
unsigned getCheckerSizeInBytes (AuthCheckMethod Method)
 Returns the number of bytes added by checkAuthenticatedRegister.
 

Enumeration Type Documentation

◆ AuthCheckMethod

Variants of check performed on an authenticated pointer.

In cases such as authenticating the LR value when performing a tail call or when re-signing a signed pointer with a different signing schema, a failed authentication may not generate an exception on its own and may create an authentication or signing oracle if not checked explicitly.

A number of check methods modify control flow in a similar way by rewriting the code

<authenticate LR>
Expand Atomic instructions

as follows:

<authenticate LR>
<method-specific checker>
ret_block:
<more instructions>
...
break_block:
brk <code>
Enumerator
None 

Do not check the value at all.

DummyLoad 

Perform a load to a temporary register.

HighBitsNoTBI 

Check by comparing bits 62 and 61 of the authenticated address.

This method modifies control flow and inserts the following checker:

eor Xtmp, Xn, Xn, lsl #1
tbnz Xtmp, #62, break_block
XPACHint 

Check by comparing the authenticated value with an XPAC-ed one without using PAuth instructions not encoded as HINT.

Can only be applied to LR.

This method modifies control flow and inserts the following checker:

mov Xtmp, LR
xpaclri ; encoded as "hint #7"
; Note: at this point, the LR register contains the address as if
; the authentication succeeded and the temporary register contains the
; *real* result of authentication.
cmp Xtmp, LR
b.ne break_block
if(PassOpts->AAPipeline)
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
Definition: Value.cpp:469
bool succeeded(LogicalResult Result)
Utility function that returns true if the provided LogicalResult corresponds to a success value.
Definition: LogicalResult.h:67

Definition at line 45 of file AArch64PointerAuth.h.

Function Documentation

◆ checkAuthenticatedRegister()

void llvm::AArch64PAuth::checkAuthenticatedRegister ( MachineBasicBlock::iterator  MBBI,
AuthCheckMethod  Method,
Register  AuthenticatedReg,
Register  TmpReg,
bool  UseIKey,
unsigned  BrkImm 
)

Explicitly checks that pointer authentication succeeded.

Assuming AuthenticatedReg contains a value returned by one of the AUT* instructions, check the value using Method just before the instruction pointed to by MBBI. If the check succeeds, execution proceeds to the instruction pointed to by MBBI, otherwise a CPU exception is generated.

Some of the methods may need to know if the pointer was authenticated using an I-key or D-key and which register can be used as temporary. If an explicit BRK instruction is used to generate an exception, BrkImm specifies its immediate operand.

Definition at line 247 of file AArch64PointerAuth.cpp.

References llvm::MachineInstrBuilder::addImm(), llvm::MachineInstrBuilder::addMBB(), llvm::MachineInstrBuilder::addMemOperand(), llvm::MachineInstrBuilder::addReg(), llvm::MachineBasicBlock::addSuccessor(), assert(), llvm::BuildMI(), llvm::MachineFunction::CreateMachineBasicBlock(), DL, llvm::MachineBasicBlock::getBasicBlock(), llvm::MachineBasicBlock::getFirstTerminator(), llvm::AArch64Subtarget::getInstrInfo(), llvm::MachineBasicBlock::getParent(), llvm::MachineFunction::getSubtarget(), llvm::getWRegFromXReg(), llvm_unreachable, MBB, MBBI, llvm::AArch64CC::NE, llvm::MachineFunction::push_back(), and TII.

◆ getCheckerSizeInBytes()

unsigned llvm::AArch64PAuth::getCheckerSizeInBytes ( AuthCheckMethod  Method)

Returns the number of bytes added by checkAuthenticatedRegister.

Definition at line 324 of file AArch64PointerAuth.cpp.

References llvm_unreachable.