</>EmbeddedInterview

What is the MMU?

MediumARM Architecture

Short answer: The MMU translates virtual addresses into physical addresses using translation tables and enforces access permissions and memory attributes.

CPUVirtual addressMMU / TLBTranslationMemoryPhysical address
MRS X0, TTBR0_EL1 // privileged: table base

1. Why translation is needed: Two processes can use the same virtual address while mapping to different physical pages. The MMU also enforces user/kernel access, read/write and execute permissions.

2. Example: With a 4 KiB page, virtual address 0x1234 has offset 0x234. If its virtual page maps to physical base 0x8000, the resulting physical address is 0x8234.

System register Role at EL1
TTBR0_EL1 / TTBR1_EL1 Translation table bases
TCR_EL1 Translation configuration
MAIR_EL1 Memory attribute encodings
SCTLR_EL1 Controls including MMU enable

3. Failure: An invalid mapping or permission violation raises a fault. Linux may resolve a valid demand-page fault or signal the process.

Interview takeaway: The MMU provides translation, isolation and memory attributes; the TLB accelerates translation.

Worked four-level page-table example

Assume 48-bit virtual addressing, 4 KiB granules and eight-byte translation descriptors.

VA [47:39] [38:30] [29:21] [20:12] [11:0]
       L0      L1      L2      L3     offset

Each level uses a nine-bit index (512 entries). TTBR0_EL1 or TTBR1_EL1 selects the applicable root. A table descriptor supplies the base of the next table; a valid terminal page descriptor supplies the physical page base and attributes. Supported block descriptors can terminate the walk at a higher level. The low 12-bit offset is combined with the page base for a 4 KiB page.

Attributes control read/write privilege, executable permission, cacheability and shareability. An invalid descriptor can cause a translation fault; a valid mapping with insufficient permission can cause a permission fault. TLB entries cache the result, so the hardware need not repeat the complete walk for each load. The granule and address width determine the actual table layout; 4 KiB and four levels are examples, not universal ARM64 requirements.