AArch64 Branches
This is a personal study note — I write these to solidify my own understanding. If you spot anything wrong or have thoughts, feel free to reach out. Layout, formatting, and grammar assisted by Claude.
Conditional branches
There is nothing surprising about conditional branches. AArch64 has four flag bits: N (negative), Z (zero), C (carry, which after a compare means unsigned higher or same), and V (signed overflow). Conditional instructions act on these flags, and instructions like compare and test set them. Interestingly, unlike x86, where add always writes the flags, AArch64 lets you choose: add leaves the flags alone and adds sets them.
AArch64 also has branches that do not read the flags at all. cbz and cbnz branch if a register is zero or not zero. tbz and tbnz test a single bit of a register and branch on it. Both have been there since Armv8.0. The cb<cc> instructions are new in Armv9.6.
cb<cc> compares two registers, or a register and an immediate from 0 to 63, and branches on the condition in one instruction. It works on 32-bit and 64-bit registers and does not touch the flags.
Direct B and BL
B and BL are very straightforward. B carries a 26-bit offset, so it can branch to anywhere within ±128 MiB of itself. BL does the same, but the L stands for link: it also saves the address of the next instruction, PC + 4, into X30, the link register, so that the callee can ret back to it.
If X30 already holds a value, BL overwrites it and the old value is discarded. A leaf function never has to touch the stack for its return address. It runs and executes ret with the caller's address still in X30.
Indirect BR, BLR and RET
Unlike x86, where an indirect jmp rax is two bytes and ret is one, an AArch64 indirect branch is still four bytes, most of them fixed. In return, AArch64 does not have x86’s problem with variable-length instructions. Every instruction sits on a 4-byte boundary and a branch to any other address faults, so there are no hidden instructions inside other instructions for an attacker to jump into.
AArch64 also has an instruction to mark where an indirect branch is allowed to land: bti. In a page the kernel marks as guarded, a br or blr that lands anywhere other than a bti raises an exception [1]. The compiler places one at every function entry and switch target.
Two more security features sit on these instructions. Pointer authentication, from Armv8.3, signs X30 before it is saved to the stack and checks the signature before ret uses it [2]. The Guarded Control Stack, from Armv9.4, keeps a second copy of every return address in memory that only the hardware can write, and ret compares against it [3]. I will cover how they work and their limitations in future posts.
AArch64 instructions so far are all 4 bytes. This means the encoding space is finite, and Arm already treats it as scarce. When SVE was announced in 2016, Arm wrote that “75% of the A64 encoding space is already allocated” [4]. It would be interesting to see how they address this.
Conditional fault
Conditional fault was announced in October 2026 with Armv9.8. The concept is straightforward: a compare that raises an exception when the condition is true, instead of branching. The motivation comes from memory-safe languages like Rust [5]. Bounds and null checks are the perfect example.
I am not so familiar with exception-related registers yet, so here is a table I wrote for myself.
- ELR_EL1, Exception Link Register: does the same job X30 does for
bl, but for exceptions. - SPSR_EL1, Saved Program Status Register: a snapshot of PSTATE at the moment of the exception. The NZCV flags, the interrupt mask bits, the exception level and the stack pointer the program was using are all recorded.
eretrestores PSTATE from it, so the program resumes with its flags intact. - ESR_EL1, Exception Syndrome Register: why the exception happened. The top 6 bits are the exception class, a code for the kind of event, and the lower bits are the instruction-specific syndrome.
- VBAR_EL1, Vector Base Address Register, holds the base address of the vector table, the kernel’s entry points, and the core adds a fixed offset for the type of exception.
- SCTLR_EL1, System Control Register, is a bag of enable bits for the kernel’s own level and for user space below it. SCTLR2_EL1 is its overflow, added when the first one filled up, and that is where the new EnCF0 bit lives.
There are four conditional fault instructions, and each of them mirrors a regular branch instruction. flt.cond mirrors b.cond. cflt<cc> #r, Xt, Xm mirrors cb<cc> with two registers as operands. cflt<cc> #r, Xt, #imm mirrors cb<cc> #imm and cbz, comparing a register against a constant. tfltz and tfltnz mirror tbz and tbnz, testing one bit of a register. Like the branches, they split on the flags: flt.cond is the only one that reads them, so it needs a cmp or another flag-setting instruction ahead of it. The other three do their own compare.
All four raise the same exception, class 0x0B, with ELR pointing at the instruction itself. ESR tells the kernel whether it was flt.cond or one of the other three, and carries the reason from the instruction.
References
[1] Arm’s description of FEAT_BTI, which "allows memory pages to be guarded against the execution of instructions that are not the intended target of a branch": Feature names in A-profile architecture, The Armv8.5 architecture extension, Arm document 109697, 2026.09.
[2] Arm’s description of FEAT_PAuth, which "supports address authentication of the contents of a register before that register is used as the target of an indirect branch, or as a load": Feature names in A-profile architecture, The Armv8.3 architecture extension, Arm document 109697, 2026.09.
[3] Arm’s description of FEAT_GCS, "an area of memory in which procedure return addresses and exception return addresses are stored and protected from modification": Feature names in A-profile architecture, The Armv9.4 architecture extension, Arm document 109697, 2026.09.
[4] The SVE announcement, with the figure for how much of the A64 encoding space was allocated by 2016: Nigel Stephens, Technology Update: The Scalable Vector Extension (SVE) for the Armv8-A architecture, Arm Community blog, 22 August 2016.
[5] Arm’s motivation for the Conditional fault instructions: Martin Weidmann, Arm A-Profile Architecture Developments 2026, Arm Community blog, 5 October 2026. "These checks can increase code size and branch frequency, which puts more pressure on branch prediction logic."