Skip to content

Commit 40c1815

Browse files
committed
fix: some docs improvements
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
1 parent ff376f3 commit 40c1815

1 file changed

Lines changed: 34 additions & 41 deletions

File tree

docs/virtio-host-guest-communication.md

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ A logical message may span several descriptors or several H2G receive buffers.
148148

149149
### External byte values
150150

151-
Large `VecBytes` and `ByteChunks` values stay outside the FlatBuffer. The
152-
FlatBuffer contains the total logical value length and whether the value is
153-
chunked. The encoder can then reference the caller's byte slices directly
154-
without first copying them into one contiguous FlatBuffer.
151+
`ByteChunks` values stay outside the FlatBuffer. The FlatBuffer contains the
152+
total logical value length and whether the value is chunked. The encoder can
153+
then reference the caller's byte slices directly without first copying them into
154+
one contiguous FlatBuffer.
155155

156156
On the guest, completed shared memory allocations can become
157157
`Bytes::from_owner` values. `ByteChunks` can therefore map transport storage
@@ -177,8 +177,8 @@ logical byte sequence split where it intersects transport buffers:
177177
```text
178178
sender chunks: [------][----------][----]
179179
logical byte stream: [------------------------]
180-
transport buffers: [--------][--------][--------][--]
181-
receiver chunks: [--------][--------][--------][--]
180+
transport buffers: [--][--------][--------][--------]
181+
receiver chunks: [--][--------][--------][--------]
182182
```
183183

184184
H2G chunking follows the preposted H2G slot size. G2H responses returned to
@@ -290,7 +290,7 @@ lengths as untrusted.
290290

291291
The transport arena lives in scratch and is not captured as ordinary guest
292292
memory. Guest producer and pool bookkeeping is normal guest state, while ring
293-
and pool bytes live in scratch. Snapshot capture needs a canonical transport
293+
and pool bytes live in scratch. Snapshot capture needs a canonical transport
294294
state.
295295

296296
`MultiUseSandbox` tracks whether queue traffic occurred after the last
@@ -370,25 +370,33 @@ The count only answers whether retained slots exist. It does not contain pool
370370
identity, addresses, or initialized lengths. Retained pool payloads cannot be
371371
restored because pool bytes are absent from the snapshot.
372372

373-
### Planned retained payload snapshots
373+
## Future guest allocated pools and retained snapshots
374374

375-
The mailbox is intended to carry a bounded, size-prefixed FlatBuffer manifest.
376-
The planned manifest has separate G2H and H2G vectors. Each retained range
377-
contains:
375+
Transport pools can leave the fixed arena and use guest allocated scratch.
376+
The rings and mailbox remain at fixed host assigned addresses. At startup, the
377+
guest allocates each complete pool with `alloc_phys_pages`. It allocates fresh
378+
pools when the snapshot generation changes.
378379

379-
```text
380-
offset: u64 pool-relative slot start
381-
len: u32 initialized payload length
382-
```
380+
The host accepts descriptor payloads anywhere in guest allocator scratch. It
381+
validates complete ranges, writable H2G buffers, uniqueness, and overlap. Ring
382+
access remains restricted to the fixed arena.
383+
384+
Pool GVAs are transient and cannot back retained `Bytes` directly. Before
385+
constructing owner backed `Bytes`, the guest maps the buffer's physical pages
386+
at a stable GVA in a reserved alias region. The `Bytes` pointer uses that
387+
alias. The final owner unmaps the alias before returning the slot to its pool.
383388

384-
The host can validate exact slot starts and bounds, zero the retained backing,
385-
copy only initialized ranges, and include that sanitized backing in the
386-
snapshot. Free slots, posted H2G buffers, unused slot tails, and unrelated
387-
bytes sharing a retained page remain zero.
389+
Stable aliases make retained payloads ordinary snapshot mappings. Snapshot
390+
capture copies each mapped physical page into snapshot memory while preserving
391+
its alias GVA. Multiple aliases to one physical page share one copied page.
392+
Owner construction clears the unused slot tail. Checkpointing clears free
393+
slots in pools with retained owners, so captured pages contain retained bytes
394+
and zeros.
388395

389-
The size prefix is published last. The host bounds it by trusted mailbox
390-
capacity before FlatBuffer verification, then validates every range against
391-
the configured pool geometry.
396+
Pool backing belongs to one snapshot generation. Retained owners keep the old
397+
pool metadata and stable aliases. After restore, the host enters the guest
398+
without an H2G request. The guest resets both producers, allocates fresh pools,
399+
prefills H2G, and returns before the host uses the restored queues.
392400

393401
## Placement and relocation limitations
394402

@@ -416,25 +424,10 @@ arena relative handle that resolves its address on every access and does not
416424
promise a stable borrowed slice. That would be a different guest API and would
417425
not constrain pointers created by unsafe code.
418426

419-
Snapshots containing retained transport values must restore each pool at the same
420-
GVA. The GPA or host backing may move only if page tables and host memory access
421-
preserve that GVA. Restore must fail if it cannot reserve or recreate the original
422-
virtual range.
423-
424-
A guest allocated transport needs a stronger publication and relocation
425-
contract:
426-
427-
* The guest allocates rings and pools from scratch and publishes all regions.
428-
* The host validates alignment, bounds, ordering, overlap, and capacity before
429-
attaching consumers.
430-
* Snapshot metadata records the published region placement.
431-
* Restore preserves pool GVAs when retained values exist.
432-
* GVA relocation is limited to snapshots without retained values, where known
433-
ring, pool, producer, and guest context state can be rebuilt, or to a future
434-
offset based guest API.
435-
436-
This contract is part of the
437-
[snapshot ABI](./snapshot-versioning.md) and needs an explicit format change.
427+
Snapshots containing retained transport values must restore each pool at the
428+
same GVA. The GPA or host backing may move only if page tables and host memory
429+
access preserve that GVA. Restore must fail if it cannot reserve or recreate
430+
the original virtual range.
438431

439432
Transport capacity is also fixed when the sandbox is created. Runtime queue
440433
resize and VIRTIO feature negotiation are not supported.

0 commit comments

Comments
 (0)