Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

13.3 Who owns the upper address bits

A 64-bit pointer on a 48-bit VA system has 16 bits that translation does not use. Four parties compete for them: the TTBR select bit, Top Byte Ignore (TBI) software tags, the MTE logical tag, and the PAC. Large-VA features shrink the pool further. This section is the bookkeeping that tells you, for a given TCR_ELx, exactly which bits belong to whom. Get it wrong and you see PACs that never authenticate, MTE checks that silently never happen, or faults with FAR values that look impossible.

The fixed points

  • Bit 55 selects the VA range in two-range regimes (EL1&0, and EL2&0 with HCR_EL2.E2H = 1): 0 means TTBR0, 1 means TTBR1. TBI does not change this. Bit 55 is never part of a PAC or a tag, and it is preserved by every PAC/AUT/XPAC operation.
  • Bits [VA−1:0] are the address, where VA = 64 − TnSZ (5.2).
  • Bits [54:VA], and [63:56] when TBI is off, must equal bit 55 for translation. Otherwise the access takes a translation fault at level 0 (or at the starting level).

In the one-range regimes (EL2 with E2H = 0, and EL3) the upper bits must be zero rather than a copy of bit 55, and TCR_EL2/TCR_EL3 have a single TBI [20] and TBID [29].

TBI and TBID

TCR_EL1.TBI0 [37] and TBI1 [38] make the address translation ignore bits [63:56] for the TTBR0 and TTBR1 halves respectively. The top byte becomes an address tag that hardware carries through loads and stores but does not translate.

TBI originally applied to instruction addresses as well. FEAT_PAuth added TBID0 [51] and TBID1 [52]. When TBIDn = 1, TBI applies to data accesses only:

TBInTBIDnData address top byteInstruction address top byte
0xSignificantSignificant
10IgnoredIgnored (the PC is written with bits [63:56] as copies of bit 55)
11IgnoredSignificant, so a branch to a tagged address is a non-canonical target and faults

The architecture never holds a tagged PC. When TBI applies to instruction addresses, a branch or an ERET to a tagged address writes the PC with the top byte replaced by a sign extension of bit 55. TBID exists for PAC, not for safety: instruction pointers do not need a software tag byte, so freeing that byte gives code pointers a wider PAC (below). Linux sets TBI0 for user space, plus TBI1 | TBID1 when KASAN or MTE is in use for the kernel half.

The PAC field

The PAC is inserted into whatever is left after the address, bit 55 and (if TBI applies) the top byte. The DDI0487 pseudocode computes this in AddPAC from the bottom PAC bit (64 − TnSZ) and a top bit that is 55 when TBI applies to that kind of pointer, or 63 when it does not. The “kind” is the crucial part. For the instruction keys (PACIA, PACIB, …), the effective TBI is TBI && !TBID; for the data keys it is plain TBI.

VA size (TnSZ)TBI appliesPAC bitsWidth
39 (25)no[63:56], [54:39]24
39 (25)yes[54:39]16
48 (16)no[63:56], [54:48]15
48 (16)yes[54:48]7
52 (12, LPA2/LVA)no[63:56], [54:52]11
52 (12)yes[54:52]3

A typical Linux configuration has a 48-bit VA, user TBI0 = 1 and TBID0 = 0. That gives 7-bit PACs for both code and data pointers in user space. Setting TBID0 would give instruction pointers 15 bits while keeping the tag byte for data. The cost of a 3-bit PAC at 52-bit VA is real: a one-in-eight guess rate makes PAuth close to decorative without FPAC to turn every wrong guess into a crash (13.1).

Note that the PAC width for a pointer depends on the TnSZ of the range that bit 55 of that pointer selects. TTBR0 and TTBR1 pointers can therefore have different PAC widths in the same process.

The MTE logical tag

MTE (13.4) defines the logical tag as bits [59:56], inside the TBI byte. In the base MTE architecture, a load or store can be tag-checked only if TBI applies to its address. A pointer in a range with TBIn = 0 is an unchecked access no matter what MAIR says. Bits [63:60] stay free for software, and HWASan-style schemes or allocator metadata use them.

MTE also costs the PAC nothing extra, because the PAC already avoids the TBI byte. A data pointer with TBI on carries the MTE tag in [59:56], 4 spare bits in [63:60] and a 7-bit PAC in [54:48]. All three can coexist.

TCMA: match-all tags

TCR_EL1.TCMA0 [57] and TCMA1 [58] (FEAT_MTE2) make a particular logical tag value unchecked:

  • TTBR0 range (bit 55 = 0): logical tag 0b0000 is treated as unchecked when TCMA0 = 1.
  • TTBR1 range (bit 55 = 1): logical tag 0b1111 is treated as unchecked when TCMA1 = 1.

These are the values that a canonical, never-tagged pointer has. With TCMA1 = 1, a kernel can enable MTE checking for EL1 and still dereference untagged 0xffff... pointers produced by code that knows nothing about tags (early boot, per-CPU offsets, phys_to_virt). Linux’s TCR_MTE_FLAGS sets exactly TCMA1 | TBI1 | TBID1. The consequence for security is that the canonical tag becomes a hole: an allocator must never hand out 0b1111 (kernel) or 0b0000 (user, if TCMA0 is set) as a real tag. Linux excludes them through GCR_EL1.Exclude (13.5).

Large VAs and D128

