Skip to content

P3 (aarch64): Stage 5 — MakePool, DeriveSubframe, chunk-loop Untyped reset and stale-ASID unmap in the dispatch; VSpace uniqueness, frame containment and caps_no_overlap in the record - #158

Merged
losfair merged 1 commit into
losfair:mainfrom
CommaBot:a64-p5-stage5
Dec 6, 2026

Conversation

@CommaBot

@CommaBot CommaBot commented Dec 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Stage 5 of the AArch64 P3 refinement proof builds on Stage 4 (#156). It adds five dispatch arms that were declared limits or missing, strengthens three record invariants, and removes three premises.

New dispatch arms

  • ASIDControl MakePool.
  • ARMPageDeriveSubframe.
  • The chunk-loop Untyped reset, both preempted and completed.
  • The stale-ASID page-table unmap. This case previously had no arm at all.

Strengthened record invariants

  • VSpace root and page-table uniqueness.
  • Frame containment in heap objects.
  • Frame caps_no_overlap.

Removed premises

  • hnoDeadTcb and FrSubSiteA are gone, and the decode-site hfr is removed.
  • The MakePool arm derives hT, hYAs and hcO from the record instead of taking them as constructor fields.

Rust, extraction and the spec port are unchanged. The PR changes proofs/Fl4ProofsA64/**, the root import list proofs/Fl4ProofsA64.lean, DESIGN.md §9 and README.md; proofs/Fl4SpecA64/**, crates/ and xtask/ are identical to main. Diff vs main ed6b92799: 331 files, +24,208 / −2,112.

New dispatch arms

Arm Group / constructor Key modules Notes
ASIDControl MakePool VsScopeA.asidMakePool Stage3PoolTopA, Stage3Pool{Shape,Mem,SysEnd,Rec,J5,End,Fin}A, Stage3PoolCoreA (PoolCtxA), Stage3T3PoolA The whole record after the call is assembled from field-group modules over a shared context. The Stage-4 premise hnoDeadTcb is replaced by McGrowA.
ARMPageDeriveSubframe VsScopeA.frameDeriveSub Stage3ArmSubframeA (JStage3A.deriveSubframeA, subframesA), Stage3T3ArmSubA, FrSubframeJ5A, P1/S1aSub*, P1/MdbSubFrA, P1/MdbInvSubA, Stage3CnInsSubA Built from the n-fold insert_subframes loop over the generalised capInsertGenA (UA ∨ SubA), with no copied proof. derive_subframe_jA has an Ok-continuation (ArchTopSubA), and its Err callers keep ArchTopErrA.
Untyped reset, preempted UtPreScopeA.retypeRstPre UtRtReset*A, Stage3AfterPreemptA Lands in A64RelPS3 with PreExitA.
Untyped reset, chunk loop completed UtScopeA.retypeRstBig UtRtReset*A BodyOKA after the clock moved comes from DelBudA at each passed preemption point.
Stale-ASID page-table unmap VsScopeA.ptUnmapT2Stale Stage3ArmPtUnmStaleA, Stage3T3ArmStaleA, VsUniqStaleA Covers unmapping a mapped Stage-2 table whose ASID no longer names a Stage-2 root (FL4: ept.rs finalise → delete_asid, then unmap_page_table returns early; spec: extKindOfAsid = none → l4v pageTableUnmap). This had no dispatch arm before Stage 5. ptUnmap_runA selects it by ASID kind. It needs no premise: "no reachable descriptor names ptr" is VsUniqA.no_reach_stale.

Record invariants

  • VsUniqA (P3/VsUniqA) gains two fields:

    • rootOnce: an unmapped root-kind cap of r (Pml4, level-0 Ept, HighVSpace) is the only root-kind cap of r, and r is installed at no ASID. ASIDPoolAssign therefore keeps rootInj1/2, and DelAsid/DelAsidPool can drop exactly the deleted ASID's walks (VsUniqClearA).
    • ptOnce: an unmapped PageTable cap of r is the only PageTable cap of r.

    How the invariant is maintained:

    • Closure lemmas. The step obligation PtClosedA is now the record {pt, root, ptu}, and the closure lemmas are written once as a generic UClosed (VsUClosedA) instantiated for both classes.
    • Unmap. Unmap obtains uniqueness from FL4's finality check (vspace.rs:1098, FinPtNoOtherA).
    • Retype. Retype obtains it from existing fields, with no new invariant: ptCapIn/hoff for tracked tables, J9 UnmTabA.spec and J3 SpecFreeA.heap for the rest.
    • ASIDPoolAssign. The ASIDPoolAssign T2 arm now shrinks T2 before the cap write.
  • FrAt containment (e0). A non-device frame cap names a range inside a heap other object, not an exact-size object at its base. The untyped drop/undrop laminarity is derived from RegionIn (l4v valid_untyped) via UtRV.rin, with no frame-specific premise.

  • FrLamA (frame caps_no_overlap). This is the third conjunct of FrBaseApartA, the A64 counterpart of x86 NoOverlap / l4v caps_no_overlap for large frames. It is maintained at every cap writer, retype, pool and boot, and DerivA tracks frame ranges. It is a [J] record conjunct.

Premises removed or derived

  • hnoDeadTcb (MakePool, Stage 4): gone, replaced by McGrowA.
  • hfr (DeriveSubframe decode site): removed, not derived. It was only used for a CarryA conjunct of derive_subframe_jA whose sole consumers are Err-only (decInv_arch_jA → Stage3DecErrVsA / Stage3DecErrPtA). The CarryA / finMA_insFrameA chain is deleted.
  • FrSubSiteA (Err path): derived and removed from Stage3DecErr* / SendErrAllA. The 2 MiB alignment and canonical form come from FrAt and JStage3A.largeFrAlCanA.
  • MakePool constructor fields: hT (JStage3A.offAsE), hYAs (JStage3A.yNotAsW) and hcO (OSOK.canon) are now derived from the record.
  • frameDeriveSub: hcO is derived from the record.
  • ptUnmapT2Stale: hTO/hEO are derived from the record.

Statement changes

  • prst. The preempted record is stated at a hidden view, like the entry record from R1 in Stage 4: A64RelPS3 := ∃ m', McGrowA m m' ∧ A64RelPS3fx … m'. Only HPreEnvA.hSend / hPre_ofA.hSend move to the hidden m'. They are ∀ m' under the run antecedents DispatchInvokeAtA … → handle_invocation … = ok (.Err Preempted, s', a') → ∀ m', A64RelPS3at … m m' → …. The premise linter reports these as 4 new UNGUARDED(record) rows (hSend | ∀ m' : McState in ptUnmapBodyA, hPre_ofA, kernelEntrySend_recGA, syscallSend_refinesA), because A64RelPS3at is in its skipNames. They are guarded by the preempted run, and the witnesses discharge them (A64Wit2TierA:276, A64WitUtTopA:481).
  • ptUnmapBodyA / ptUnmap_runA. The selector hT2 is now required only for Stage-2 / window-root kinds. Stale and Stage-1 kinds go to the new arm with no premise.
  • derive_subframe_jA. The postcondition is now ArchTopSubA, with the Err half unchanged and an Ok half that gives the decode's success view. ArchTopSubA.toErrA serves the previous callers.

Premises of the new arms (DESIGN §9 has the full list)

  • MakePool:
    • [P] the platform facts (ArchTotal, ArchPlat, A64FrameMasks; hn: the arch's s2_ipa_bits is the spec's s2IpaBits);
    • [P] hCs;
    • [S] one core (h1, hnN, as for the IPC/SchedContext/Domain groups);
    • [W] the tracked-CNode facts of the destination and parent (hdc/hCp/hCd, the same shape as CnScopeA.cnodeCopy's);
    • decode-determined facts.
  • DeriveSubframe, ptUnmapT2Stale: no new named premise.
  • Untyped reset arms: those of the other Untyped arms, plus [P] DelPlatA, the entry clock and CounterStepA. Which arm applies is a case hypothesis on the reset_untyped run.

Non-vacuity

  • Every top keeps its mechanized witness (wit_send_nonvacuous, wit_ut_nonvacuous, wit_recv_nonvacuous, wit_comb_nonvacuous, wit_runexit_nonvacuous / wit_runvppi_nonvacuous, wit_irq_nonvacuous).

  • New this stage:

    • wit_ut_nonvacuous is an end-to-end Untyped Retype into the root CNode that satisfies every premise of the Send top.
    • The message-register tables are merged into one.
  • The Stage-5 arms have premise-level witnesses at most:

    • A64WitVsArmsA covers ptMapHi / ptMapS2 / frameMapS2 / ptUnmapT2;
    • A64WitSubA covers the DeriveSubframe decode up to insert_subframes and the pure inputs of subframesA;
    • wit_utChunk_prems covers the chunk-loop resets;
    • asidMakePool and ptUnmapT2Stale have no arm witness.

    §9 lists what each does not show.

Declared limits and backlog (DESIGN §9)

  • Device Untyped.
  • The Stage-1 / high-window shrink, together with tightening the temporary PtFreshA disjunct (mp = false ∧ ptr ∉ T2; this weakens an invariant, it is not a premise).
  • vsx-P and ptUnmapT2Z. ptUnmapT2 still carries [J] hUniq.
  • Removing FrMapSiteA (needs a RAM-frame window clause in utWin).
  • Moving the Copy arm to of_capDerivCnA.
  • Arm-level run witnesses (MakePool, DeriveSubframe SubInv, the chunk-loop resets) and the full VS-world witness.
  • The guest-resume finish and the other guest entries.
  • SMP (numNodes = 1).

Verification

  • lake build Fl4ProofsA64, cold (fresh lake, no cache) at 5f26fb509: 8,995 jobs, 0 errors, 0 sorry, 52 min 38 s.
  • The two review-fix commits on top (+40/−42; they remove constructor fields, derive them from the record, and edit docs) were built incrementally: 8,995 jobs, green.
  • Axiom scan: 2,630 modules and 136,166 declarations depend only on propext, Classical.choice and Quot.sound. A #print axioms spot check on the 20 linter tops plus JSyscallA.frameDeriveSubA, JSyscallA.ptUnmapT2StaleA, JSyscallA.asidMakePoolA, JStage3A.asidMakePoolA, JStage3A.subframesA and JStage3A.ptUnmapT2StaleA gives the same result.
  • No sorry, admit, native_decide, bv_decide, axiom, unsafe, implemented_by or opaque in the added proof code. All 78 new .lean files are imported from Fl4ProofsA64.lean.
  • Premise linter (the same out-of-tree linter as for P3 (aarch64): kernel-entry refinement over the syscall, fault and VM-exit entries, with a mechanized non-vacuity witness (Stage 3) #155/P3 (aarch64): Stage 4 — interrupt-entry top, remaining TCB/IPC/Domain arms, Untyped Retype, VSpace Stage-2/high-window arms, record-extension refactor, witnesses for every top #156, 20 tops), compared with Stage 4: guarded 226, wp 1491 and plain 124 are unchanged. UNGUARDED(record) goes from 80 to 84; the 4 new rows are the run-guarded hSend ∀ m' explained above.
  • Independent review by Claude Fable 5.2: APPROVE after one round of fixes. Its P1 was that the MakePool arm passed state facts as constructor fields; those are now derived from the record.
  • A separate static audit also passed. The proof gate is self-hosted and needs the owner's approval for fork PRs, so the builds above were run on our build host.

🤖 Generated with Claude Code

…ped reset and the stale-ASID unmap in the dispatch; VSpace root/page-table uniqueness, frame containment and caps_no_overlap in the record

Built from par/a64-p5-int. See the PR description for the new arms, the record invariants, the removed premises and the declared limits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@losfair
losfair merged commit d73be29 into losfair:main Dec 6, 2026
1 check was pending
CommaBot added a commit to CommaBot/FL4 that referenced this pull request Dec 6, 2026
…into par/a64-p6-int

Merged against the base 6c92d26 (main's Stage-5 squash has the same tree), so only the
Fl4SpecEquiv additions and the two PORTING.md edits come in.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants