AGENT SKILL

arm-aarch64-exception-levels-memory-model-and-mmu

Use for the core architecture: AArch64 register and instruction design and how it differs from AArch32, the instruction set characteristics that matter to compilers and hand-written assembly, exception levels EL0 to EL3 and the privilege model, the weak memory model and the barriers and acquire-release semantics it forces, and the MMU with translation regimes, page table formats and TLB behaviour.

License 许可
MIT
最近更新
2026-11-15
Stars
★ 5
Forks
3

01 前言 Front Matter

name
arm-aarch64-exception-levels-memory-model-and-mmu
description
Use for the core architecture: AArch64 register and instruction design and how it differs from AArch32, the instruction set characteristics that matter to compilers and hand-written assembly, exception levels EL0 to EL3 and the privilege model, the weak memory model and the barriers and acquire-release semantics it forces, and the MMU with translation regimes, page table formats and TLB behaviour.

03 SKILL.md 正文

ARM: AArch64, Instruction Set Characteristics, Exception Levels, the Memory Model, and MMU and Translation

Part 2 of 6 of the ARM: A Deep Dive reference (plugin arm-architecture-deep-dive), covering §5–§9. Sibling skills: arm-what-arm-is-licensing-families-and-isa-generations (§0–§4), arm-vectors-atomics-numerics-and-security-architecture (§10–§15), arm-system-architecture-boot-and-virtualization (§16–§20), arm-cortex-m-toolchain-porting-and-performance (§21–§25), arm-reference (§26–§31). Section numbers are shared across the set; a reference written as §N → skill points into that sibling skill.

Currency: The architecture is documented and stable. Two things moved decisively. See §26 → arm-reference for Arm's business model, and its actual market position.

⚠️ ARM is a business model as much as an instruction set, and you cannot understand the architecture without understanding that. ⚠️ The design choices — modularity, optional extensions, profiles, strict architectural compliance — exist because the ISA has to be implementable by dozens of independent companies at wildly different power and performance points.

Builds on a microarchitecture reference (§20 ISA design, §8 memory consistency) and a semiconductor reference. Complements a digital-logic reference for the boot chain and a computer-hardware reference for the datacentre context.

⚠️ GOTCHA boxes mark where ARM differs from x86 in ways that break assumptions.

The three ideas that organize this document:

  1. ⚠️ THE ARCHITECTURE IS A CONTRACT, NOT A CHIP (§1 → arm-what-arm-is-licensing-families-and-isa-generations, §4 → arm-what-arm-is-licensing-families-and-isa-generations). "ARM" names a specification that Apple, Qualcomm, Amazon and a microcontroller vendor all implement completely differently. Statements about "ARM performance" are usually category errors.
  2. ⚠️ THE WEAK MEMORY MODEL IS THE MOST CONSEQUENTIAL DIFFERENCE FROM x86 (§8, §23 → arm-cortex-m-toolchain-porting-and-performance). Concurrent code that is correct on x86-TSO can be silently broken on ARM with no source change. This is the single most common real porting failure and it produces intermittent bugs.
  3. ⚠️ SECURITY IS ARCHITECTED, NOT BOLTED ON (§13–§15 → arm-vectors-atomics-numerics-and-security-architecture). TrustZone, pointer authentication, BTI, MTE and CCA are architectural features with silicon support — which is genuinely different from mitigation-by-software, and it is a large part of why ARM won mobile.

§5. ⚠️ AArch64

⚠️ A clean-sheet design, and its choices are instructive because they were made with forty years of hindsight.

⚠️ REGISTERS  ⚠️ 31 general-purpose (X0-X30, or W0-W30 for
   32-bit views), ⚠️ plus a ZERO REGISTER (XZR/WZR) and a
   separate stack pointer
   ⚠️ COMPARE x86-64's 16 — ⚠️ more registers means less
   spilling, and it is one of the genuine ISA-level differences
⚠️ ⚠️ WHAT AArch64 DELIBERATELY REMOVED from AArch32
   ⚠️ CONDITIONAL EXECUTION on nearly every instruction —
      ⚠️ ARM's famous feature, dropped because it complicates
      out-of-order register renaming badly
   ⚠️ ⚠️ THE PC AS A GENERAL REGISTER — ⚠️ AArch32 let you write
      to r15 and branch. Elegant, and a nightmare for
      implementation and security
   ⚠️ Load/store multiple with arbitrary register lists
   ⚠️ The barrel shifter on every operand (⚠️ retained in
      reduced form)
⚠️ WHAT IT KEPT  ⚠️ FIXED 32-BIT INSTRUCTION LENGTH (⚠️ which
   makes parallel DECODE far easier than x86's variable
   length — see a microarchitecture reference §20) ·
   load/store architecture · condition flags (NZCV) ·
   ⚠️ conditional SELECT instructions (CSEL) replacing
   predication
⚠️ ADDRESSING MODES  base+offset, pre/post-indexed, scaled
   register, PC-relative — ⚠️ and PC-relative addressing plus
   ADRP is how position-independent code works efficiently

