Skip to content
powderluvPublic

About

Rustproof: a Rust + Verus isolation nucleus that safely hosts an untrusted GPU compute driver (gfx1201). Design/scaffold stage.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

Rustproof

A small, formally-verifiable Rust + Verus isolation nucleus that safely hosts an untrusted GPU compute driver. The existing C++ lite:: gfx1201 (AMD RDNA4) driver runs as an ordinary user process and drives the GPU directly; the nucleus owns the address-space page tables and (later) the AMD-Vi IOMMU tables, and confines the driver so that — buggy or malicious — it cannot touch memory it was not granted. First target: a KVM guest on the x86_64 box gpu-host, dispatching one real gfx1201 wave through the untrusted driver.

Honest scope: Rustproof aims to verifiably isolate an untrusted GPU driver — it does not verify GPU computation. Two guarantees, split permanently: isolation / DMA-containment is in scope and verifiable; GPU compute correctness is permanently out of scope. The nucleus never reasons about what a wave computes, only about what memory the device can reach.

Status (updated 2026-12-02 — Phases 0–3 complete):

  • Boot & live hardware isolation (QEMU 11.1.3 TCG + KVM + RISC-V): Both x86_64 (PVH + SeaBIOS + emulated AMD-Vi with dma-remap=on + bridged PCI topology) and riscv64 (OpenSBI + Sv39) boot ring-3 userland and pass the full capability, IPC, delegation, IRQ, region-teardown, and AMD-Vi DMA-containment rig (CONTAINED / TRANSLATED / RIGHTS / REVOKED / PER-DEVICE / DENY / 65,536-BDF default-deny).
  • 4-layer verification pyramid in CI (.github/workflows/ci.yml):
    1. Host tests & mutation sweeps: 18 crates (tools/host-tests.sh), 76 host + x86/RISC-V QEMU rig mutants (tools/mutate.py).
    2. Miri (Tree Borrows): 18 host crates UB-checked (tools/miri.sh).
    3. Kani (bounded symbolic model checking): 43 harnesses across 17 crates (tools/kani.sh) + 20 harness mutations (tools/mutate-kani.py).
    4. Verus (unbounded machine-checked proofs + 6-channel accept-gate): 246 verified obligations (--no-cheating, 3-seed Z3-stable, 19/19 Verus proof/spec mutants killed, zero third-party crates.io deps) over single-source crates/abi (21), crates/deleg (58, unbounded $\forall N$ forest/closure/splice), and crates/iommu-amdvi (167, V4 65,536-BDF DTE confinement + V3 3-level 512 GiB IoPtPool refinement & PT self-protection + V5 command ring) via tools/verus.sh / cargo run -p verify.
  • Not yet done (Phase 4 & real GPU M0): Verus PointsTo lifting of raw-pointer vspace (V2), AmdViHw/nucleus-stub (V3–V5 composition), and NucleusState (V1), plus real gfx1201 VFIO hardware bring-up on gpu-host.

What "verified" will mean here

A green proof is never "the system is safe." It is "safe modulo": a small trusted unsafe stub (asm/MMIO/TLB/IOMMU-invalidate primitives in crates/nucleus-stub + crates/arch-*, hand-audited, partly Kani-checked); a trusted spec (our human-owned spec_t.rs models of x86-64 page tables and the AMD-Vi table format, SHA-256 locked in toolchain/spec_t.lock and checked against the Intel SDM / AMD IOMMU spec); a pinned toolchain (one Verus release 0.2026.11.29.f823b28, one stable rustc 1.100.0, one bundled Z3 4.16.0); and hardware axioms (the MMU and AMD-Vi interpret our tables per spec). The confinement claim is storage + DMA confinement — not timing side channels. Same shape of assurance as seL4; the tooling differs, the honesty does not.

Milestones

M Capability Machine-checked property Enforced by
M0 Boots as KVM guest; untrusted lite:: dispatches one gfx1201 wave none (feasibility gate) host IOMMU (plain VFIO)
M1 — nucleus memory safety (V1) host
M2 multiple address spaces inter-AS isolation reachable == capabilitied (V2) + IPC no-amplification (V6) host
M3 emulated vIOMMU first load-bearing DMA-reach dma_reach ⊆ authorized (V3) + DTE-config (V4) nucleus (emulated)
M4 bare-metal AMD-Vi reclaim / stale-IOTLB safety (V5); V3/V4 on real silicon nucleus (bare-metal)
M5 — composed confinement assurance case nucleus (composed)

Under plain VFIO (M0–M2) the host programs the physical IOMMU. In this tree today, both the IOMMU authority model (crates/iommu) and real AMD-Vi hardware tables/driver (crates/iommu-amdvi) exist, run against QEMU 11's emulated AMD-Vi (amd-iommu,dma-remap=on), and have Verus proofs over their pure DteWords / 3-level IoPtPool / cmdbuf models; lifting the raw MMIO hardware path onto nucleus-stub PointsTo specs (Phase 4 M3) and running real gfx1201 hardware (M0/M4 on gpu-host) remain to be done.

Repo layout

