Skip to content

experiment: v0.4 Phase 4 PoC — WpBranch snapshot round-trip + restore#160

Merged
WaylandYang merged 3 commits into
mainfrom
experiment/v0.4-phase4-restore
May 25, 2026
Merged

experiment: v0.4 Phase 4 PoC — WpBranch snapshot round-trip + restore#160
WaylandYang merged 3 commits into
mainfrom
experiment/v0.4-phase4-restore

Conversation

@WaylandYang
Copy link
Copy Markdown
Contributor

The fourth and final kernel-level question for v0.4: are WpBranch-captured snapshots actually restorable, or just bit-consistent?

This PoC uses the production `forkd_uffd::wp_snapshot::WpBranch` library (not raw uffd_raw) to capture a snapshot during a KVM guest's run, then loads that snapshot into a fresh KVM VM and validates the restored VM re-runs the guest code correctly.

Result: PASS

```
[stage 1] source VM
running source vcpu... halted; memfd[0x1000] = 0x42 ✓

[stage 2] WpBranch capture
arm: 13.245µs
bulk_copy: 256 pages
snapshot has BEFORE marker (0xBE) at 0x1000 ✓

[stage 3] restore + re-run
destination memfd loaded with snapshot ✓
dest vcpu halted; memfd[0x1000] = 0x42 (re-ran code) ✓

Phase 4 PASSED — restore is functionally valid, not just bit-consistent.
```

v0.4 kernel-level open questions: all closed

# Question Answered by Result
1 UFFD_WP works on memfd Phase 1 PoC 3 ms/GiB linear
2 WP catches KVM guest writes via EPT Phase 2 PoC flags=0x3
3 UFFD_WP × THP Phase 3 PoC 4 KiB granularity
4 WpBranch snapshots restorable this PoC round-trip works

What remains for v0.4 to ship

Integration engineering, not research:

  1. Shared memfd handle to Firecracker (path documented in DESIGN-v0.4-PHASE3-SPIKE.md — `/proc/self/fd` looks viable without FC patch).
  2. `--live-fork` flag through forkd-controller::branch_sandbox.
  3. Reproduce `bench/pause-window/sweep-diff.sh` with --live-fork for v0.3.4-vs-v0.4 data.

Test plan

  • Build on dev box (kernel 6.14): `cargo build --release -p v0_4-restore-poc` clean.
  • Run: `sudo ./target/release/v0_4-restore-poc` — passes.

🤖 Generated with Claude Code

WaylandYang and others added 3 commits May 25, 2026 12:44
Uses the production forkd_uffd::wp_snapshot::WpBranch library (not the
raw uffd_raw module from earlier PoCs) to capture a snapshot during a
KVM guest's lifetime, then loads that snapshot into a fresh KVM VM
and validates the restored VM re-runs the guest code correctly.

Sequence:
  1. source VM: memfd-backed, guest writes 0x42, halts.
  2. reset BEFORE marker, WpBranch captures snapshot.
  3. fresh dest VM: memfd loaded from snapshot file.
  4. dest vcpu runs same guest code from 0:0x100 → writes 0x42.
  5. ✓ dest memfd at GPA 0x1000 holds 0x42 (restore is valid).

If this passes, the WpBranch-captured snapshot file is functionally
restorable — not just bit-consistent with the pre-WP-arm state.
This is the last kernel-level question for v0.4: previous PoCs proved
WP catches writes and is consistent; this proves the resulting file
works as a snapshot.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@WaylandYang WaylandYang merged commit 04d4363 into main May 25, 2026
2 checks passed
@WaylandYang WaylandYang deleted the experiment/v0.4-phase4-restore branch May 25, 2026 05:04
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.

1 participant