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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
9 changes: 9 additions & 0 deletions DESIGN.md
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,15 @@ 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.
- AArch64 P3's delete finaliser hooks for Notification, Endpoint and IrqHandler are [S] scoped to `numNodes = 1` (FL4's `possible_switch_to` branches on the affinity and the current core, the spec's is single-core); under it the waiters' locality follows from the per-step record. The Reply and thread / SchedContext hooks, not yet proved, take the same scope.
- AArch64 P3's Reply to a faulted caller (`JSyscallA.replyFaultA`, `P3/Stage3ReplyFaultArmA`; spec `fl4HandleFaultReply`) is [S] scoped to: an `UnknownSyscall` reply shorter than `TRAP_FULL_LENGTH` (37 words), or a fault not sent in the long form (`fault_w1 = 0`, as for every thread with `TRAP_SYSCALLS` clear): the long form's extra registers (x8–x30, TPIDR_EL0) are not in the spec; a caller whose timeout handler is not an endpoint cap; `numNodes = 1`.
- AArch64 P3 Stage 3 (`proofs/Fl4ProofsA64/P3/Stage3*`), proved: the syscall kernel-entry top `kernelEntry_recGA` / `kernelEntry_stage3A` (ghost sets float existentially in the exit record `A64RelS3`), over the dispatch groups CNode, VSpace, SchedContext, TCB, IPC, IRQ, flush, reply, domain, error and VCPU (Untyped: no constructor yet; see the scope-limit bullet) (labels 60–69, at the body and dispatch level: `VcpuScopeA`); the receive family and the combined syscalls (`kernelEntryComb_recGA`, `syscallComb_refinesA`); the preempted exit without the callers' `hPre` premise (`hPre_ofA`, from `HPreEnvA`: `hX` and `T` are derived from the record, and the `Clock` the delete/revoke loop carries to its `Preempted` exit is threaded through `DispPostRA`); and the VM-exit entries end to end (`kernelEntry_runExitA`, `kernelEntry_runVppiA`). The blocking receive with a reply object is proved for a reply object linked to another thread as well (case B of `take_reply`: the link is cancelled first, `Stage3RecvPushCancelA`), so the receive scope no longer assumes an unlinked reply object. The IRQ-control decode's node count is a record fact (`NdOKA.nodes`: the kernel-state word `NUM_NODES` equals the platform's `numNodes`, and every write set keeps it), not a [P] premise over store memory (`IrqPlatA.nodes` is gone). TCB SetIPCBuffer is proved for a zero address (`JSyscallA.setIpcBufZeroA`) and a non-zero one (`JSyscallA.setIpcBufNzA`, `P3/Stage3LiftTcbBufNzA`) on any target thread (the current thread included, with its `reschedule_required`) from a non-device Frame source; a device-frame source or a misaligned or invalid buffer is a decode error, covered by `DecErrSpecPA.thread` (`decErrSpecA`, `sendBodyErrAllA`).
- AArch64 P3 Stage 3, dispatch scope limits ([S]): the scope premise of the syscall tops (`hArm`) holds only for the invocations of `DispScopeA`. A decode that succeeds outside it is not covered, so the tops say nothing about: Untyped Retype / RetypeShared (`UtScopeA` has no constructor yet; first in line for the next stage); TCB Configure, SetSpace, ReadRegisters, WriteRegisters, CopyRegisters, SetTimer, SetHighVSpace, the breakpoint labels and single stepping; SetSchedParams with a changed SC or another handler cap kind; DomainScheduleConfigure / SetStart; ARMASIDControlMakePool; ARMPageDeriveSubframe; the Stage-2 frame map, the page-table map into a high window or Stage-2, and the T2 unmap shrink; Notification send to a bound thread running a VCPU. Their decode `Err` returns are covered (`decErrSpecA`, `ErrScopeA`).
- AArch64 P3 Stage 3, architecture switch (`ArchSwFA`, `P3/ScArchSwA`): the `KERNEL_ROOT` word of the kernel-state block is a record fact (`NdOKA.kroot`: it names the spec's global user VSpace `armUsGlobalVspace`, kept by every write set), and `execIdle` / `execThread` take it, the no-high-window-at-address-0 fact, the run links (`RunLinkA`) and "the current core is core 0" from the record (`ArchTieA`, `JStage3A.archRestA`) instead of quantifying over every store. `ArchSwFA` is therefore single-core (`c = 0`, from `numNodes = 1`): its multicore form belongs to the SMP stage, which must restate the per-core root views. The [P] has a Lean inhabitant for the model architecture: `witArchSwOf : ArchSwFA st AR1` (`P3/A64ArchSwH`, with `P3/A64ArchSwA`–`G`) proves `set_vm_root` and `set_kernel_vm_root` against `threadRootWritesA` / `kernelRootWritesA` on core 0, so the `ArchSwFA` premise is satisfiable.
- AArch64 P3 Stage 3, the scheduler premise of the tops (`hGap`, `SchedGapFreeA` at the body's reached record, `P3/Stage3SysTopA`): [S] `oneDomain`, [P] `minAgree` (`fl4MinBudget = MIN_BUDGET`), [P] `ticks` (`ScCfgTimeAgreeA`), [J] `timer` (the schedule-timer inputs and `SniHypA` after `switch_sched_context`, guarded by the run that reaches it: awaken, select the action, switch).
- AArch64 P3 Stage 3 non-vacuity (mechanized): `Wit.wit_send_nonvacuous` (`P3/A64Wit2TopA`) shows that the premises of `kernelEntrySend_recGA` are jointly satisfiable. It exhibits, for a concrete model architecture (`P3/A64Wit2ArchA`) and the w1 boot state, a store, an arch state, a spec state and the ghost sets satisfying every premise of the theorem (`SendEntryHyps` is the theorem's binder list; `wit_top_send` also derives its conclusion there), with `witArchSwOf` as the `ArchSwFA`. Everything is existential except one hypothesis, `OpaqueWA` (witness-world [P]; it is not a premise of any top): facts about `opaque` spec constants that no Lean term proves or refutes (any value of the constant's type is a model; `P3/A64Wit2PlatA` gives 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 facts that are properties of the witness world rather than of FL4's platform: `irq` (the IRQ oracle only yields the VGIC maintenance line, a non-kernel IRQ) and `hNow` (the spec's clock and the raw counter agree at a state whose last observation is the next raw sample; both oracles are `0`). The witness also discharges `hGap` (`wit2b_hGapA`, proved at any record state). Only the Send / NBSend / Call top has a mechanized witness; the Recv, Comb and VM-exit tops share its platform premises but are not instantiated yet.
- AArch64 P3 Stage 3, declared Stage-4 limits ([S4]): the guest-resume `finish` (`hNative` / `hNat`: an `ARMVCPU_Run` that resumes the guest, so the caller stays current in `runningVM`, is outside the top), and the guest entries `vgic`, `vppi`, `vcpuExit` and `vcpuFault`, which are deferred to the S4 guest-lifecycle follow-up.
- AArch64 P3 Stage 3, still open (work in progress, not limits): the last premise duplication in the top assembly (the interrupt entry's IRQ set against the preempted exit's, once the interrupt top exists). The preempted exit takes its platform facts from the entry's `FaultEnvA` (`ExitPlatA`), its timeout-send premise (`SendPA`) is guarded by the run that reaches the preempted state, and the polled line's `reserved` clause is a [P] clause of `PollAgreeA` (fl4-kernel#154).
- 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.
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,13 @@ guest's hardware writes included, so the runtime's executions from `w0` /
`w1` are serializable (`w0_serializable_impl`, `w1_serializable_impl`),
from four memory-model and IPI premises. `cargo xtask gate` checks the x86_64
extraction; the AArch64 one is extracted and checked on its own
(`lake build Fl4ProofsA64`). P3 also covers the x86_64 VCPU/EPT
(`lake build Fl4ProofsA64`). AArch64 P3 Stage 3 proves the syscall
kernel-entry top (`kernelEntry_recGA`), the receive family and combined
syscalls, the preempted exit and the VM-exit entries `runExit` / `runVppi`;
the guest-resume `finish` and the other guest entries are declared Stage-4
limits, `ArchSwFA` is single-core (the SMP stage restates it per core), and
the premises of the Send top are shown jointly satisfiable (`wit_send_nonvacuous`,
under the witness-world hypothesis `OpaqueWA`) (DESIGN.md §9). P3 also covers the x86_64 VCPU/EPT
extension on a joint VM state (`VmEptState`): retype and untyped, the EPT
syscalls through the dispatcher, the VCPU report and detach, the IO-port
cap's owner, revoke and delete, capability delete of every cap
Expand Down
Loading