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

5.3 Descriptors and walk mechanics

This section describes the VMSAv8-64 descriptor format (64-bit descriptors) for a 48-bit output address. The 52-bit and 128-bit variants change the address fields and add levels, and are in 5.7. Permission bits are named here and explained in 5.5. AF and DBM are in 5.6.

How a walk proceeds

A table walk starts from TTBRn_ELx.BADDR at the starting level. At each level it takes a group of VA bits as an index, reads the 64-bit descriptor at table_base + index × 8, and acts on the descriptor type:

  • invalid: the walk stops with a Translation fault at that level;
  • table: the walk continues at the next level using the address in the descriptor;
  • block or page: the walk ends, and the output address is the descriptor address field concatenated with the remaining low VA bits.

Every table occupies exactly one granule: 512 entries for 4K, 2048 for 16K, 8192 for 64K. The only exceptions are a smaller first table, when the VA size does not fill the top level, and concatenated first tables at stage 2.

Architecturally, each descriptor read is a single-copy atomic 64-bit read (128-bit with FEAT_D128). Its endianness is set by SCTLR_ELx.EE for the regime, so a big-endian EE reads your little-endian tables byte-swapped. The walker uses the cacheability and shareability from TCR_ELx.{IRGN,ORGN,SH} (5.2). Walks are permitted to be speculative and to be cached, both as final TLB entries and as intermediate walk cache entries. That is why a descriptor update needs the maintenance sequence in 9.1.

Descriptor types by bits[1:0]

bits[1:0]Levels 0–2Level 3
x0Invalid (bits[63:1] ignored, so software may use them)Invalid
01Block (where a block is permitted at that level), otherwise invalidReserved: treated as invalid
11TablePage

So the same 0b11 means “table” at level 2 and “page” at level 3. A page descriptor written one level too high is silently read as a table pointer to your data page. The walk then continues through data as if it were descriptors.

Block sizes by granule (48-bit OA, DS == 0):

GranuleLevel 1 blockLevel 2 blockLevel 3 page
4K1GB2MB4KB
16K– (64GB only with DS == 1)32MB16KB
64K– (4TB only with FEAT_LPA)512MB64KB

Level 0 holds only table descriptors in the 48-bit formats.

Field layouts (stage 1, 4K granule)

Table descriptor (levels 0-2):
 63      62:61     60        59        58:51    50:48  47:12              11:2    1 0
+-------+---------+---------+---------+--------+------+------------------+-------+---+
|NSTable|APTable  |UXNTable/|PXNTable |ignored |RES0  | next-level table |ignored|1 1|
|       |         |XNTable  |         |        |      | address [47:12]  |       |   |
+-------+---------+---------+---------+--------+------+------------------+-------+---+

Block (L1/L2, type 01) and page (L3, type 11) descriptors:
 63   62:59   58:55  54      53   52   51   50  49:48  47:n   n-1:12  11  10  9:8 7:6     5  4:2      1 0
+----+-------+------+-------+----+----+----+---+-----+------+-------+---+---+---+-------+--+--------+---+
|ign |PBHA/  |SW    |UXN/XN |PXN |Cont|DBM |GP |RES0 | OA   | RES0  |nG |AF |SH |AP[2:1]|NS|AttrIndx|t t|
|    |ign    |use   |       |    |    |    |   |     |      |(block)|   |   |   |       |  |        |   |
+----+-------+------+-------+----+----+----+---+-----+------+-------+---+---+---+-------+--+--------+---+
 n = 30 for a 1GB block, 21 for a 2MB block, 12 for a page

The lower attributes (bits [11:2]) are:

  • AttrIndx[2:0], an index into MAIR_ELx (6.5);
  • NS (meaningful only for a Secure regime);
  • AP[2:1];
  • SH (shareability for Normal memory, 6.4);
  • AF;
  • nG, which makes the entry ASID-tagged (only in regimes with ASIDs).

The upper attributes are:

  • GP (BTI guarded page, 13.1);
  • DBM;
  • Contiguous;
  • PXN and UXN (in single-range regimes, bit 54 is XN and bit 53 is RES0);
  • four bits for software use;
  • bits [62:59], which are ignored unless FEAT_HPDS2 PBHA is enabled, or POE claims [62:60] as POIndex.

With FEAT_BBM, bit 16 of a block descriptor is nT (9.2).

