Skip to content

feat: add virtqueue transport foundations - #1793

Open
andreiltd wants to merge 19 commits into
external-bytesfrom
virtq-foundations
Open

feat: add virtqueue transport foundations#1793
andreiltd wants to merge 19 commits into
external-bytesfrom
virtq-foundations

Conversation

@andreiltd

@andreiltd andreiltd commented Sep 3, 2026

Copy link
Copy Markdown
Member

The patch implements shared layout and ownership model for virtq based host and guest communication. This is a preparation work for replacing stack based IO with virtq, in the meantime function calls and logging use the legacy transport. Actual takeover, buffer mappings, guest allocated pools and retained buffer snapshots are separate stages.

  • queue configurations and a shared scratch arena for rings and buffer pools.
  • SlotPool allocation,
  • stateful chain I/O,
  • shared message framing,
  • guest queue initialization,
  • canonical ring state validation

@andreiltd andreiltd changed the title virtq foundations feat(virtq): add virtqueue transport foundations Sep 3, 2026
@andreiltd andreiltd changed the title feat(virtq): add virtqueue transport foundations feat: add virtqueue transport foundations Sep 3, 2026
@andreiltd andreiltd added kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. area/fuzzing Fuzzing related test failures created from weekly CI labels Sep 3, 2026
@andreiltd andreiltd added the regen-goldens Regenerate snapshot golden fixtures label Sep 5, 2026
Read received payloads directly into caller owned storage and require
paired completion of readable/writable chains.

Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Make pool restoration transactional.

Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Split and rename the pool implementations, add explicit lower/upper
SlotPool regions.

Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Define deterministic producer and consumer reset behavior. Validate
canonical events, descriptor chains, IDs, buffer policy, and unused
descriptors.

Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Represent scratch bookkeeping with one repr(C) layout. Derive offsets
and assert the host/guest ABI at compile time.

Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Use the first GPA of the reserved pages as an exclusive limit. Accept
allocations ending at the limit and reject address overflow.

Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Define directional queue depths, buffer sizes, and pool page counts.
Account for guest allocated rings and pools in minimum scratch
calculations. Publish the transport contract through scratch-top
metadata.

Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
This patch adds guest owned G2H and H2G rings and pools during guest
initialization, and prefill H2G receive capacity. The guest then
publishes their gpas through scratch metadata.

The patch is also validates allocation order, scratch ownership, and
canonical ring images before installing either host consumer.

Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Persist validated G2H and H2G ring images in running snapshots. Restore fixed transport allocations and install fresh host consumers before sandbox execution.

Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Allocate logical regions atomically

Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Use queue_size instead of queue_depth

Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
@andreiltd
andreiltd marked this pull request as ready for review September 8, 2026 14:41
Copilot AI lite review requested due to automatic review settings September 8, 2026 14:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

TransportArena::new currently sets h2g_pool_addr to the G2H pool offset, causing pool overlap and an incorrect transport arena layout.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds the foundations needed to support a virtqueue-based transport across host/guest, and wires that transport geometry into scratch layout and snapshot versioning so snapshots can faithfully restore or reinitialize transport state.

Changes:

  • Extend sandbox configuration, scratch layout, and snapshot config schema to include per-direction virtqueue geometry (queue sizes, buffer sizes, pool pages) and bump snapshot ABI/config versions.
  • Add host/guest virtqueue memory access primitives and guest transport context initialization during generic_init.
  • Introduce canonical ring image validation (incl. fuzzing) and refactor buffer/pool plumbing toward SlotPool + BufferLease/BufferMap.