§6. Instruction Set Characteristics

⚠️ Load/store architecture — ⚠️ arithmetic operates on registers only, so memory access is explicit; this makes the memory model (§8) analyzable. ⚠️ Load/store PAIR (LDP/STP) — ⚠️ two registers in one instruction, heavily used in prologues and epilogues. ⚠️ CSEL and the conditional-select family — ⚠️ branchless selection without full predication. ⚠️ Bitfield instructions (UBFX, SBFX, BFI) — ⚠️ single-instruction extract and insert, notably better than the x86 equivalents. ⚠️ Encoding constraints: ⚠️ immediates are limited by the fixed 32-bit width, so large constants need MOVZ/MOVK sequences or a literal pool — ⚠️ which is why disassembly shows apparently redundant instruction pairs. ⚠️ System registers are accessed via MRS/MSR, ⚠️ and the naming convention (REG_ELx) tells you which exception level owns it (§7). ⚠️ Code density: ⚠️ AArch64 is denser than fixed-32-bit RISC traditionally was but less dense than Thumb-2 or x86 — a deliberate trade for decode simplicity.


§7. ⚠️ Exception Levels

⚠️ The privilege model, and it is cleaner than x86's rings.

⚠️ THE LEVELS  ⚠️ EL0 (applications) · EL1 (OS kernel) ·
   ⚠️ EL2 (HYPERVISOR) · ⚠️ EL3 (SECURE MONITOR — the highest,
   and where the world switch happens, §13)
⚠️ ⚠️ EL2 EXISTING AS AN ARCHITECTED LEVEL is the key difference
   from x86, where virtualization was retrofitted. ⚠️ The
   hypervisor has its own level, its own registers and its own
   translation regime by design (§20)
⚠️ ⚠️ ORTHOGONAL TO THIS: SECURITY STATE (§13). ⚠️ Secure and
   Non-secure worlds each have their own EL0/EL1, so the
   privilege model is TWO-DIMENSIONAL. ⚠️ ARMv9's CCA adds a
   third dimension with Realm state (§15)
⚠️ EXCEPTION HANDLING  ⚠️ a VECTOR TABLE indexed by exception
   type AND by the level/state the exception came from ·
   ⚠️ ELR (return address), SPSR (saved state), ESR (⚠️ the
   syndrome register, which tells you WHY — enormously useful
   for debugging)
⚠️ ⚠️ EXCEPTIONS ROUTE UPWARD, and where they route is
   CONFIGURABLE via HCR_EL2 and SCR_EL3 — ⚠️ which is what lets
   a hypervisor trap and emulate specific guest operations
⚠️ SYNCHRONOUS vs asynchronous (IRQ, FIQ, SError) ·
   ⚠️ FIQ historically the fast interrupt, now largely used for
   secure-world interrupts

§8. ⚠️ The Memory Model

⚠️ §1 → arm-what-arm-is-licensing-families-and-isa-generations's second organizing idea, and the thing most likely to bite you. See a microarchitecture reference §8 for consistency models generally.

⚠️ ⚠️ ARM IS WEAKLY ORDERED. ⚠️ Loads and stores can be reordered
   far more freely than on x86-TSO — ⚠️ store-store, load-load,
   load-store and store-load reordering are all permitted where
   no dependency exists
⚠️ ⚠️ THE PRACTICAL CONSEQUENCE: CONCURRENT CODE THAT IS CORRECT
   ON x86 CAN BE BROKEN ON ARM WITH NO SOURCE CHANGE. ⚠️ x86's
   stronger model HIDES missing synchronization. ⚠️ The bugs are
   intermittent, load-dependent and hard to reproduce
⚠️ THE BARRIERS
   ⚠️ DMB  data memory barrier — orders memory accesses
   ⚠️ DSB  data synchronization barrier — stronger, waits for
      completion
   ⚠️ ISB  instruction synchronization barrier — ⚠️ needed after
      changing system state that affects instruction fetch
   ⚠️ Each takes a SHAREABILITY DOMAIN and access-type qualifier
      (ISH, OSH, NSH; LD, ST) — ⚠️ using the weakest sufficient
      variant matters for performance
⚠️ ⚠️ ACQUIRE/RELEASE IS BUILT INTO THE INSTRUCTIONS
   ⚠️ LDAR (load-acquire) and STLR (store-release) — ⚠️ ordering
   semantics without a separate barrier, and generally FASTER
   than a full DMB. ⚠️ This is the idiom to use
⚠️ ⚠️ ADDRESS, DATA AND CONTROL DEPENDENCIES provide some
   ordering for free — ⚠️ and relying on them is subtle and
   compiler-hostile, because the compiler may optimize the
   dependency away
⚠️ MEMORY TYPES  ⚠️ NORMAL (cacheable, reorderable, speculatable)
   vs ⚠️ DEVICE (nGnRnE through nGRE — ⚠️ device memory
   attributes control gathering, reordering and early
   acknowledgement, and getting these wrong on MMIO causes
   baffling driver bugs)
⚠️ CACHE MAINTENANCE  ⚠️ ARM requires explicit cache maintenance
   in places x86 does not, particularly for ⚠️ SELF-MODIFYING
   CODE and JITs — ⚠️ instruction and data caches are not
   coherent, so a JIT must clean D-cache and invalidate I-cache

§9. MMU and Translation

⚠️ Translation regimes are per exception level and per security state, ⚠️ which is why there are so many system registers. ⚠️ TTBR0 and TTBR1 — ⚠️ two base registers split by address range, so user and kernel mappings live in separate tables and a context switch changes only TTBR0. ⚠️ This is architecturally cleaner than the x86 arrangement and made Meltdown-style page-table isolation cheaper. ⚠️ Granule sizes of 4 KB, 16 KB and 64 KB — ⚠️ note that 16 KB is what Apple uses, and it is a real source of porting friction for code that assumes 4 KB pages. ⚠️ Multi-level tables, up to 4 or 5 levels, ⚠️ with configurable address size (TCR). ⚠️ ASIDs and VMIDs avoid TLB flushes on context and VM switch. ⚠️ STAGE 2 TRANSLATION is the virtualization feature (§20 → arm-system-architecture-boot-and-virtualization): ⚠️ the guest's "physical" address is translated again by the hypervisor's tables — architected, not emulated. ⚠️ TLB maintenance is explicit and has broadcast variants, ⚠️ and TLBI instructions plus the required DSB/ISB sequencing are a classic source of subtle kernel bugs.

04 同仓库更多 Skills

the-vibey-project
the-vibey-project/vibey

white-paper-writing

Use when writing white papers, technical reports, policy documents, thought leadership pieces, or any long-form authoritative document. Triggers on requests to write, structure, outline, or review white papers, technical reports, position papers, policy briefs, or evidence-driven arguments. Also use for B2B content marketing strategy, technical documentation requiring authority, academic-style reports, or any document that must educate while persuading. Use when someone asks "how should I structure this" for a long-form document.

★ 5
the-vibey-project
the-vibey-project/vibey

prose-technical-mechanics

Use when editing or writing prose at a technical/mechanical level: choosing between Anglo-Saxon and Latinate diction, placing information in topic vs stress positions, writing periodic vs cumulative sentences, handling sentence rhythm, punctuation as logic, transitions, paragraph structure, or phonesthetics. Use when someone wants to understand WHY prose works or doesn't, not just surface-level style advice. Triggers on word choice, sentence structure, emphasis, rhythm, diction, or any deep writing mechanics question.

★ 5
the-vibey-project
the-vibey-project/vibey

prose-mechanics

Use when writing, editing, or analyzing prose style; when trying to avoid generic AI-sounding writing; when applying specific prose styles such as journalistic, academic, narrative, KJV biblical, Hemingway plain, Latinate/Jamesian, Orwellian, Augustan, Victorian, Early Modern (Bacon, Browne, Milton), or free indirect discourse; or when coaching someone on writing voice and mechanics. Triggers on any request to improve, analyze, or write in a specific prose style, to fix "AI-sounding" writing, to make prose more vivid or concrete, to vary sentence rhythm, or to understand how a particular writer achieves their effects.

★ 5
the-vibey-project
the-vibey-project/vibey

narrative-structure

Use when structuring stories, pitches, presentations, white papers, or any persuasive narrative; analyzing the hero's journey in fiction or non-fiction; applying StoryBrand for business communication; designing narrative arcs for thought leadership; or understanding Vogler, Snyder, Propp, or Campbell frameworks. Triggers on any narrative structure, storytelling, pitch structure, StoryBrand, hero's journey, three-act structure, Freytag, Save the Cat, narrative arc, or "how should I structure this story/pitch/presentation" request.

★ 5
the-vibey-project
the-vibey-project/vibey

legal-brief-writing

Use when writing legal briefs, motions, or any court filing; when analyzing judicial cognition and persuasion; when applying elite brief-writing techniques from Roberts, Clement, Kagan, Garner; or when structuring legal arguments for maximum persuasion. Also use for autistic/neurodivergent advocates who need to understand how their natural communication style maps to elite legal advocacy. Triggers on any legal writing, brief drafting, motion preparation, or legal argument structuring request.

★ 5
the-vibey-project
the-vibey-project/vibey

journal-publishability-criteria

Use whenever a research paper, article or preprint is being written, revised, reviewed or published, and specifically before every publication of docs/paper.md. Covers what legitimate journals actually gate on, in order of gating — the editor's desk screen (scope, novelty, package problems), what reviewers judge (methodological soundness, claims the evidence can carry, statistical and qualitative reporting), EQUATOR reporting guidelines, the ICMJE authorship criteria, COPE's view of text recycling, the near-universal generative-AI policy (no AI author, disclosure, author responsibility), TOP 2025 transparency standards, how to verify a journal is legitimate, submitting without an institution, and a pre-submission checklist. Triggers on requests to evaluate, review, prepare or submit a paper, to judge publishability, to write a declarations or data-availability section, to disclose AI use, or to check a journal.

★ 5