Introduction
Pointer authentication stores a Pointer Authentication Code, or PAC, in the unused top bits of a pointer. To sign a pointer, an instruction calculates the PAC from the pointer, a modifier and a secret key, then inserts it. To authenticate, an instruction calculates the PAC again and compares. If they match, the upper bits of the pointer are restored so that it can be used. If not, the outcome depends on the version of the architecture: the pointer is corrupted so that it will fault when used, or the instruction faults at once.
There are five keys. The mnemonic names the key:
- key A or B for instruction addresses,
iaandib; - key A or B for data addresses,
daanddb; - the generic key,
ga, used bypacgaalone.
A z in the name means the modifier is zero. The usual pattern at the
start of a function is to sign the return address in x30, with
sp as the modifier, and to authenticate it before returning.
Base instructions of this kind come with FEAT_PAuth. The forms with
sppc or 171615 come with FEAT_PAuth_LR and add a second
modifier. None of these instructions changes the condition flags.
Some forms, including paciasp and autiasp, are hints that
run as a no-operation on processors without the feature. They are listed with the
other hints on the System
instructions page.
The instructions
Signing
| Mnemonic | Syntax | What it does | Flags |
|---|---|---|---|
pacia, pacib | pacia Xd, Xn | Signs an instruction address in Xd, with the modifier in Xn or sp. Key A or B. | – |
pacda, pacdb | pacda Xd, Xn | Signs a data address. | – |
paciza, pacizb | paciza Xd | Signs an instruction address with a modifier of zero. | – |
pacdza, pacdzb | pacdza Xd | Signs a data address with a modifier of zero. | – |
pacga | pacga Xd, Xn, Xm | Calculates a PAC for the 64-bit value in Xn, with the modifier in Xm or sp, using the generic key. The code goes in the top 32 bits of Xd and the low 32 bits are 0. | – |
Authenticating and stripping
| Mnemonic | Syntax | What it does | Flags |
|---|---|---|---|
autia, autib | autia Xd, Xn | Authenticates an instruction address in Xd, with the modifier in Xn or sp. | – |
autda, autdb | autda Xd, Xn | Authenticates a data address. | – |
autiza, autizb | autiza Xd | Authenticates an instruction address with a modifier of zero. | – |
autdza, autdzb | autdza Xd | Authenticates a data address with a modifier of zero. | – |
xpaci, xpacd | xpaci Xd | Removes a PAC without checking it, for an instruction address or a data address. | – |
Branches, returns and loads
These authenticate and act in one instruction. The authenticated address is not written back to the register, except for the pre-index form of the loads, and there it is written without the PAC.
| Mnemonic | Syntax | What it does | Flags |
|---|---|---|---|
braa, brab | braa Xn, Xm | Authenticates Xn, with the modifier in Xm or sp, then branches to it. | – |
braaz, brabz | braaz Xn | The same with a modifier of zero. | – |
blraa, blrab | blraa Xn, Xm | Authenticates Xn, then calls it, setting x30. | – |
blraaz, blrabz | blraaz Xn | The same with a modifier of zero. | – |
retaa, retab | retaa | Authenticates x30 with sp as the modifier and returns. | – |
eretaa, eretab | eretaa | Authenticates the address in ELR_ELx with sp as the modifier, restores PSTATE from the SPSR, and returns from the exception. Undefined at EL0. | NZCV, restored from the SPSR |
ldraa, ldrab | ldraa Xt, [Xn, #imm]; ldraa Xt, [Xn, #imm]! | Authenticates the base register with a modifier of zero, adds the offset, and loads a doubleword. | – |
Return addresses with a second modifier (FEAT_PAuth_LR)
These use x30 and sp, with the address of the instruction
as a second modifier, so that a signature is bound to one place in the code. The
immediate forms name a label, and autiasppc and retaasppc
take the second modifier from it. The register forms hold the value in
Xn. The
171615 forms use x17 for the address and x16
and x15 for the two modifiers.
| Mnemonic | Syntax | What it does | Flags |
|---|---|---|---|
paciasppc, pacibsppc | paciasppc | Signs the address in x30 using sp and the program counter as modifiers. It includes an implicit bti. | – |
pacnbiasppc, pacnbibsppc | pacnbiasppc | Signs in the same way without the implicit bti, for code that is not a branch target. | – |
autiasppc, autibsppc | autiasppc label | Authenticates x30 using sp and the address of the label. | – |
autiasppcr, autibsppcr | autiasppcr Xn | Authenticates x30 using sp and the value in Xn. | – |
retaasppc, retabsppc | retaasppc label | Authenticates x30 with sp and the label, then returns. | – |
retaasppcr, retabsppcr | retaasppcr Xn | Authenticates x30 with sp and the value in Xn, then returns. | – |
pacia171615, pacib171615 | pacia171615 | Signs x17 using x16 and x15 as modifiers. | – |
autia171615, autib171615 | autia171615 | Authenticates x17 using x16 and x15 as modifiers. | – |
With FEAT_PAuth_LR, pacm
sets PSTATE.PACM. While PSTATE.PACM is 1, some earlier forms such as
retaa also take a second modifier, in x16.
Links
Reference
- Arm A64 Instruction Set Architecture – Arm’s description of each A64 instruction
- Arm Architecture Reference Manual for A-profile – the full architecture specification