File summaries
File Description
src/hyperlight_host/tests/snapshot_goldens/goldens_version.rs Bump goldens version to v3.0
src/hyperlight_host/tests/integration_test.rs Adjust OOM/abort expectations for transport
src/hyperlight_host/src/sandbox/uninitialized.rs Update tests for new scratch sizing
src/hyperlight_host/src/sandbox/uninitialized_evolve.rs Attach virtq on initialize path
src/hyperlight_host/src/sandbox/snapshot/tripwires.rs Bump ABI and config media type expectations
src/hyperlight_host/src/sandbox/snapshot/mod.rs Carry optional in-memory virtq snapshot
src/hyperlight_host/src/sandbox/snapshot/file/mod.rs Persist/load transport layout fields; config v2 gating
src/hyperlight_host/src/sandbox/snapshot/file/media_types.rs Add MT_CONFIG_V2; bump ABI to 3
src/hyperlight_host/src/sandbox/snapshot/file/config.rs Add transport fields + normalization validation
src/hyperlight_host/src/sandbox/snapshot/file_tests.rs Tests for config v2 + transport round-trip
src/hyperlight_host/src/sandbox/initialized_multi_use.rs Restore/attach virtq depending on NextAction
src/hyperlight_host/src/sandbox/config.rs Add transport geometry to configuration
src/hyperlight_host/src/mem/virtq_mem.rs Host MemOps for scratch + ring images
src/hyperlight_host/src/mem/shared_mem.rs Add checked atomic load/store helpers
src/hyperlight_host/src/mem/mod.rs Export virtq modules
src/hyperlight_host/src/mem/mgr.rs Attach/restore/snapshot virtq in memory manager
src/hyperlight_host/src/mem/layout.rs Place transport arena in fixed scratch prefix
src/hyperlight_guest/src/transport/mod.rs Global guest transport context plumbing
src/hyperlight_guest/src/transport/mem.rs Guest MemOps for scratch GVAs
src/hyperlight_guest/src/transport/context.rs Guest virtq producers + pool construction
src/hyperlight_guest/src/prim_alloc.rs Shared allocation limit helper + tests
src/hyperlight_guest/src/lib.rs Export guest transport module
src/hyperlight_guest/src/layout.rs Add scratch-top accessors for transport metadata
src/hyperlight_guest/src/error.rs Convert VirtqError into guest error
src/hyperlight_guest/src/arch/amd64/prim_alloc.rs Use scratch allocator limit helper
src/hyperlight_guest/src/arch/aarch64/prim_alloc.rs Use scratch allocator limit helper
src/hyperlight_guest_bin/src/transport.rs Guest transport initialization at boot
src/hyperlight_guest_bin/src/lib.rs Call transport init during generic init
src/hyperlight_common/src/virtq/ring/fuzz.rs QuickCheck fuzz for ring ops interleavings
src/hyperlight_common/src/virtq/ring/canonical.rs Canonical packed ring image validation
src/hyperlight_common/src/virtq/pool/tests.rs SlotPool unit tests
src/hyperlight_common/src/virtq/pool/slot.rs SlotPool implementation
src/hyperlight_common/src/virtq/pool/fuzz.rs QuickCheck fuzz for SlotPool invariants
src/hyperlight_common/src/virtq/msg.rs Remove old virtq message header module
src/hyperlight_common/src/virtq/event.rs Add canonical clear helper
src/hyperlight_common/src/virtq/desc.rs Add descriptor table clear + base accessor
src/hyperlight_common/src/virtq/concurrency.rs Update loom tests to new pool/buffer APIs
src/hyperlight_common/src/virtq/buffer.rs Add Segments split/chunk APIs; BufferLease
src/hyperlight_common/src/virtq/access.rs Add BufferMap interface for completed buffers
src/hyperlight_common/src/transport.rs Shared message framing + external values
src/hyperlight_common/src/lib.rs Export shared transport module
src/hyperlight_common/src/layout.rs Scratch-top metadata struct + transport arena
src/hyperlight_common/src/arch/amd64/layout.rs Make min_scratch_size checked/Option
src/hyperlight_common/src/arch/aarch64/layout.rs Make min_scratch_size checked/Option
src/hyperlight_common/benches/virtq_api.rs Update benchmarks to SlotPool naming
src/hyperlight_common/benches/common/mod.rs Update bench harness to BufferMap/Lease
src/hyperlight_common/benches/buffer_pool.rs Replace old pool benches with SlotPool
fuzz/README.md Document added canonical image fuzzing
fuzz/fuzz_targets/virtq_packed_ring.rs Fuzz canonical image validation paths
docs/snapshot-versioning.md Update snapshot versioning docs for transport
docs/snapshot-oci-format.md Update OCI snapshot format docs for v2 config
CHANGELOG.md Note transport and ABI/schema changes
Review details
  • Files reviewed: 58/58 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +227 to +233
Some(Self {
g2h_ring_addr: base_addr,
h2g_ring_addr: addr(h2g_ring_offset)?,
g2h_pool_addr: addr(g2h_pool_offset)?,
h2g_pool_addr: addr(h2g_pool_offset)?,
ring_span_len: g2h_pool_offset,
len,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks to me like offsets are correct, also changeset suggestion is nonsensical.

Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/fuzzing Fuzzing related test failures created from weekly CI kind/enhancement For PRs adding features, improving functionality, docs, tests, etc. ready-for-review PR is ready for (re-)review regen-goldens Regenerate snapshot golden fixtures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants