</>EmbeddedInterview

What are ASIDs, VMIDs and TLB shootdowns?

HardARM Architecture

Short answer: ASIDs distinguish address spaces, VMIDs distinguish virtual-machine translation contexts, and a TLB shootdown invalidates cached translations on CPUs that could still use an outdated mapping.

Process A: ASID 5Process B: ASID 6Same VA, different cached translationsMapping changes: invalidate affected TLB entries
Translation tags avoid unnecessary global invalidation; they do not remove the need to invalidate changed mappings.

1. Example: Process A and B both access VA 0x4000, but A maps it to PA 0x10000 while B maps it to PA 0x20000. Non-global translations can be tagged with different ASIDs.

2. When a mapping changes: The OS updates page tables and ensures affected CPUs cannot keep using obsolete entries. ARM provides TLBI instructions and shareable invalidation forms; Linux uses architecture-specific TLB flushing helpers.

3. VMID: A hypervisor uses a VMID to distinguish stage-2 contexts. Reusing an identifier requires appropriate invalidation.

Interview takeaway: ASID/VMID tags improve context switching; invalidation maintains correctness when mappings or identifiers change.

Why identifiers reduce context-switch overhead

TLB entry A: VA 0x4000 + ASID 7 -> PA 0x10000
TLB entry B: VA 0x4000 + ASID 8 -> PA 0x20000

With distinct valid ASIDs, a switch from process A to B need not discard every cached non-global translation. Global mappings follow their own matching rules. ASID space is finite, so the kernel manages reuse and invalidation, often with generation-based allocation.

VMIDs similarly distinguish guest stage-2 contexts. When a hypervisor reuses a VMID or changes a guest mapping, it must invalidate relevant cached translations according to architectural rules. Combined stage-1/stage-2 entries may be affected.

A shootdown is needed, for example, when one core unmaps a page that another core may still have cached. The OS updates translation structures, ensures descriptor writes are visible as required, invalidates the affected translations, and waits for the necessary completion before reusing physical memory. ARM shareable TLBI operations can target relevant cores without necessarily requiring a separate IPI to each one. A representative architectural pattern involves ordering table writes before TLBI, then waiting for invalidation completion and performing required context synchronization; exact instructions and scope depend on the mapping change. Use Linux's TLB flush interfaces and never free backing pages while another CPU can still access an obsolete mapping.