The 52-bit VA configurations (5.7) use the same rules. FEAT_LVA (64K granule) and FEAT_LPA2 (4K/16K granules with TCR_ELx.DS = 1) both allow TnSZ down to 12. The address then consumes bits [51:0], the TBI byte and bit 55 are unchanged, and the PAC is squeezed to bits [54:52]. MTE is unaffected, because its tag lives in the TBI byte. A kernel that switches to 52-bit VA for capacity reasons should be honest that it is trading PAuth strength for address space.

FEAT_LVA3 with the D128 translation format allows a 56-bit VA, using bits [55:0] with bit 55 doubling as the range select. Here [54:VA] is empty, so with TBI on, no bits are left for a PAC at all. With TBI off, only the top byte is available, and MTE cannot use it. Take the exact PAC-field rules for D128 and LVA3 configurations from the AddPAC/CalculateBottomPACBit pseudocode in the DDI0487 issue you target, not from this derivation. The MTE4 controls TCR_ELx.MTX0/MTX1 [60]/[61] (13.6) change the accounting again, because they decouple MTE checking from TBI.

What FAR_ELx reports

Faults expose the upper bits, and a crash-dump reader needs to know which bits to trust:

FaultFAR_ELx[63:56]
Data abort or watchpoint on a tagged addressThe tag byte as used by the access (Linux strips it from si_addr unless the handler set SA_EXPOSE_TAGBITS)
Instruction abortThe faulting PC. If TBI applied to instruction addresses, the branch already replaced the top byte with a sign extension of bit 55; if not (TBI off, or TBIDn = 1), the non-canonical top byte the branch target carried
Synchronous MTE tag check fault, without FEAT_MTE_TAGGED_FAR[59:56] = the logical tag; [63:60] UNKNOWN
Synchronous MTE tag check fault, with FEAT_MTE_TAGGED_FARAll of [63:56] valid
Asynchronous tag check faultNo FAR at all; only a TFSR_ELx flag
RET after a failed AUT without FPACA corrupted PAC field or error code, so the “address” has garbage in [54:48] or the top byte

FEAT_MTE_TAGGED_FAR is a 2022 MTE extension (Linux calls it Armv8.9), reported in ID_AA64PFR2_EL1.MTEFAR [11:8] and exposed to user space as HWCAP3_MTE_FAR. Without it, Linux overwrites FAR[63:60] with bits from the untagged address before reporting, so user space does not see UNKNOWN garbage.

Bring-up note: When a level-0 translation fault arrives at a “valid” address, compare FAR bits [63:56] and [54:VA] with bit 55 before suspecting the tables. A pointer that was tagged by code expecting TBI = 1, but used in a regime with TBI = 0 (EL3, or EL2 with E2H = 0 and TCR_EL2.TBI = 0), faults exactly like an unmapped address. Firmware that inherits an allocator or a library from a TBI-assuming environment hits this first.

Checkpoint

Q13.3.1 A user process runs with T0SZ = 16, TBI0 = 1 and TBID0 = 1. How wide are the PACs produced by PACIA (code pointer) and PACDA (data pointer) for TTBR0 addresses?

  • A. Both 7 bits
  • B. Both 15 bits
  • C. PACIA 15 bits ([63:56] and [54:48]); PACDA 7 bits ([54:48])
  • D. PACIA 7 bits; PACDA 15 bits
Answer

C. With TBID0 = 1, TBI applies only to data addresses. The instruction keys therefore see TBI as off and may use the top byte, giving 8 + 7 = 15 bits. The data keys see TBI on and use only [54:48]. D reverses the roles: TBID frees the top byte of instruction pointers, which is its whole purpose.

Read more: Arm ARM (DDI0487), Pointer authentication, the PAC field; TCR_EL1.TBID0

Q13.3.2 A kernel enables MTE checking at EL1 with TCR_EL1.TCMA1 = 1. A kernel pointer 0xffff_8000_1234_0000 (never tagged) is dereferenced into Tagged memory whose allocation tag is 0x3. What happens, and why?

  • A. No fault. The logical tag is 0xF and bit 55 = 1, so TCMA1 makes the access unchecked
  • B. A synchronous tag check fault, because 0xF ≠ 0x3
  • C. No fault, because the TTBR1 range is never tag-checked
  • D. A translation fault, because bits [63:56] are not ignored at EL1
Answer

A. Bits [59:56] of the pointer are 0xF. With bit 55 = 1 and TCMA1 = 1, tag 0b1111 is a match-all value and the access is unchecked. This is why allocators must exclude 0xF as a real kernel tag. Without TCMA1 the result would be B. C is wrong because TTBR1 accesses are checked whenever TBI1 is set, TCF is not NONE and the memory is Tagged.

Read more: Arm ARM (DDI0487), TCR_EL1.TCMA1; Allocation Tag checking

Q13.3.3 Linux moves from 48-bit to 52-bit user VA (FEAT_LPA2, T0SZ = 12) with TBI0 = 1. What happens to user-space PAuth and MTE?

  • A. Both are unaffected; the extra address bits come from the TBI byte
  • B. The MTE logical tag is unaffected, but the user PAC shrinks from 7 bits to 3 bits
  • C. MTE must be disabled because bits [59:56] become address bits
  • D. PAuth stops working because no PAC bits remain
Answer

B. The four extra address bits [51:48] are taken from the PAC field [54:48], leaving [54:52]. The TBI byte, and therefore the MTE tag in [59:56], is untouched. D would be true only if the VA reached bit 55, as in the 56-bit LVA3 configuration with TBI on.

Read more: Arm ARM (DDI0487), FEAT_LPA2; Pointer authentication, the PAC field