Skip to content

P3 (x86): refine VM and EPT operations through kernel entry - #150

Merged
losfair merged 1 commit into
losfair:mainfrom
CommaBot:pr/mmuad-stage2
Dec 2, 2026
Merged

losfair merged 1 commit into
losfair:mainfrom
CommaBot:pr/mmuad-stage2

Conversation

@CommaBot

@CommaBot CommaBot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Scope

This completes the x86 VM Stage-2 serial core-entry refinement over VmEptState and the extended abstract spec. The result relates each covered entry to a spec outcome and returns the joint VM relation through VEAny. The relation tracks the common kernel state, the VCPU images and bindings, and the EPT tables. The change is confined to Lean proofs, the saved-IRQ extension and status documentation. The Rust kernel, x86 extraction, ported seL4 spec and AArch64 proof and spec trees have no changes in this commit.

Theorems

  • VmEptState.decodeDisp assembles the per-capability decoder results in VDispAll. These include VCPU operations and replies, owned I/O ports, EPT table and frame operations, CNode labels 25–32, untyped retype and reset, EPT-root assignment and SetEPTRoot. The EPT-mapped frame cases include unmap, address, subframe and accessed-bit operations, plus the corresponding invalid-label and wrong-mapping guards. The separately proved capDelete and cnodeDecodeAll are carried forward into this dispatcher.
  • VmEptState.dispatchAt discharges the VCPU, EPT-table, EPT-mapped frame and I/O-port routes at entry. It takes VDispNativeAt for the Vs.NativeCap branch, including the CNode, untyped, TCB and ASID-pool cap routes. handleInvocationE, afterV and VmEptPre.preemptPathVFk carry success and preemption through the joint state. scheduleVF and finishVF compose timer awakening, scheduling, activation and the current VCPU check.
  • VmEptState.dispatchV and VmEptState.kernel_entry cover native syscall dispatch and entry. Separate entry theorems cover vmEnterEntry, unknownSyscallEntry, trapSyscallEntry, interruptEntry, userExceptionEntry, vmFaultEntry, vcpuExitStalled and vcpuExitUnstalled. The VMEnter proof covers VMX and SVM staging, notification completion and the budget-declined arm. The unstalled-exit proof composes timestamp, VCPU check and budget charge through VmEptState.checkTimestampHole, including exhausted-budget outcomes and timeout suppression while the thread remains runningVM.

Named premises

Tag Premises and where they apply
[J] KEntryArmsV.budget relates the budget test after the FaultIP write. fast relates accepted ReplyRecv and requires a decline to leave the state unchanged. disp is the native-capability dispatch agreement at a reached invocation. orc is VmOrc at each related preempted outcome. recv covers Recv, NBRecv, Wait and NBWait. recvMid covers the receive after a non-preempted ReplyRecv, NBSendRecv or NBSendWait first phase. yield covers Yield. fin supplies KFinVE at each reachable finish.
[J] KFinVE carries hd (domainTime ≠ 0 ∨ NdOK), orc (VmOrc), arch (ArchSwF), archNd (ArchNdF), fo (FpuOwnOK) and idle (IdleVt). The outer event and VCPU-exit theorems quantify the same fields at each reached finish via EventFinishVE and VcpuExitFinishVE.
[J] Entry uses VmEptState, Entered or the resumed/current-thread facts where required, the current thread outside its ready queue, and the native valid-fault-handler projection. ZvCtRun supplies the running host caller where required. Timestamp and charge use ValidMachineTime and Sched.OffReady. Fresh host IRQ uses ValidIrqMasks. Ordinary unknown syscall uses FastFaultOK for the outer fast-fault bridge.
[J] The standalone capability theorems retain their own state premises. The CNode and deletion arms use VxE, SpecGlob, PPR0, MRV and the relevant endpoint-queue (EpQPre), no-switch (Vs.NoSwitch), slot placement, CNode bound and argument/extra-cap relations. The other VDispAll fields retain the corresponding current-thread, cap/tag, slot, VCPU placement and buffer premises, including AbsSlot, Canonical, BufOut, VArgs, ExtraOK and ExtraRel2 where used. The VM proofs discharge SigVmDonJ3 and the VM signal tail. The shared scheduler's native instantiation still uses SignalJHypB.
[P] Store and architecture facts are P1.LawfulStore, P1.PlainStore, P0.StoreTotal, P0.ArchTotal, StoreExt, ARIface, ARKeep, ARMask and ArchRefines. Machine-state agreement is MR a σ.machineState and the applicable MachPlat/MachPlatC, MRKeep/MRKeepD, PPPlatA and IrqPlatA.
[P] Clock, budget, interrupt and fault premises are TimeAgree, SetDlDet (the native producer uses SetDlDetR), agreement on sporadic.min_budget and sporadic.max_release_time, the ticks_to_us and maxTicksToUs agreement, and the event-specific IrqHw, UserHw and VmfHw records. MachPlat supplies the timestamp agreement before charge, including after the fresh host IRQ read. ArchSwF and ArchNdF describe platform effects at the finish states above.
[P] Virtualization and I/O use ZvVirtAgree, the exact concrete backend-code agreement, ZvSyncKeep, VirtSanEq.CapAgree for VMX control sanitization, and PortInValAt/PortInValMR.
[W] No new spec-work premise.

[S] Boundaries

  • The theorems cover the serial core body after the entry gate and saved-register/capture work, with one scheduling domain and the single-core IRQ view. The existing trusted interfaces cover assembly, hardware guest execution, the captured VCPU image and the saved host vector. Separate local entry/exit fast paths and cross-core IPI handling are outside these statements.
  • Fresh host IRQ uses the native IrqHw agreement on the line selected by the oracle, with a vector below 256. For saved guest IRQs, SavedIrqAt relates the no-IRQ sentinel or the exact 8-bit vector. Both paths exclude remote-call IPI 126 and reschedule IPI 127. The saved path includes active and inactive device vectors and non-IPI vectors above the device range. A stalled exit skips timestamp, VCPU check and charge, and still handles its saved vector and finishes.
  • Native syscalls use the signed native range −11 through −1 with the trap flag clear. VMEnter is signed −23 with the trap flag clear, an agreed enabled backend and a bound VCPU. The ordinary unknown case uses UnkSys (out-of-range number or set trap flag) and NoDbgSys (excludes debug/TLS calls −12 through −20 and requires a disabled backend or lack of a VCPU binding for −23). The spec must select the ordinary fault case. A trapped −23 for which the spec selects VMEnter therefore falls outside that case. Trap vectors are below 256 and use FL4's zero-extended payload convention. Host fault arguments use the native hardware agreements listed above. NativeScope is confined to native compatibility lemmas.

Spec extension and shared statements

  • Fl4Spec/Ext/VirtExitIrqF.lean adds handleSavedIrqVF, vcpuExitPrefixVF and fl4VcpuExitSavedVF. A captured inactive device vector is masked and acknowledged. The other vectors reuse handleInterruptVF, and the optional saved vector requires no fresh IRQ selection. The new module is documented in proofs/Fl4Spec/PORTING.md.
  • The JHole and JTH entry witnesses use JAtZB. Their charge, budget and timeout result families also carry NatFoot, including JHole.chargeBudget*, JHole.checkBudget*, JHole.toJ and the JTH.endTimesliceTmo* and timeout IPC results. The native projections JAtZ.ppJHC, ppJHM and preHoleC retain the separate JExt witness. The shared preemption-path and post-invocation families use source-indexed JAtN in the results in place of the former JAt, JStab and PPQJI forms, removing the corresponding VxE requirements.
  • The shared awaken and scheduler statements (awaken_refinesW*, schedule_refinesW*) parameterize the timer transition relation. Native callers instantiate it with Fires. The shared queue/state invariant statements (oiQ, OIK, OIKE, OIS, oi_setThreadState) take OIx, tracking either the idle state or runningVM and the threads allowed in that state. jowes_slotDFH takes JAtZB. The frame-alias statements (MdbStep.frameAlias, Vs.FrameInv.alias', VsMdbInv.frameAlias) accept the source EPT bit while retaining the unmapped destination requirement.

Verification

The single CommaBot commit 08cf8d52c3f0dd513b8056b4b70c423798a36b16 has parent c16cc0aca44ff7436ca558d984f46db8eda16aea and changes 157 files. It is the verified squash a7e422600 with 49 unimported per-generation scratch scripts under proofs/scratch/ax73–ax82 removed; every other path is byte-identical. The following ran on the verified snapshot on afkprover.

  • The targeted entry/spec and shared-gate build passed 9,668 jobs. The full default x86 lake build passed 10,493 jobs. Both reported zero errors and zero sorry warnings.
  • The full x86 root AX sweep checked 250,835 declarations in the FL4 proof, spec, gate and extraction namespaces. All 1,662 named cumulative AX checks passed. Each result uses only propext, Classical.choice, Quot.sound or has no axiom dependency.
  • The added-line audit found zero sorry, admit, axiom, opaque, native_decide or bv_decide hits, including under Fl4Spec/Ext/. The final source hashes were rechecked after the build and AX sweep.

🤖 Generated with Claude Code

Connect VM and EPT capability dispatch, VMEnter, host faults and interrupts, and both saved-vector VCPU exit paths to the VM-aware schedule and finish.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@losfair
losfair merged commit e958f61 into losfair:main Dec 2, 2026
1 check failed
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