Repository navigation
P3 (aarch64): kernel-entry refinement over the syscall, fault and VM-exit entries, with a mechanized non-vacuity witness (Stage 3) - #155
Merged
Conversation
…exit entries, with a mechanized non-vacuity witness (Stage 3) Stage 3 of the AArch64 P3 refinement proof (Lean 4, `proofs/Fl4ProofsA64`): FL4's slow-path kernel entries refine the spec's `call_kernel` body from `kBodyA` through `syscall.finish`, for the syscall dispatch groups, the fault and VM-exit entries, the preempted exit and decode errors. Every hypothesis is a named premise tagged [P]/[J]/[S]/[S4], and `kernelEntrySend_recGA`'s premises are shown jointly satisfiable (`wit_send_nonvacuous`, under the witness-world hypothesis `OpaqueWA`). Also extends the AArch64 spec port (`proofs/Fl4SpecA64`, documented in its PORTING.md), updates DESIGN.md section 9 and the README status, and relies on losfair#154 (already on main). No Rust or extraction change. Root `lake build Fl4ProofsA64` (last full build at the witness merge; later commits are docs and the losfair#154 merge): 8671 jobs, 0 errors, 0 sorry; axioms: propext, Classical.choice, Quot.sound. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Dec 5, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Stage 3 of the AArch64 P3 refinement proof: FL4's slow-path kernel entries refine the spec's
call_kernelbody, end to endfrom the entry's
kBodyAthroughsyscall.finish, for the system-call groups listed below, the fault and VM-exit entriesand the preempted exit. No Rust or extraction change: the PR changes
proofs/Fl4ProofsA64/**,proofs/Fl4SpecA64/**(see "Spec port changes"),DESIGN.md§9 andREADME.md. It is based on main82371d591(#154 included: lift3 merges main).Everything is stated against the Aeneas extraction (
Fl4CoreA64) and the AArch64 spec port (Fl4SpecA64), which this PR also extends (see "Spec port changes").What it proves (top theorems,
proofs/Fl4ProofsA64/P3/)kernelEntry_stage3AStage3KEntryTopAkOpAand leaves the record, andfinishis the producer's (hfin), then the entry refineskOpA >>= fl4Finishand the next record (KExitA) holdskernelEntry_recGAStage3SysTopAA64RelS3kernelEntry_recA(+userException_recFinA,vmFault_recFinA,unknownSyscall_recFinA)Stage3KEntryFaultFinAfinishdischargedkernelEntrySend_recGA/syscallSend_refinesAStage3SysSendAkernelEntryRecv_recGA/syscallRecv_refinesAStage3SysRecvAkernelEntryComb_recGA/syscallComb_refinesAStage3SysCombAkernelEntry_runExitA,kernelEntry_runVppiAStage3VcpuExitWireAJSyscallA.dispatchAStage3DispTopAafterPreemptA,hPre_ofA,HPreA.ofEnvStage3AfterPreemptA,Stage3HPreAafter_invocation (.Err .Preempted)), the callers'hPredischarged fromHPreEnvAJSyscallA.decErrSpecA,JSyscallA.sendBodyErrAllAStage3DecErrAllA,Stage3SendErrAllAErrarms of decode,hSpecdischarged)JSyscallA.setIpcBufZeroA,JSyscallA.setIpcBufNzAStage3LiftTcbBufA,Stage3LiftTcbBufNzA,Stage3TcbReschedAreschedule_required), non-device Frame source; a device-frame source or a misaligned / invalid buffer is a decode error (DecErrSpecPA.thread,decErrSpecA,sendBodyErrAllA)RecvPreA.recvPushUnbA,RecvPreA.recvSendUnbA,RecvPreA.unbCoreAStage3RecvUnbArmA,Stage3RecvPushCancelA,Stage3RecvSendABndUnbA) against a waiting sender, with or without a reply push; a reply object linked to another thread is cancelled first (case B oftake_reply), so the receive scope no longer assumes an unlinked reply objectDispatch groups (
DispScopeA,Stage3DispTopA): CNode, VSpace, IPC, SchedContext, TCB, cache maintenance, IRQ (IRQAck,IRQSetHandler,IRQClearHandler), one-word reply (ARMPageGetAddress,ARMPageTestAndClearAccessed), Domain (DomainSetSet), VCPU (labels 60–69, body/dispatch level:VcpuScopeA), and the non-archErrgroup.Not covered ([S] scope limits, see DESIGN §9): Untyped Retype / RetypeShared (
UtScopeAhas no constructor), TCB Configure / SetSpace / Read-, Write-, CopyRegisters / SetTimer / SetHighVSpace / breakpoints and single stepping, the SetSchedParams cases with a changed SC or another handler cap kind, DomainSchedule*, ARMASIDControlMakePool, ARMPageDeriveSubframe, Stage-2 and high-window map extensions, the T2 unmap shrink, Notification send to a bound thread running a VCPU. An uncovered invocation whose decode succeeds makes the top's scope premise false at that state.The interrupt entry arm is proved (
interrupt_serviceA,Stage3KEntryIrqA) but is not assembled into a top yet.Spec side
FinWorkHyp, reply and fault paths: see the DESIGN §9 text for what stays [J].Named premises at the tops
Every premise is a named hypothesis or record field with a tag in its docstring; none is
sorry/axiom. Axioms (#print axiomsover all 2,454 modules):propext,Classical.choice,Quot.sound.ArchTotal,MaxSpi,ArchPlat,IrqPlatA(maxSpionly),FaultEnvA(hCs,h1,hmb,hmax,htu),FinPlatA(arK,toUs,hmax,htu),ArchSwFA(backend realizes ordered root writes and the per-core register view), the four preemption-path agreements (hlimit,hag,hconv, GICv2v2),PlainStore,A64FrameMasks,IrqArchAandhMax(maxIRQ = 5375),SchedGapFreeA'sminAgreeandticks(hGap, below),PollAgreeA(the poll; since aarch64: Defer EL2 guest PPIs to IRQ entry #154 it carries the clause that a polled line is never a VGIC-maintenance or vppi-event line: aarch64: Defer EL2 guest PPIs to IRQ entry #154).hGap=SchedGapFreeAat the body's reached record (Stage3SysTopA): [S]oneDomain, [P]minAgree(fl4MinBudget = MIN_BUDGET), [P]ticks(ScCfgTimeAgreeA), [J]timer(the schedule-timer inputs andSniHypAafterswitch_sched_context, guarded by the run awaken → select → switch; the witness dischargeshGap,wit2b_hGapA, at any record state);JSyscallA/JStage3A(the syscall-entry record),JStage3EntryAandEntryBaseA(current-thread, idle and clock facts),VcpuEntryA(a guest entry),SysChargeA(the budget-exhausted branch after theFAULT_IPwrite),hSend/SendPA(the timeout send without a waiting receiver, guarded by the run that reaches the preempted state),IrqLineBaseA(active),NdOKA(domain-schedule words, including the node-count wordNUM_NODES = numNodes: F1).numNodes = 1,oneDomain/numDomains = 1,hCs,noResched, the receive scope limits E1–E6, N1, N2, the cap-fault handler endpoint andntfnSc = curSc(Stage3RecvScopeA), the combined-call limit F2/F3 (Stage3SysCombA), thereservedclause of the interrupt entry'sIrqLineA, and the faulted-caller Reply form (JSyscallA.replyFaultA,fault_w1 = 0/ shortUnknownSyscall).hNative/hNat(afinishafter which the current thread runs no guest: anARMVCPU_Runthat resumes the guest is outside the top) and the guest entriesvgic,vppi,vcpuExit,vcpuFault.OpaqueWA(P3/A64Wit2ArchA), the only hypothesis of the non-vacuity witnesswit_send_nonvacuous: facts aboutopaquespec constants that no Lean term proves or refutes (any value of the constant's type is a model;P3/A64Wit2PlatAgives the model values): one domain,maxIRQ = 5375, GICv2,numNodes = 1,maxTicksToUs = U64::MAX, kernel WCET 10 µs, 1000 ticks per timer unit, timer unit 1, a 10^9 Hz counter,fl4MaxPeriodUs = MAX_PERIOD_US, a monotone raw counter; and two properties of the witness world, not of FL4's platform:irq(the IRQ oracle only yields the VGIC maintenance line, a non-kernel IRQ) andhNow(the spec's clock and the raw counter agree at a state whose last observation is the next raw sample; both oracles are0). It is not a premise of any top theorem.Non-vacuity
A witness gate was run against the tops: a concrete store, arch and spec state satisfying every premise of
kernelEntrySend_recGA(par/a64-p3-witfor plan B;par/a64-p3-wit2+par/a64-p3-archswfor the mechanized one). It found nine problems, all fixed:IrqPlatA.nodeswas a ∀ over all store states on a memory word, unsatisfiable17b9eca13: dropped;NUM_NODES = numNodesis a record fact (NdOKA.nodes) kept by every write sethScopewas an unpinned ∀ overJSyscallAstatesaca88db91: pinned like Recv/Comb by the three entry equations (fl4SyscallFaultIP, post-writebudget_ok,fl4BudgetOk)HPreEnvA.hSendwas guarded by the relation, not the runDispatchInvokeAtA ∧ handle_invocation = ok (.Err .Preempted …)FaultEnvAP3/A64Wit2ArchA) that satisfiesFaultEnvA,NowAgreeA,FinPlatAand the platform agreements (ArchTotal,MaxSpi,ArchPlat,IrqArchA,SniHypA,ArRootKeepA)ArchSwFAhad no inhabitantpar/a64-p3-archsw+archsw2(2c3b1c72e):A64ArchSwA–H;witArchSwOf : ArchSwFA st AR1is unconditional (P3/A64ArchSwH), provingset_vm_root/set_kernel_vm_rootagainstthreadRootWritesA/kernelRootWritesAon core 0KERNEL_ROOTtie between the record andArchSwFA0c232114b:KERNEL_ROOTis a record fact (NdOKA.kroot,JStage3A.kroot);ArchSwFA.exec*take it from the record (ArchTieA)ArchSwFA's ∀ core quantifier unsatisfiable multicore(L.cpu s).val = 0, callers discharge it from the record (numNodes = 1); the SMP note is in §9Z.Y ∌ 0ArchSwFA.exec*, derived from the record (F4:h0 : H 0 = none+Z.Ymembership)RunLinkAArchSwFA.exec*, derived from the record (F4:VcRunA.run/.vtcb)Also the premise dedupe (
b17d946aa,aca88db91):reservedmoved from [S] to a [P] clause ofPollAgreeAon the preemption path,SendPAguarded at the reached record (no∀over records),ExitPlatAreplaces the platform factsHPreEnvAcopied fromFaultEnvA,EntryBaseAshared byVcpuEntryAandJStage3EntryA.Mechanized witness:
Wit.wit_send_nonvacuous(P3/A64Wit2TopA): for the model arch and the w1 boot state it exhibits a store, an arch state, a spec state and the ghost sets satisfying every premise ofkernelEntrySend_recGA(SendEntryHypsis the theorem's binder list), withwitArchSwOfas theArchSwFA;wit_top_sendalso derives the theorem's conclusion there. Everything is existential exceptOpaqueWA(witness-world [P]). The witness covers the Send/NBSend/Call top (CNode Copy at w1); the Recv, Comb and VM-exit tops share its platform premises but are not instantiated.Declared limits (DESIGN §9, "AArch64 P3 Stage 3")
Stage-4 ([S4]) list above; single-core
ArchSwFA(U7: per-core guard(L.cpu s).val = 0; multicore is not claimed);OpaqueWA(the witness world; not a premise of any top); still open within Stage 3 and marked in progress, not as limits: the interrupt top assembly and the sharedIrqEnvAdedupe.Spec port changes (
proofs/Fl4SpecA64/**, 27 files, +2,451/−260 vs main)The PR also changes the AArch64 spec port, which
PORTING.mddocuments (generations 6, 7, 8; each change has an Architect ruling there).New
Ext/*modules (FL4 differences from l4v, outside the port):Ext/FaultReply(FL4's reply to a fault: theTimeoutreply register order,sanitise_vcpu_spsr),Ext/IrqSignal(a signalled IRQ is masked and ack unmasks it, whatever the GIC version),Ext/Reply(reply budget and timeout delivery with FL4's minimum and counter conversion),Ext/SchedBudgetandExt/SchedControl(the platform release-time limit and the minimum in counter ticks),Ext/SchedTail(the schedule and reprogram decision, the timer view),Ext/Timestamp(the raw counter as the clock,CNTPCT_EL0/CNTVCT_EL0),Ext/UntypedVirt(the untyped decode's virtualization check),Ext/UserTop(fl4UserVtop). ModifiedExt/*modules:ARMVCPURun,ArchTypes,Entry,Finalise,Invocation,IrqControl,Stage2,Tcb,Timer,VSpace.In-port hooks (one-line
-- FL4 hookchanges inside the l4v-derived modules; all documented inPORTING.md):AARCH64/Structs.leanacap_rights,acap_fsize,acap_is_device,acap_map_data,update_map_data,arch_cap_is_device,acap_rights_update)AARCH64/VSpace.leanis_FrameCap,arch_derive_cap,arch_same_region_as,same_aobject_asfor a Stage-2 frameAARCH64/VSpace.leanfind_vspace_for_asidhides FL4's Stage-2 and high roots (thevspaceOptfilter)Machine.leanuserVtop := fl4UserVtop: FL4'sUSER_TOP(2^47 − 1), not l4v'spptrUserTop(a difference in value, not in shape: FL4's AArch64 kernel runs at EL1 with a 48-bit Stage-1 user half, l4v's AARCH64 at EL2)Decode.leandecode_vs_inv_flushcomparesendwithuserVtop(FL4vspace.rs933 usesUSER_TOP)AARCH64/Arch.lean,AARCH64/VCPU.lean,AARCH64/VSpace.leanreturn ()→pure ()at 3 + 5 + 1 sites (Leandoreturnis an early exit; Isabelle's is a no-op); not a semantic extensionreturn ()" (l. 55) and the VCPU fixes (l. 750)The semantic one to review is
userVtop: it makes the l4v decodersdecode_fr_inv_map,decode_pt_inv_mapanddecode_vs_inv_flushreject exactly what FL4'sdecode_page_map,decode_page_tableand the flush decode reject.Kernel-change dependency
losfair/FL4#154(82371d591, on main; lift3 contains it): after it, the preemption-point poll leaves the EL2 VGIC-maintenance and virtual-timer PPIs pending (like REMOTE_CALL), so a polled line is never reserved. The proof takes this as the [P] clause ofPollAgreeA; it is false against a kernel without #154.Build and reproduce
At
0a29cfba1(the last Lean change; later commits touch only docs, files and one docstring, with aMODE=modcheck ofStage3SysTopA): rootFl4ProofsA64Build completed successfully (8671 jobs), 0 errors, 0sorry, no skipped jobs. Axiom audit over all 2,468 modules / 131,253 declarations:[propext, Classical.choice, Quot.sound](AX_EXIT 0).Reproduce:
cd proofs && lake build Fl4ProofsA64, then a file withimport Fl4ProofsA64, a DFS overenv.constantscollecting axioms (asproofs/scratch/a64/…_ax.leandid; kept out of the PR) or#print axioms Fl4ProofsA64.P3.JSyscallA.dispatchA/…Sched.kernelEntry_stage3A/…kernelEntryComb_recGA/…hPre_ofA.CI note: the gate workflow re-extracts and checks only x86_64; this tree is checked by
lake build Fl4ProofsA64(README).Size
git diff --shortstat 82371d591 643ec103a: 1277 files changed, 417,297 insertions(+), 419 deletions(−):proofs/Fl4ProofsA64/**1,247 files, +413,569/−82 (1,228 new files, mostly new modules);proofs/Fl4SpecA64/**27 files, +2,451/−260;DESIGN.md,README.md. No file outsideproofs/other than those two;crates/andxtask/are identical to main. Noproofs/scratchfile differs from main.The PR carries the whole AArch64 P3 tree that is not on main yet: about 414k lines under
proofs/Fl4ProofsA64/**, almost all of it new modules, plus theDESIGN.md§9 /README.mdstatus. It is one combined PR for the stage and is published as one CommaBot commit (git commit-tree <lift3 tip>^{tree} -p <main>).Review notes
Every merge into
par/a64-p3-lift3was built with the rootFl4ProofsA64plus an axiom audit; the numbers above are the last full root build + AX, which ran at0a29cfba1; the commits after it (merge of main82371d591, removal of five stray files, docstring tags onSchedGapFreeA, docs) are Rust-only, docs, files and one docstring (MODE=modofStage3SysTopA: 7,160 jobs, 0 errors).🤖 Generated with Claude Code