With 16K and 64K granules, the address fields start at bits 14 and 16 respectively. For 64K with FEAT_LPA, bits [15:12] carry OA[51:48] (5.7).

Stage 2 descriptors keep the same type encodings and address fields, but the attributes differ:

  • MemAttr[3:0] in bits [5:2] is a direct encoding, not an index;
  • S2AP[1:0] in bits [7:6];
  • XN[1:0] in bits [54:53] (with FEAT_XNX).

Details are in 11.3.

Bits shown as RES0 inside the OA field of a block (for example bits [20:12] of a 2MB block) must be zero. A block whose address is not aligned to the block size is a programming error, and the architecture does not guarantee the resulting translation. 5.9 lists it among the five commonest mistakes.

The starting level

Each level resolves g − 3 VA bits, where 2^g is the granule size, because a granule holds 2^(g−3) eight-byte entries. With VAbits = 64 − T0SZ:

levels_needed = ceil((VAbits - g) / (g - 3))
start_level   = 4 - levels_needed        // levels are numbered so the last is level 3
first_table_entries = 2 ^ ((VAbits - g) - (levels_needed - 1) * (g - 3))
GranuleStart L0Start L1Start L2Start L3
4K (g=12, 9 bits/level)VA 40–48 bits (T0SZ 16–24)31–39 (25–33)22–30 (34–42)≤21 (43–48)
16K (g=14, 11 bits/level)48 (16), with 2 entries37–47 (17–27)26–36 (28–38)≤25 (39–48)
64K (g=16, 13 bits/level)–43–48 (16–21), with 64 entries at 48 bits30–42 (22–34)≤29 (35–47)

T0SZ values above 39 need FEAT_TTST (v8.4), so a level-3 start is only reachable with it for 4K, and with it for most of the 16K/64K level-3 range. The 52-bit cases (T0SZ below 16) are in 5.7.

For stage 1, the starting level is implied by TxSZ and the granule. Software cannot choose it, so the table tree it builds must start at exactly that level. A common bring-up error is to build a 3-level tree (L1 → L2 → L3) for a 39-bit VA and then program T0SZ = 16. The walker treats the L1 table as L0. Every VA below 512GB uses entry 0 of it, which is interpreted as a level-0 descriptor pointing to a “level 1” table that is really your level 2.

The contiguous bit

Contiguous (bit 52) is a hint. It tells the implementation that a naturally aligned run of adjacent entries in the same table holds consistent attributes and permissions and maps a contiguous, equally aligned output range, so the whole run may be cached as one TLB entry:

GranuleLevel 3 runLevel 2 runLevel 1 run
4K16 × 4KB = 64KB16 × 2MB = 32MB16 × 1GB = 16GB
16K128 × 16KB = 2MB32 × 32MB = 1GB–
64K32 × 64KB = 2MB32 × 512MB = 16GB–

An implementation may ignore the bit. If software sets it on a run that is not consistent (one entry differs, the run is misaligned, or one entry is invalid), the result is CONSTRAINED UNPREDICTABLE. The permitted outcomes include a TLB conflict abort, or a translation that uses another entry of the run for an address it was not meant to cover. Changing one page inside a contiguous run therefore needs break-before-make on the whole run (9.2).

Stage-2 concatenated tables

At stage 2, the starting level is explicit: VTCR_EL2.SL0, with SL2 for level −1 under LPA2. For 4K, SL0 = 00 means level 2, 01 level 1 and 10 level 0. For 16K/64K, 00 means level 3, 01 level 2 and 10 level 1. Because the starting level is programmable, stage 2 may start one level later (one level number higher) than the IPA size alone would imply, with up to 16 concatenated tables at the initial level. The concatenated block is one contiguous region, aligned to its total size, and the extra top IPA bits select which table to use.

Example (4K, 40-bit IPA, T0SZ = 24): stage 1 logic would start at level 0 with only 2 entries used. Stage 2 can instead start at level 1 (SL0 = 01) with 2 concatenated 4KB tables (8KB, 8KB-aligned), and IPA bit 39 selects the table. This saves one walk level for every stage-1 descriptor fetch and every final access, which matters because stage 2 lookups multiply (5.1). KVM uses this for its default IPA sizes.

4K granule, IPA sizeStart L0Start L1 (concatenated)Start L2 (concatenated)
40 bits2 entries2 tables– (would need 1024)
42 bits8 entries8 tables–
44 bits32 entriesnot allowed (32 > 16)–
34 bits–16 entries16 tables (the maximum)

Configurations whose T0SZ/SL0 combination is inconsistent (it would need more than 16 tables, or the start level is too low for the IPA size) generate a stage 2 Translation fault. Stage 1 never concatenates.

Validation note: Test the contiguous hint for correctness, not speed, because the architecture never requires it to make anything faster. Map a 64KB contiguous run (4K granule) with a distinct data pattern per page, access all 16 pages in random order from several PEs, and check every value. Then repeat with one deliberately inconsistent entry and check that the outcome is one the architecture permits for a misprogrammed Contiguous bit, as listed in the Arm ARM (for example a TLB conflict abort, reported as DFSC 0b110000, or a translation derived from one of the entries in the run). Note that a translation derived from the “wrong” entry can produce a PA that no single entry maps, so the checker must accept the permitted outcomes rather than only the intended PAs. DTLB_WALK (PMU event 0x0034) counts dropping with the hint set are evidence that the implementation uses it, but the event is not a pass criterion.

Bring-up note: When you build tables with a host-side script for a pre-silicon image, also emit the computed starting level and first-table size, and assert them against the T0SZ/TG0 you will program. Two numbers in a log are cheaper than a hang at the first instruction after SCTLR_ELx.M = 1.

Checkpoint

Q5.3.1 A level-3 table contains an entry with bits[1:0] = 0b01. What does the walker do for a VA that indexes it?

  • A. It maps a 4KB block, because 01 is the block encoding
  • B. It treats the entry as a table pointer, because level 3 has no blocks
  • C. It takes a Translation fault at level 3, because 01 is reserved at level 3 and treated as invalid
  • D. The result is CONSTRAINED UNPREDICTABLE, and the entry may be used as a page
Answer

C. At level 3, only 0b11 (page) is valid. 0b01 is reserved and behaves as an invalid descriptor, which gives a Translation fault at level 3. Option A carries the level 0–2 meaning of 01 into level 3.

Read more: Arm ARM (DDI0487), “Translation table descriptor formats”, VMSAv8-64 level 3 descriptor format

Q5.3.2 With a 4K granule, software builds L1 → L2 → L3 tables for a 39-bit VA space but programs T0SZ = 16. The kernel image lives at VA 0x4000_0000. What happens on the first fetch after the MMU is enabled?

  • A. It works, because unused high bits of the VA are zero
  • B. The walker starts at level 0, treats the L1 table as L0, and follows entry 0 as a table descriptor, so the walk goes one level off and normally faults or translates wrongly
  • C. The walker detects the short tree and starts at level 1
  • D. The MSR SCTLR_EL1 that sets M is UNDEFINED, because T0SZ mismatches the tables
Answer

B. The starting level is implied by T0SZ and the granule, and the walker cannot see your intended structure. VA bits [47:39] index the “L0” table, which here is your L1 table. Entry 0, if it is a block, is invalid at level 0 (fault). If it is a table, the walk continues through a wrongly levelled tree. Option C assumes the walker checks the tree’s shape, and it does not.

Read more: Arm ARM (DDI0487), “Translation table walks”, “Selection between TTBR0 and TTBR1” and the initial lookup level tables

Q5.3.3 A hypervisor wants a 4K-granule stage 2 for a 40-bit IPA starting at level 1. What must the initial table be?

  • A. One 4KB table, 4KB-aligned, with IPA bit 39 ignored
  • B. A level-0 table with 2 entries, because concatenation is only for 64K granules
  • C. 16 concatenated tables, the architectural fixed count
  • D. Two concatenated 4KB tables in one 8KB-aligned 8KB region, with IPA bit 39 selecting the table
Answer

D. A 40-bit IPA at level 1 needs 2^(40−30) = 1024 entries, which is 2 tables. Concatenated tables must be contiguous and aligned to their total size. Sixteen is the maximum number of concatenated tables, not a fixed count (so C is wrong). Option A is wrong because, with T0SZ = 24 and SL0 = 01, the walker always uses IPA bit 39 to index an 8KB region. With only one 4KB table allocated, IPAs with bit 39 set index whatever memory follows that table.

Read more: Arm ARM (DDI0487), “Concatenated translation tables for the initial stage 2 lookup”, VTCR_EL2.SL0