Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,11 @@ The proof is staged so each level is useful by itself and later levels build on
- VCPU / EPT (the extended spec `Fl4Spec/Ext/Virt*`), on the joint state `VmEptState` (P3's relation with the VCPU list, the VCPU images and the EPT tables): retype of all 19 object types, the decoded untyped invocation including reset; the EPT syscall suite through FL4's dispatcher (`TCBSetEPTRoot`, EPT table map and unmap, `X86PageMapEPT`, the unmap of an EPT-mapped frame, `X86ASIDPoolAssign` of an EPT root); the VCPU report and detach chain; the IO-port cap's owner (`ArchCap.ioPortCap` carries it, decision Q2) and its revoke, finalisation and delete; a final thread cap's finalisation (VCPU detach, then the native tail); and FL4's `delete(slot, true)` against `capDeleteVF` for every cap (`VmEptState.capDelete`, the deletion loop with zombies, swaps and preemption); and every CNode invocation (labels 25–32: Revoke, Delete, CancelBadgedSends, Copy, Mint, Move, Mutate, Rotate) through FL4's dispatcher against `invokeCnodeVF` (`VmEptState.cnodeDecodeAll`): an error leaves the state unchanged, an `Ok` outcome is back at `VmEptState`, a preempted Revoke or Delete keeps the VM side's pre-state facts (`CnAllPostVE`).
- x86 VM Stage 2 reaches kernel entry. `VmEptState.decodeDisp` assembles the proved VM/EPT and common capability arms. The entry uses `VmEptState.dispatchAt`, which discharges the VCPU, EPT-table, EPT-mapped frame and owned I/O-port cap arms and takes the native-capability cases as a premise (`VDispNativeAt`). CNode, untyped, EPT-root assignment and SetEPTRoot have separate decode theorems, and their native-capability routing at entry is covered by that premise. `VmEptState.handleInvocationE` and `afterV` carry the invocation outcomes and preemption through the VM relation. `VmEptState.kernel_entry` composes the native syscall ABI paths with the dispatcher and VM-aware finish. The separate `vmEnterEntry`, `unknownSyscallEntry`, `trapSyscallEntry`, `interruptEntry`, `userExceptionEntry`, `vmFaultEntry`, `vcpuExitStalled` and `vcpuExitUnstalled` cover the other x86 core entry arms. They start from `VmEptState` and return a related extended-spec outcome at `VEAny`. The finish includes awakening, scheduling, activation and checking the current VCPU.
- Stage 2's [S] scope is the serial core entry after the gate, with one scheduling domain and the single-core IRQ view. Host interrupts use the native fresh-read `IrqHw` contract and `ValidIrqMasks`. Both fresh host and saved guest-exit vectors exclude remote-call IPI 126 and reschedule IPI 127. `VirtExitIrqF` covers an absent saved vector, active and inactive device lines, and saved non-IPI vectors above the device range. The trusted boundary includes entry/exit assembly, hardware guest execution, and the captured vector and VCPU image. Native syscall numbers are −11 through −1 with the trap flag clear. VMEnter (−23) requires a clear trap flag, an agreed enabled backend, and a bound VCPU. The ordinary unknown syscall theorem uses `UnkSys` (out-of-range number or set trap flag), `NoDbgSys` (excludes debug/TLS calls and requires a disabled backend or lack of a VCPU binding for −23), and the spec's ordinary-fault selection guard. Trap vectors are below 256 and follow FL4's zero-extended payload convention. The joint-state, native-capability, IPC and finish premises are listed in the entry and dispatcher modules.
- x86 VM Stage 3 replaces Stage 2's arm premises. `VEAnyX.outerS3` is one theorem over the nine concrete entries (`S3Ev`), from `VEAnyX` and the event's `S3Pre` to an extended-spec outcome at `VEAnyX`. Its syscall case, `VmEptState.kernel_entryS3`, takes the start record `StartS3` in place of `KEntryArmsV`, `VDispNativeAt` and the finish premises; the other cases take no `EventFinishVE` / `VcpuExitFinishVE`. The Stage 2 theorems are kept. The extended spec's FrameBatch (`performFrameBatchWith`) is parameterized by the deletion it uses, and the VM-aware step uses `capDeleteVF`.
- Stage 3's remaining premises. [J] `StartS3`: `X : SInvXV` (the native carried bundle without `NativeScopeS`), current thread not idle, `SpecIoPorts`, `SpecUtZ`, `DevRangeS`, `GpmOutV`, `UtInv''`, `RV`, `IdleVtS`; `S3Fault` and the scheduler, domain, FPU-owner, idle and clock facts of the other events. [P] `StartS3.air` (`ArchIrqRel`), the platform arguments of `outerS3` (including `FpuImplDet`, `FpuWriteDet`, `StoreExt`) and the hardware arguments of each event. [S] `StartS3.core` (`SelectedCoreScope` for the invoked capability of the current thread on the executing core: SchedControl names that core, Untyped only on core 0), and Stage 2's event guards above.
- Stage 3 non-vacuity: `JBootQ.VWit.witness_schedControl` and `witness_untyped` (`P3/VmWitS3`) give a concrete store, arch and spec state satisfying `VEAnyX ∧ S3Pre` for `SysCall` on a SchedControl cap and `SysNBSendWait` on an Untyped cap, with a `runningVM` TCB and its VCPU in the CSpace. The quantified fields `air` and `core` are not vacuous there: a dispatch pair exists (`w_dispatch`: the `FaultIP` write and a passing `budget_ok` on the FL4 side, a passing budget check on the spec side), and at it the invoked slot is looked up and decodes to the SchedControl / Untyped cap and `SelectedCoreScope` holds (`w_core_exercised`). The witness clock sits at the cap of `getCurrentTime` (`tW = -(getCurrentTime_buffer + 1)`), so the entry's time read is `tW` whatever the opaque `timeOracle` gives and the consumed time is 0; with the clock at 0 the budget check would depend on `timeOracle 1`. `air` asks for at least one IOAPIC (`ArchIrqRel`, as real x86): the witness arch `warV` is `warI1` (one IOAPIC of 24 pins, as the spec's `init_arch_state`) with the platform's `virtualization` code and VMX capability words. Premises: [P] `virtKind = .vmx ∨ .svm` (a running guest forces a backend) and [P] one scheduling domain. [J] `SInvXV` is an entry premise, as `SInvX` was; the witness satisfies it.
- `outerS3` at the witness (`P3/VmWitOuter`, `outer_schedControl`, `outer_untyped`): every platform argument of `VEAnyX.outerS3` is instantiated at `warV` / `wAR` / `ipiMR` (`ARIface`, `ZvVirtAgree`, `ZvSyncKeep`, `CapAgree`, `PortInValMR`, `MRKeepD`, `MachPlat`, `MRKeep`, `PPPlatA`, `IrqPlatA`, `TimeAgree`, `ArchRefines`, the budget and timer queries, `StoreExt`), so the theorem's conclusion holds at the witness for both entries. Left as [P] premises, all about opaque `Fl4Spec` constants and none about the arch: `OpaqueWK` (one domain, `maxTicksToUs`, kernel WCET and timer unit, the period bound, `setDeadlineImpl` determinism, a port-read value), `virtKind`, `retypeFanOutLimit = 256`, `resetChunkBits = 16`, `FpuImplDet`, `FpuWriteDet`.
- Stage 3 does not prove: that the post re-establishes `S3Pre` (no multi-entry run; `SInvXV` has no preservation theorem), a `VEAnyX` state from boot, or non-vacuity of the other events' `S3Pre`.
- Hypotheses still to discharge are named in each file. The main ones: the state facts after the TCB fault-handler install, finalisation of a final Endpoint, Notification, Reply, Thread or SchedContext cap on the spec side (`FinWorkHyp`; FL4's side and the VSpace cases are proved), the reply and fault paths, and the placement link between P3's typed heap and P1's object sets.
- The proofs so far found no disagreement between FL4 and the spec.

Expand Down
40 changes: 28 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -242,25 +242,41 @@ cap's owner, revoke and delete, capability delete of every cap
(`VmEptState.capDelete`), and every CNode invocation (labels 25–32:
Revoke, Delete, CancelBadgedSends, Copy, Mint, Move, Mutate, Rotate) at
that state through FL4's dispatcher (`VmEptState.cnodeDecodeAll`).
Stage 2 proves the native x86 syscall entry and VM-aware scheduler
finish. The entry discharges the VM-specific capability routes and
takes the native-capability dispatcher cases as a premise. Separate
refinements cover VMEnter on VMX and SVM, ordinary unknown and trapped
syscalls, host interrupts, user exceptions, VM faults, and stalled and
unstalled VCPU exits. The proofs start from the joint VM state under
the entry and platform premises in [DESIGN.md §9](DESIGN.md#9-proof-plan).
Stage 3 proves one theorem over the nine x86 core entries
(`VEAnyX.outerS3`): native syscall, VMEnter on VMX and SVM, ordinary
unknown and trapped syscalls, host interrupts, user exceptions, VM
faults, and stalled and unstalled VCPU exits. The syscall case
(`VmEptState.kernel_entryS3`) covers the native-capability dispatcher
cases, the invocation, receive and yield arms and the finish, which
Stage 2 (`VmEptState.kernel_entry`) took as premises. Every entry starts
from the joint VM state (`VEAnyX`) and the premises of that event
(`S3Pre`), and returns a related extended-spec outcome at `VEAnyX`. The
post does not re-establish `S3Pre`, so the next entry must be given it
again, and no run of several entries is proved. Producing the first
`VEAnyX` state from boot is open. `VEAnyX` and `S3Pre` are not vacuous:
a constructed concrete state with a running guest and its VCPU satisfies
both for a syscall invoking a SchedControl cap and for one invoking an
Untyped cap (`JBootQ.VWit.witness_schedControl`, `witness_untyped`; the
state is not shown to be reached from boot). At that state a dispatch
pair exists and the invoked cap's core restriction is exercised
(`w_core_exercised`), and `outerS3` applies with every platform argument
instantiated except premises on opaque spec constants (`outer_schedControl`,
`outer_untyped`). The premises are listed in
[DESIGN.md §9](DESIGN.md#9-proof-plan).

The [S] scope is serial core entry after the gate, with one scheduling
domain and the single-core IRQ view. Assembly, hardware guest execution
and the capture of the VCPU image and vector lie at the trusted boundary.
Both fresh host and saved guest interrupt vectors exclude cross-core IPIs
126 and 127. The saved path covers no vector, active and inactive device
lines, and non-IPI vectors above the device range. Native syscall numbers
are −11 through −1 with the trap flag clear. VMEnter (−23) also requires
an agreed enabled backend and a bound VCPU. Ordinary unknown syscalls use
`UnkSys`, exclude debug/TLS calls, and require the spec to select the
ordinary fault case. Software-trap vectors are below 256 and use FL4's
zero-extended payload.
are −11 through −1 with the trap flag clear. For the capability the
syscall invokes, a SchedControl cap must name the executing core and an
Untyped cap is covered only on core 0. VMEnter (−23) also requires a
clear trap flag, an agreed enabled backend and a bound VCPU. Ordinary
unknown syscalls use `UnkSys`, exclude debug/TLS calls, and require the
spec to select the ordinary fault case. Software-trap vectors are below
256 and use FL4's zero-extended payload.

## x86 virtualization

Expand Down
194 changes: 194 additions & 0 deletions proofs/Fl4Proofs.lean
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ import Fl4Proofs.P3.SpecNKO
import Fl4Proofs.P3.IpcGrant
import Fl4Proofs.P3.IpcGrantX
import Fl4Proofs.P3.IpcGrantTr
import Fl4Proofs.P3.IpcGrantTrV
import Fl4Proofs.P3.IpcEpGrant
import Fl4Proofs.P3.IpcLeaves
import Fl4Proofs.P3.EpRecvX
Expand Down Expand Up @@ -2382,6 +2383,9 @@ import Fl4Proofs.P3.VirtTyK6
import Fl4Proofs.P3.VirtAwaken
import Fl4Proofs.P3.VirtNvTcb
import Fl4Proofs.P3.VirtR7e
import Fl4Proofs.P3.VirtFrameBatch
import Fl4Proofs.P3.VirtFrameBatchConservative
import Fl4Proofs.P3.VmFrameBatchRestart
import Fl4Proofs.P3.VirtR7eK
import Fl4Proofs.P3.VirtNvcW
import Fl4Proofs.P3.VirtR7eK2
Expand Down Expand Up @@ -2814,7 +2818,13 @@ import Fl4Proofs.P3.VmDelHyps
import Fl4Proofs.P3.VmDelCap
import Fl4Proofs.P3.VmCnodeRD
import Fl4Proofs.P3.VmCnodeVtxSpec
import Fl4Proofs.P3.DeriveVt
import Fl4Proofs.P3.VmCnodeVtx
import Fl4Proofs.P3.XTopJointXferGB
import Fl4Proofs.P3.P3JSendFootBase
import Fl4Proofs.P3.VmEntryS3Xfer
import Fl4Proofs.P3.P3JSendStF
import Fl4Proofs.P3.VmEntryS3SendF
import Fl4Proofs.P3.VmCnodeCp
import Fl4Proofs.P3.VmCnodeAll
import Fl4Proofs.P3.VmDisp
Expand All @@ -2831,6 +2841,77 @@ import Fl4Proofs.P3.VmFinish
import Fl4Proofs.P3.VmHiErr
import Fl4Proofs.P3.VmInvAfter
import Fl4Proofs.P3.VmKEntry
import Fl4Proofs.P3.VmEntryS3Budget
import Fl4Proofs.P3.VmEntryS3Yield
import Fl4Proofs.P3.VmEntryS3Recv
import Fl4Proofs.P3.VmEntryS3Finish
import Fl4Proofs.P3.VmEntryS3Oracle
import Fl4Proofs.P3.VmEntryS3Fault
import Fl4Proofs.P3.VmEntryS3Pool
import Fl4Proofs.P3.VmEntryS3ScCtl
import Fl4Proofs.P3.VmEntryS3Decode
import Fl4Proofs.P3.VmEntryS3Untyped
import Fl4Proofs.P3.VmEntryS3Dispatch
import Fl4Proofs.P3.VmEntryS3Tdx
import Fl4Proofs.P3.VmEntryS3Pml4
import Fl4Proofs.P3.VmEntryS3Thread
import Fl4Proofs.P3.VmEntryS3Sc
import Fl4Proofs.P3.VmEntryS3Domain
import Fl4Proofs.P3.VmEntryS3IoControl
import Fl4Proofs.P3.VmEntryS3Send
import Fl4Proofs.P3.VmEntryS3ReplyNormal
import Fl4Proofs.P3.JAtZBUpdConsumed
import Fl4Proofs.P3.VmEntryS3XferAll
import Fl4Proofs.P3.VmEntryS3ReplyXfer
import Fl4Proofs.P3.JAtZBRstPost
import Fl4Proofs.P3.JAtZBRunTmo
import Fl4Proofs.P3.VmEntryS3ReplyFault
import Fl4Proofs.P3.VmEntryS3ReplyTmo
import Fl4Proofs.P3.JAtZBTmoRecv
import Fl4Proofs.P3.VmEntryS3ReplyRecv
import Fl4Proofs.P3.VmEntryS3Irq
import Fl4Proofs.P3.IrqCtlTrace
import Fl4Proofs.P3.VmEntryS3IrqCtl
import Fl4Proofs.P3.JAtZBMakePool
import Fl4Proofs.P3.VmEptMakePool
import Fl4Proofs.P3.VmEntryS3AsidControl
import Fl4Proofs.P3.JAtZBThrSched
import Fl4Proofs.P3.JAtZBRestartN
import Fl4Proofs.P3.JAtZBThrPost
import Fl4Proofs.P3.VmEntryS3ThrAdapt
import Fl4Proofs.P3.JAtZBThrResume
import Fl4Proofs.P3.JAtZBThrMcp
import Fl4Proofs.P3.JAtZBThrUnbind
import Fl4Proofs.P3.JAtZBThrBind
import Fl4Proofs.P3.JAtZBThrBindTop
import Fl4Proofs.P3.JAtZBThrPrio
import Fl4Proofs.P3.JAtZBThrSetPrio
import Fl4Proofs.P3.JAtZBThrTls
import Fl4Proofs.P3.JAtZBThrWrite
import Fl4Proofs.P3.JAtZBThrWriteTop
import Fl4Proofs.P3.JAtZBThrCopy
import Fl4Proofs.P3.JAtZBThrCopyTop
import Fl4Proofs.P3.JAtZBThrRead
import Fl4Proofs.P3.JAtZBThrReadTop
import Fl4Proofs.P3.JAtZBThrPostF
import Fl4Proofs.P3.JAtZBThrExtAux
import Fl4Proofs.P3.JAtZBThrFlags
import Fl4Proofs.P3.JAtZBThrSingleStep
import Fl4Proofs.P3.JAtZBThrBp
import Fl4Proofs.P3.JAtZBThrGetBp
import Fl4Proofs.P3.JAtZBThrFpuAux
import Fl4Proofs.P3.JAtZBThrFpu
import Fl4Proofs.P3.JAtZBThrTimer
import Fl4Proofs.P3.VmEntryS3InsTcb
import Fl4Proofs.P3.JAtZBTcbBuf
import Fl4Proofs.P3.VmEntryS3TcbInst
import Fl4Proofs.P3.VmEntryS3ReplyArm
import Fl4Proofs.P3.VmEntryS3FrameBatch
import Fl4Proofs.P3.VmEntryS3FrameMap
import Fl4Proofs.P3.VmEntryS3Frame
import Fl4Proofs.P3.VmEntryS3Tables
import Fl4Proofs.P3.VmEntryS3Selected
import Fl4Proofs.P3.VmEntryS3RecvEndpoint
import Fl4Proofs.P3.NatFoot
import Fl4Proofs.P3.EptSetRoot
import Fl4Proofs.P3.EptSetRootDec
Expand Down Expand Up @@ -2944,3 +3025,116 @@ import Fl4P2Base.SerialW
import Fl4P2Base.GateImpl
import Fl4P2Base.GateLock
import Fl4P2Base.SafeW
import Fl4Proofs.P3.VmEntryS3TcbSsp
import Fl4Proofs.P3.VmEntryS3ThrDisp
import Fl4Proofs.P3.VmEntryS3Coverage
import Fl4Proofs.P3.VmFinFamTac
import Fl4Proofs.P3.VmFinFamA
import Fl4Proofs.P3.VmFinFamFpu
import Fl4Proofs.P3.VmFinFamFn
import Fl4Proofs.P3.VmFinFamDl
import Fl4Proofs.P3.VmFinFamHook
import Fl4Proofs.P3.VmFinGenBase
import Fl4Proofs.P3.VmFinGenLRd
import Fl4Proofs.P3.VmFinGenLIo
import Fl4Proofs.P3.VmFinGenLSi
import Fl4Proofs.P3.VmFinGenLSg
import Fl4Proofs.P3.VmFinGenLLd
import Fl4Proofs.P3.VmFinGenLFo
import Fl4Proofs.P3.VmFinGenVF
import Fl4Proofs.P3.VmFinVF
import Fl4Proofs.P3.VmFinGenUi
import Fl4Proofs.P3.VmFinGenIdk
import Fl4Proofs.P3.VmFinGenNk
import Fl4Proofs.P3.VmFinGenYk
import Fl4Proofs.P3.VmFinGenHu
import Fl4Proofs.P3.VmFinGenNq
import Fl4Proofs.P3.VmFinGenCt
import Fl4Proofs.P3.VmFinGenPj
import Fl4Proofs.P3.VmFinGenB
import Fl4Proofs.P3.VmFinFamB
import Fl4Proofs.P3.VmFinVF2
import Fl4Proofs.P3.VmFinArmB
import Fl4Proofs.P3.VmFinGenDl
import Fl4Proofs.P3.VmFinArmDl
import Fl4Proofs.P3.VmFinArmNq
import Fl4Proofs.P3.VmFinDecode
import Fl4Proofs.P3.VmFinArmIlVm
import Fl4Proofs.P3.VmFinArmIl
import Fl4Proofs.P3.VmFinFbV
import Fl4Proofs.P3.VmFinArmIlTop
import Fl4Proofs.P3.VmFinArmFo
import Fl4Proofs.P3.VmFinArmFoTop
import Fl4Proofs.P3.VmFinVgFb
import Fl4Proofs.P3.VmFinArmVgA
import Fl4Proofs.P3.VmFinArmVgB
import Fl4Proofs.P3.VmFinArmVgC
import Fl4Proofs.P3.VmFinVgSlot5
import Fl4Proofs.P3.VmRecvFoot0
import Fl4Proofs.P3.VmRecvFoot1
import Fl4Proofs.P3.VmRecvFoot2a
import Fl4Proofs.P3.VmRecvFoot2
import Fl4Proofs.P3.VmRecvFootB
import Fl4Proofs.P3.VmRecvFootC
import Fl4Proofs.P3.VmRecvFootD
import Fl4Proofs.P3.VmRecvFootX
import Fl4Proofs.P3.VmRecvFootXT
import Fl4Proofs.P3.VmRecvLeaves
import Fl4Proofs.P3.VmMidBlock
import Fl4Proofs.P3.VmRecvMid
import Fl4Proofs.P3.VmRecvMidSig
import Fl4Proofs.P3.VmRecvMidNtfn
import Fl4Proofs.P3.VmRecvMidEp
import Fl4Proofs.P3.VmRecvMidEp2
import Fl4Proofs.P3.VmRecvMidAsm
import Fl4Proofs.P3.VmRecvMidDon
import Fl4Proofs.P3.VmRecvMidDonV
import Fl4Proofs.P3.VmFaultMid
import Fl4Proofs.P3.VmFaultSw
import Fl4Proofs.P3.VmRecvS
import Fl4Proofs.P3.VmRecvMidTop
import Fl4Proofs.P3.VmJAtZRB
import Fl4Proofs.P3.VmSwitchR
import Fl4Proofs.P3.VmSwitchRTop
import Fl4Proofs.P3.VmJAtZRBRet
import Fl4Proofs.P3.VmJAtZRBFin
import Fl4Proofs.P3.VmFinishR
import Fl4Proofs.P3.VmMidQ
import Fl4Proofs.P3.VmMidFb
import Fl4Proofs.P3.VmMidRunQ
import Fl4Proofs.P3.VmMidB
import Fl4Proofs.P3.VmMidVfh
import Fl4Proofs.P3.VmMidProd
import Fl4Proofs.P3.VmRecvFin
import Fl4Proofs.P3.VmEntryS3TopG
import Fl4Proofs.P3.VmEntryS3TopR
import Fl4Proofs.P3.VmEntryS3Fast
import Fl4Proofs.P3.VmHiRvm
import Fl4Proofs.P3.VmEntryS3Orc
import Fl4Proofs.P3.VmFinFrontS3
import Fl4Proofs.P3.VmEntryS3Start
import Fl4Proofs.P3.SInvXV
import Fl4Proofs.P3.SInvXVWit
import Fl4Proofs.P3.VmWitPlatform
import Fl4Proofs.P3.VmWitSpec
import Fl4Proofs.P3.VmWitMem
import Fl4Proofs.P3.VmWitZ
import Fl4Proofs.P3.VmWitCs
import Fl4Proofs.P3.VmWitBlk
import Fl4Proofs.P3.VmWitLay
import Fl4Proofs.P3.VmWitSpecB
import Fl4Proofs.P3.VmWitJAt
import Fl4Proofs.P3.VmWitVcpu
import Fl4Proofs.P3.VmWitS3
import Fl4Proofs.P3.VmWitOuter
import Fl4Proofs.P3.VmEntryS3TopS
import Fl4Proofs.P3.VmEntryS3Mid
import Fl4Proofs.P3.VmEntryS3Disp
import Fl4Proofs.P3.VmEntryS3Entry
import Fl4Proofs.P3.VmEntryS3Outer
import Fl4Proofs.P3.VmDispX
import Fl4Proofs.P3.VmVxLow
import Fl4Proofs.P3.VmKEntryX
import Fl4Proofs.P3.VmHandleX
import Fl4Proofs.P3.VmHandleTopX
import Fl4Proofs.P3.VmInvAfterX
Loading
Loading