Repository navigation
feat(uffd): MAP_PRIVATE base-file backing + MISSING|MINOR registration (substrate v2b) - #4
Merged
Merged
Conversation
The engrams ADR 0045 unified-memory-substrate (v2b) surface. Clean-room, derived from kernel primitives + the engrams spec, NOT from any AGPL-licensed fork. Inert/opt-in: without the new field every path is byte-identical to stock; never touches src/vmm/src/snapshot/ and never changes SNAPSHOT_VERSION (10.0.0). A new optional top-level load param `uffd_base_file`: when set with the Uffd memory backend, guest memory is created as MAP_PRIVATE of this shmem file (reusing the snapshot_file region builder, shared=false) instead of anonymous, and the UFFD registration uses MISSING|MINOR (userfaultfd crate feature linux5_13). The external handler then resolves base-identical pages with UFFDIO_CONTINUE — one page-cache copy shared by every same-template microVM on the host — and session-divergent pages with UFFDIO_COPY; guest writes COW natively to private anon pages, so the shared base file is never written through the mapping. Invalid with the File backend; rejected for hugetlbfs (minor faults are shmem-only here). Requires kernel >= 5.13. Unit test covers read-through, COW privacy, mapping offsets, and the hugetlbfs rejection; the engrams-side substrate_kernel_capabilities suite gates the kernel behaviors themselves. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The engrams ADR 0045 unified-memory-substrate (v2b) fork surface — D1 of the substrate program. Clean-room (kernel primitives + the engrams spec; never any AGPL fork).
A new optional top-level load param
uffd_base_file: when set with the Uffd memory backend, guest memory is created asMAP_PRIVATEof this shmem file (reusing the existingsnapshot_fileregion builder withshared=false) instead of anonymous, and UFFD registration becomesMISSING|MINOR(userfaultfd crate featurelinux5_13). The external handler then resolves:UFFDIO_CONTINUE: one page-cache copy shared by every same-template microVM on the host (the density mechanism, now available to restores)UFFDIO_COPY: privateInvariants held
src/vmm/src/snapshot/;SNAPSHOT_VERSIONstays 10.0.0 (R2 byte-compat preserved).Validation
test_create_guest_memory_with_base_file): read-through from the base, COW privacy (write never reaches the file), mapping offsets, hugetlbfs rejection — green on engram-dev (kernel 6.8).substrate_kernel_capabilitiessuite (engrams #163).Consumed by the engrams D2 PR (client field + handler CONTINUE arm + base-shm provisioning); the submodule bump there runs the
build-firecrackerjob + R2 diff-guard end-to-end.🤖 Generated with Claude Code