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
24 changes: 24 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,30 @@ base. This file holds what you must not get wrong.
- After extraction: `python3 xtask/scripts/gen_const_specs.py proofs` and `python3 xtask/scripts/gen_p0.py proofs`,
then commit `proofs/Fl4Core/*` with the regenerated P0 files.

## Proof records (extension cost)

Adding a field to an invariant/keep record must cost O(1) files, not O(construction sites). Rules for `proofs/Fl4ProofsA64`:
The patterns to copy are `DomKeepA.ofKey` (`Stage3SortA`), `SpecGlobA.ofKey` (`FrameA`), `VcpuSpecStepA.ofKey`
(`VcpuDelFrameA`) and `MFrA.ofParts` / `MFrDA.ofParts` (`ScSWrA`); `handoff`-style codemods are compile-driven and idempotent.

1. A **keep/frame record** (`σ'.f = σ.f` per field, e.g. `DomKeepA`, `SpecGlobA`, `VcpuSpecStepA`) ships with a key
(`DomKeyA σ`, a tuple of the kept components), `ofKey`, `key`, `refl`, `trans`. Call sites use `X.ofKey rfl`,
`X.ofKey (by rw [e])`, `X.ofKey (congrArg XKey e)`, `X.refl _`, `X.trans`; a key is an `abbrev` (a `def` makes the kernel compare the large state
arguments of two key applications first and can hit deep recursion); adding a kept component edits the structure,
the key, `ofKey` and `key` in the one defining file.
2. No anonymous-constructor literal `⟨…⟩` of a record with 4 or more fields outside its defining module: use `{ x with … }`,
`where`, a smart constructor, or `keep_rfl`. Never write `⟨rfl, rfl, rfl, rfl⟩` for a record.
3. Hypotheses that travel together (3 or more parameters in 3 or more signatures) get a bundle structure (`ArchTieA` is the
pattern); a new fact is a new field. No new positional store-fact parameters on `ArchSwFA`-style interfaces.
4. A record extension is a Step-0 item: count its construction sites (`git grep -wc`) and state the expected churn in
files in the line's contract. More than 20 files means the smart-constructor refactor comes first.
5. Context such as the MCS state `m` or `Z` is never a new binder on existing theorems (`m : McState` is bound in about
800 files): add it as a field of the bundle that already carries it (`MFrA`, `JStage3A`'s nested records).
6. Range/disjunction sets (`DomW`, `SKsA`, `inKs*`) are consumed through membership lemmas, not by hand-counted
`Or.inl`/`Or.inr` chains.
7. A record-extension commit carries no statement changes beyond the record itself: check with
`git diff -U0 | grep -E '^[-+](theorem|lemma|def|structure)'` before pushing.

## Commands

```sh
Expand Down
18 changes: 14 additions & 4 deletions DESIGN.md

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,13 +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`). 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
(`lake build Fl4ProofsA64`). AArch64 P3 Stages 3 and 4 prove the syscall
kernel-entry top (`kernelEntry_recGA`) over the CNode, VSpace (incl. the Stage-2 and high-window maps and the T2 unmap shrink),
SchedContext, TCB (installs, SetSpace, Configure, SetSchedParams, SetTimer, Read-, Write- and CopyRegisters), IPC, IRQ, Domain, VCPU and Untyped (Retype, TCB creation and the non-preempting reset) groups,
the receive family and combined syscalls, the preempted exit, the interrupt entry (`kernelEntryIrq_recGA`) and the VM-exit entries `runExit` / `runVppi`;
the preempting Untyped reset, a device Untyped, DeriveSubframe, ASIDControl MakePool, the Stage-1 / high-window shrink, the guest-resume `finish` and the other guest entries are declared limits,
`ArchSwFA` is single-core (the SMP stage restates it per core), and
the premises of every top are shown jointly satisfiable (`wit_send_nonvacuous`, `wit_recv_nonvacuous`, `wit_comb_nonvacuous`, `wit_runexit_nonvacuous` / `wit_runvppi_nonvacuous` (a VCPU-less exit), `wit_irq_nonvacuous`, under the witness-world hypotheses `OpaqueWA` and the IRQ-oracle fact of each; the Untyped arm has a premise-level witness) (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
82 changes: 82 additions & 0 deletions proofs/Fl4ProofsA64.lean
Original file line number Diff line number Diff line change
Expand Up @@ -1684,13 +1684,31 @@ import Fl4ProofsA64.P3.Stage3ArmFrMapA
import Fl4ProofsA64.P3.Stage3MapExtA
import Fl4ProofsA64.P3.Stage3MapExtCoreA
import Fl4ProofsA64.P3.Stage3ArmFrMapHiA
import Fl4ProofsA64.P3.Stage3MapS2UnmA
import Fl4ProofsA64.P3.Stage3ArmFrMapS2A
import Fl4ProofsA64.P3.Stage3T3ArmS2A
import Fl4ProofsA64.P3.Stage3PinVsS2A
import Fl4ProofsA64.P3.Stage3ArmPtUnmUA
import Fl4ProofsA64.P3.Stage3ArmPtUnmMA
import Fl4ProofsA64.P3.Stage3ArmPtUnmXA
import Fl4ProofsA64.P3.Stage3TcbSuspFrA
import Fl4ProofsA64.P3.Stage3TcbRestartFr2A
import Fl4ProofsA64.P3.Stage3TcbSuspResA
import Fl4ProofsA64.P3.Stage3TcbRegsFrA
import Fl4ProofsA64.P3.TcbWriteBridgeA
import Fl4ProofsA64.P3.Stage3TcbRegWriteFrA
import Fl4ProofsA64.P3.Stage3TcbRegWriteA
import Fl4ProofsA64.P3.Stage3TcbRegWriteArmA
import Fl4ProofsA64.P3.Stage3TcbRegResumeA
import Fl4ProofsA64.P3.Stage3TcbRegCopyRsA
import Fl4ProofsA64.P3.Stage3TcbRegCopySelfA
import Fl4ProofsA64.P3.Stage3TcbRegCopySuspA
import Fl4ProofsA64.P3.Stage3TcbRegCopyA
import Fl4ProofsA64.P3.Stage3TcbRegCopyArmA
import Fl4ProofsA64.P3.Stage3TcbRegInvA
import Fl4ProofsA64.P3.Stage3TcbRegMidA
import Fl4ProofsA64.P3.Stage3InvSpecTcbRegsA
import Fl4ProofsA64.P3.Stage3InvSpecTcbRegsWA
import Fl4ProofsA64.P3.Stage3CapVsFrameGA
import Fl4ProofsA64.P3.Stage3VsTyPostA
import Fl4ProofsA64.P3.Stage3ArmAssignA
Expand Down Expand Up @@ -1755,6 +1773,10 @@ import Fl4ProofsA64.P1.S1aStepPool
import Fl4ProofsA64.P3.Stage3FinA
import Fl4ProofsA64.P3.Stage3T3ArmsA
import Fl4ProofsA64.P3.Stage3T3ArmHiA
import Fl4ProofsA64.P3.Stage3ArmPtMapHiA
import Fl4ProofsA64.P3.Stage3T3ArmPtHiA
import Fl4ProofsA64.P3.Stage3ArmPtMapS2A
import Fl4ProofsA64.P3.Stage3T3ArmPtS2A
import Fl4ProofsA64.P3.Stage3T3DecEqA
import Fl4ProofsA64.P3.Stage3T3ArmCoreA
import Fl4ProofsA64.P3.Stage3T3ArmsCnA
Expand Down Expand Up @@ -1845,6 +1867,8 @@ import Fl4ProofsA64.P3.Stage3TcbUnbindA
import Fl4ProofsA64.P3.Stage3TcbMcpA
import Fl4ProofsA64.P3.Stage3TcbBindA
import Fl4ProofsA64.P3.Stage3DispTcbA
import Fl4ProofsA64.P3.Stage3TcbPreExitA
import Fl4ProofsA64.P3.Stage3DispTcbPreA
import Fl4ProofsA64.P3.Stage3CancelLoopA
import Fl4ProofsA64.P3.Stage3CancelBadgedA
import Fl4ProofsA64.P3.Stage3SigWakeFootA
Expand Down Expand Up @@ -1949,6 +1973,12 @@ import Fl4ProofsA64.P3.UtApSys2A
import Fl4ProofsA64.P3.UtAsmAllA
import Fl4ProofsA64.P3.UtAsmAll0A
import Fl4ProofsA64.P3.UtRtRecA
import Fl4ProofsA64.P3.UtRtExA
import Fl4ProofsA64.P3.UtRtLastA
import Fl4ProofsA64.P3.UtKeepA
import Fl4ProofsA64.P3.McGrowUtA
import Fl4ProofsA64.P3.UtRtNewPlaceA
import Fl4ProofsA64.P3.Stage3UtArmA
import Fl4ProofsA64.P3.UtRtRecTopA
import Fl4ProofsA64.P1.S1aRtTopK
import Fl4ProofsA64.P3.UtDecRecA
Expand All @@ -1970,6 +2000,10 @@ import Fl4ProofsA64.P3.UtPpScA
import Fl4ProofsA64.P3.UtPpTsA
import Fl4ProofsA64.P3.UtPpHookA
import Fl4ProofsA64.P3.UtRtResetPpA
import Fl4ProofsA64.P3.UtKeepCurA
import Fl4ProofsA64.P3.UtResetNoErrA
import Fl4ProofsA64.P3.UtRtResetNpA
import Fl4ProofsA64.P3.A64WitUtA
import Fl4ProofsA64.P3.UtClrA
import Fl4ProofsA64.P3.UtChunkA
import Fl4ProofsA64.P3.UtMakePoolA
Expand All @@ -1978,6 +2012,7 @@ import Fl4ProofsA64.P3.UtResetA
import Fl4ProofsA64.P1.S1aRtTopRst
import Fl4ProofsA64.P3.UtRtRecRstA
import Fl4ProofsA64.P3.UtDecRecRstA
import Fl4ProofsA64.P3.UtDecExA
import Fl4ProofsA64.P3.UtApRec5A
import Fl4ProofsA64.P3.UtRec6KeepA
import Fl4ProofsA64.P3.UtVcInitA
Expand Down Expand Up @@ -2173,6 +2208,21 @@ import Fl4ProofsA64.P3.VcpuDelHookA
import Fl4ProofsA64.P3.VcpuDelFinHookA
import Fl4ProofsA64.P3.Stage3DelAsmTopA
import Fl4ProofsA64.P3.Stage3TcbDelStepA
import Fl4ProofsA64.P3.Stage3TcbChainIfaceA
import Fl4ProofsA64.P3.Stage3TcbChainA
import Fl4ProofsA64.P3.Stage3TcbChainStartA
import Fl4ProofsA64.P3.Stage3TcbSetSpaceSelA
import Fl4ProofsA64.P3.Stage3TcbConfigSelA
import Fl4ProofsA64.P3.Stage3TcbChainHelpA
import Fl4ProofsA64.P3.Stage3DecErrTcbValA
import Fl4ProofsA64.P3.Stage3LiftTcbSpaceA
import Fl4ProofsA64.P3.Stage3InvSpecTcbSpaceA
import Fl4ProofsA64.P3.Stage3InvSpecTcbCfgA
import Fl4ProofsA64.P3.Stage3InvSpecTcbBufDecA
import Fl4ProofsA64.P3.Stage3InvSpecTcbPerfA
import Fl4ProofsA64.P3.Stage3InvSpecTcbPreA
import Fl4ProofsA64.P3.Stage3LiftTcbCfgFrontA
import Fl4ProofsA64.P3.Stage3LiftTcbCfgA
import Fl4ProofsA64.P3.Stage3TcbBufStepA
import Fl4ProofsA64.P3.Stage3LiftTcbBufA
import Fl4ProofsA64.P3.Stage3LiftTcbTimeoutA
Expand All @@ -2182,6 +2232,7 @@ import Fl4ProofsA64.P3.Stage3CapInsertBufA
import Fl4ProofsA64.P3.Stage3TcbDelGA
import Fl4ProofsA64.P3.Stage3TcbBufStepsA
import Fl4ProofsA64.P3.Stage3TcbReschedA
import Fl4ProofsA64.P3.Stage3TcbBufMidA
import Fl4ProofsA64.P3.Stage3LiftTcbBufNzA
import Fl4ProofsA64.P3.Stage3LiftTcbTimeoutNnA
import Fl4ProofsA64.P3.Stage3P1StepA
Expand All @@ -2190,6 +2241,14 @@ import Fl4ProofsA64.P3.Stage3TcbPrioAnyA
import Fl4ProofsA64.P3.Stage3LiftTcbSspA
import Fl4ProofsA64.P3.Stage3InsP1A
import Fl4ProofsA64.P3.Stage3LiftTcbSspEpA
import Fl4ProofsA64.P3.Stage3TcbInstallA
import Fl4ProofsA64.P3.Stage3LiftTcbHighA
import Fl4ProofsA64.P3.Stage3InvSpecTcbHighA
import Fl4ProofsA64.P3.Stage3TcbSchedFrameA
import Fl4ProofsA64.P3.Stage3TcbPrioCurA
import Fl4ProofsA64.P3.Stage3TcbSchedCurA
import Fl4ProofsA64.P3.Stage3TcbSchedMidA
import Fl4ProofsA64.P3.Stage3TcbSchedScA
import Fl4ProofsA64.P3.Stage3LiftFlushA
import Fl4ProofsA64.P3.Stage3DispFlushA
import Fl4ProofsA64.P3.Stage3DispIrqA
Expand All @@ -2199,6 +2258,7 @@ import Fl4ProofsA64.P3.Stage3LiftTestClearA
import Fl4ProofsA64.P3.Stage3DispReplyA
import Fl4ProofsA64.P3.Stage3LiftDomainA
import Fl4ProofsA64.P3.Stage3DispDomA
import Fl4ProofsA64.P3.Stage3DomSchedA
import Fl4ProofsA64.P3.Stage3ErrPreA
import Fl4ProofsA64.P3.Stage3ErrKeepA
import Fl4ProofsA64.P3.Stage3ErrKeep2A
Expand Down Expand Up @@ -2277,6 +2337,7 @@ import Fl4ProofsA64.P3.Stage3DecErrTcbRegsA
import Fl4ProofsA64.P3.Stage3DecErrTcbAuthA
import Fl4ProofsA64.P3.Stage3DecErrTcbPacA
import Fl4ProofsA64.P3.Stage3DecErrTcbBufA
import Fl4ProofsA64.P3.Stage3DecErrTcbRootsCoreA
import Fl4ProofsA64.P3.Stage3DecErrTcbRootsA
import Fl4ProofsA64.P3.Stage3DecErrTcbSpaceA
import Fl4ProofsA64.P3.Stage3DecErrTcbA
Expand Down Expand Up @@ -2305,6 +2366,10 @@ import Fl4ProofsA64.P3.Stage3T3ArmsVcpuRunA
import Fl4ProofsA64.P3.Stage3VcpuExitA
import Fl4ProofsA64.P3.Stage3VcpuExitWireA
import Fl4ProofsA64.P3.Stage3SignalVmA
import Fl4ProofsA64.P3.Stage3TcbDebugLabelsA
import Fl4ProofsA64.P3.Stage3TcbTimerRecA
import Fl4ProofsA64.P3.Stage3TcbTimerA
import Fl4ProofsA64.P3.Stage3InvSpecTcbTimerA
import Fl4ProofsA64.P3.Stage3SigVmArmA
import Fl4ProofsA64.P3.Stage3YieldBodyA
import Fl4ProofsA64.P3.Stage3RecvScopeA
Expand All @@ -2329,6 +2394,12 @@ import Fl4ProofsA64.P3.A64Wit2BudgetA
import Fl4ProofsA64.P3.A64Wit2EntryA
import Fl4ProofsA64.P3.A64Wit2TierA
import Fl4ProofsA64.P3.A64Wit2TopA
import Fl4ProofsA64.P3.A64Wit3ClockA
import Fl4ProofsA64.P3.A64Wit3ExitA
import Fl4ProofsA64.P3.A64Wit3RunA
import Fl4ProofsA64.P3.A64Wit3TopA
import Fl4ProofsA64.P3.A64WitRcA
import Fl4ProofsA64.P3.A64WitRcCombA
import Fl4ProofsA64.P3.Stage3DomIpiA
import Fl4ProofsA64.P3.A64ArchSwA
import Fl4ProofsA64.P3.A64ArchSwB
Expand All @@ -2338,3 +2409,14 @@ import Fl4ProofsA64.P3.A64ArchSwE
import Fl4ProofsA64.P3.A64ArchSwF
import Fl4ProofsA64.P3.A64ArchSwG
import Fl4ProofsA64.P3.A64ArchSwH
import Fl4ProofsA64.P3.Stage3KEntryIrqBodyA
import Fl4ProofsA64.P3.Stage3KEntryIrqTopA
import Fl4ProofsA64.P3.A64WitIrqA
import Fl4ProofsA64.P3.Stage3TcbReadRegsA
import Fl4ProofsA64.P3.Stage3InvSpecTcbRegsA
import Fl4ProofsA64.P3.TcbInvokeReadCallFineA
import Fl4ProofsA64.P3.Stage3TcbReadCallSpecA
import Fl4ProofsA64.P3.Stage3TcbReadCallA
import Fl4ProofsA64.P3.Stage3SuspOffQA
import Fl4ProofsA64.P3.Stage3TcbReadRegsSuspA
import Fl4ProofsA64.P3.Stage3TcbReadCallSuspA
6 changes: 4 additions & 2 deletions proofs/Fl4ProofsA64/P3/A64Wit2ArchA.lean
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,10 @@ structure OpaqueWA : Prop where
gic : kernelConfig.configArmGicV3 = false
/-- `numNodes = 1` (`opaque fl4A64Platform`; [S]) -/
nodes : fl4A64Platform.numNodes = 1
/-- the reset chunk size is 16 bits (`opaque kernelConfig`; the Untyped reset arm's `hchunk`) -/
chunk : resetChunkBits = 16
/-- the Stage-2 IPA width is 40 (`opaque fl4A64Platform`; `ar1_plat`'s width; the Untyped reset arm's `hIpa`) -/
ipaBits : fl4A64Platform.s2IpaBits = 40
/-- `maxTicksToUs = U64::MAX` (`opaque maxTicksToUs`) -/
max : maxTicksToUs = core.num.U64.MAX.bv
/-- kernel WCET 10 µs (`opaque timeConsts`; FL4's build) -/
Expand All @@ -146,8 +150,6 @@ structure OpaqueWA : Prop where
freq : fl4TimerFrequencyHz = 1000000000
/-- `fl4MaxPeriodUs = MAX_PERIOD_US` (`opaque fl4MaxPeriodUs`) -/
period : fl4MaxPeriodUs = MAX_PERIOD_US
/-- the IRQ oracle only yields the VGIC maintenance line, a non-kernel IRQ (`opaque irqOracleAx`; witness world) -/
irq : ∀ n, irqOracle n = irqVGICMaintenance
/-- the raw counter oracle is monotone (`opaque fl4RawCounterOracle`) -/
hC : ∀ i, fl4RawCounterOracle i ≤ fl4RawCounterOracle (i + 1)
/-- the spec's clock and the raw counter agree at a state whose last observation is the next raw sample (`opaque
Expand Down
Loading