rustproof/
├── AGENTS.md                                           # onboarding & guardrails for engineers + AI agents
├── toolchain/                                          # verus.lock, spec_t.lock, fetch-verus.sh
├── crates/
│   ├── kernel/                                         # generic nucleus (one impl, x86-64 + riscv64; 0 dyn, 0 static mut)
│   ├── kernel-demo/                                    # boot/containment demo logic (behind `demo` feature)
│   ├── abi/  deleg/  iommu-amdvi/                      # TCB: Verus-proven (246 obs) + Kani + Miri + host-tested
│   ├── capabilities/ iommu/ regions/ runstate/ mm/     # TCB: host/exhaustive + Miri + Kani (Verus Phase 4 M1)
│   ├── vspace/ vspace-riscv/ ipc/ sched/ loader*/      # TCB: page tables, IPC, run queue, ELF (Verus Phase 4 M2)
│   ├── hostcontract/  hal/                             # frozen M0 ioctl contract; Arch trait
│   ├── nucleus-stub/  arch-x86_64/  arch-riscv64/      # trusted unsafe stubs (raw MMIO/MSR/asm; Kani-checked)
│   ├── nucleus/  nucleus-riscv/                        # bootable kernel images
│   ├── init/  riscv-init/                              # untrusted root tasks (the demo)
│   └── userland-rt/  driver-host/  driver-shim/        # EMPTY PLACEHOLDERS (pre-M0 real-GPU driver host)
├── tools/                                              # verus.sh, verify-gate.py, mutate*.py, miri.sh, kani.sh, host-tests.sh, run-qemu*.sh
└── docs/                                               # design docs & living Phase 4 plan (below)

Status, plainly. Phases 0–3 are done: abi, deleg, and iommu-amdvi (pure DTE/3-level IoPtPool/cmdbuf) carry 246 unbounded Verus obligations behind a 6-channel accept-gate (tools/verus.sh), 17 crates carry 43 Kani harnesses (tools/kani.sh), 18 crates run under Tree Borrows Miri (tools/miri.sh), and 10 QEMU 11 rigs exercise real x86-64 (PVH/SeaBIOS/AMD-Vi/bridged) and RISC-V (OpenSBI/Sv39) boots. What is not here yet: Phase 4 Verus expansion (capabilities, regions, iommu, vspace, nucleus-stub PointsTo lifting, V5 stale-IOTLB ghost tokens, top-level composition), vendor/, libvirt/, and the real gfx1201 C++ lite:: driver bring-up on gpu-host.

The C++ lite:: driver is never linked into the nucleus — it is a separate, untrusted process reached only over the capability/IPC ABI.

Build & run

All four verification layers and the QEMU x86-64 / RISC-V rigs work today on Linux with pinned stable Rust 1.100.0 (rust-toolchain.toml, targets x86_64-unknown-none + riscv64gc-unknown-none-elf) and QEMU:

# Verus proofs + 6-channel accept-gate (fetches pinned Verus + bundled Z3 automatically)
./tools/verus.sh                            # full gate (246 obligations, 3 Z3 seeds, 19 mutants)
cargo run -p verify                         # workspace wrapper for tools/verus.sh

# Host tests, Tree Borrows Miri, Kani (4 GiB memory-capped), and mutation sweeps
./tools/host-tests.sh                       # 18 crates + check-demo-order.py
./tools/miri.sh                             # 18 crates (requires nightly + miri,rust-src)
./tools/kani.sh                             # 43 harnesses across 17 crates (sequential, 4 GiB cap)
./tools/mutate-kani.py                      # 20 Kani harness mutants
python3 tools/mutate.py                     # 76 host + QEMU x86/RISC-V mutants

# Boot & live AMD-Vi containment rigs under QEMU (run one at a time)
./tools/run-qemu.sh                         # x86-64 PVH + ring-3 init => "rustproof: BOOT OK"
IOMMU=1 FIRMWARE=1 ./tools/run-qemu.sh      # SeaBIOS + emulated AMD-Vi + edu DMA containment
BRIDGE=1 IOMMU=1 FIRMWARE=1 ./tools/run-qemu.sh
./tools/run-qemu-riscv.sh                   # riscv64 OpenSBI + Sv39 + userland

Planned (not wired yet — hardware-gated on gpu-host):

cargo xtask run      # real loop on gpu-host: build → image → VFIO-bind (no-FLR) → boot guest

gpu-host throughout these docs is a placeholder for your x86-64 GPU-passthrough machine; the GPU BDF (0000:03:00.0) and the libvirt domain/paths are examples — replace with your own.

Docs

  • AGENTS.md — start here if picking up work (engineer or AI agent): exact status, commands, Kani/Verus/spec-lock guardrails.
  • docs/formal-proof-plan.md — living execution plan & Phase 4 handoff: Phase 0–3 completion log and crate-by-crate M1→M5 Verus checklist.
  • docs/implementation-plan.md — master program plan: milestones, work-breakdown, critical path, staffing gates, risk register.
  • docs/repo-structure.md — workspace, toolchain pinning, boot, hosting the untrusted driver.
  • docs/milestone-M0.md — real-GPU M0 critical path (tasks T0.0–T0.11).
  • docs/host-contract.md — nucleus ↔ untrusted-driver ABI (9 ops, capabilities, IPC, the crux argument).
  • docs/nucleus-design.md — verified nucleus internals (caps, address spaces, IPC, scheduling, AMD-Vi manager, trusted stub).
  • docs/verification.md — Verus invariant ladder V1–V7, honest proof TCB, toolchain pin, decision history.
  • docs/ai-proof-writer.md — human-owned _t spec vs. agent-authored _u proof model and the 6-channel accept-gate.
  • docs/dev-infra.md — dev loop, CI jobs, red-team DMA harness, gpu-host integration & Gate G2 facts.

License

Licensed under the MIT License — see LICENSE.

Unless you state otherwise, any contribution you submit is licensed under MIT.

About

Rustproof: a Rust + Verus isolation nucleus that safely hosts an untrusted GPU compute driver (gfx1201). Design/scaffold stage.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages