Private tier: the virtio framework (misc/virtio) and ddi::private::virtio #6
Loading…
Reference in a new issue
No description provided.
Delete branch "r4-virtio"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Stacked on #5 (
r2-private-fd). Needed by illumos-drm's virtio-gpu driver (R4, WI-456).What
illumos-kernel-private-virtio-sys, a new private-tier crate for the gate's virtio framework (misc/virtio,uts/common/io/virtio/virtio.h): every function of the header, the four opaque types,virtio_direction_t,VIRTIO_ANY_INTR_TYPEand two feature bits. Each item cites its gate line atcda5b9a49f; the crate is empty unless built withunstable-gate-cda5b9a49f. It is a crate of its own rather than a module ofillumos-kernel-private-sysbecause the framework is its own kernel module: only virtio drivers should get-N misc/virtio(the §4 boundary rule).ddi::private::virtio, the safe wrapper (featureunstable-gate-cda5b9a49f-virtio), which makes the framework'sVERIFYs and panics unreachable from safe code (DESIGN.md §5.13):VirtioSetup::init(&OwnNode), thennegotiate→VirtioNegotiated(queues, configuration writes), thencomplete→ the runningVirtio.completeregisters the configuration handler, callsvirtio_init_completeonce, asksvirtio_intr_prionly when interrupts were added, refuses high-level priorities, and builds the state with the priority through anInitViewthat has no queues.Pending), so drivers complete in thread context (VirtioHandler::queue_work).Queue::submittakes the request (aChainData) and a closure that can only nameVirtioDmareached through the request; the queue owns it untilpoll. Empty chains are refused.Virtiodisables interrupts, waits for the task queue, shuts the device down, evacuates and drops every request, drops the state, and only then callsvirtio_fini.VirtioDmacopies with bounds checks. Configuration offsets are checked against the driver'sunsafeVirtioConfig::SIZE.lint-manknows the new crate. CI runs clippy, the host tests, the doctests (stable and the pinned nightly) and rustdoc with the virtio feature.Verification
cargo check/clippy -D warnings/fmt --check, workspace and with the feature.cargo test -p ddi --no-default-features --features unstable-gate-cda5b9a49f-virtio --lib: 13 passed, 4 of them new for virtio. They cover configuration ranges, cookie splitting, repeated indexes, and a no-lost-signal test with 8 marker threads and a worker, 20 rounds.compile_failtests with error codes (E0308DevInfofor init, E0599 late queue allocation, E0599 queues fromInitView, E0597 a buffer outside the request) and their compiling twins.cargo xtask lint-man --gate <checkout of cda5b9a49f>: 77 private citations, 0 errors. The one other error isddi_ncpus_expected, which postdates that gate. Against a newer gate, virtio.h moved and lint-man reports the citations as moved, as designed.cargo xtask kernel-checkagainst oibldofgate (illumoscda5b9a49f,virtioloaded by vioblk/vioif):illumos-kernel-private-virtio-sys: sizes 1/1, offsets 0/0, symbols 48/48. All other crates are as before; gld and ktest are not loaded.virtio_gpu, pinned atbe78455670, in a QEMU 6.2 guest withvirtio-gpu-gl-pci, illumoscda5b9a49f): setup, negotiation (0x110000003of0x130000003), both queues, the configuration handler and the running device work; the driver completed 19,543 requests (7,224 fenced, 5 queue-full waits, 0 failures, 0 timeouts) from its task queue, 8 threads submitting at once, andVirtio's teardown ran on each clean unload (two in the final boot: afterrun-r4-test.sh's refused detaches, and after Mesa's virgl driver had used the device). No panic. Logs are with illumos-drm#7.36d8c52c14): with a transitional vioblk attached first,virtio_initfor the GPU fails with "Failed to map CAP 1 @ BAR4". The wrapper reports it as theiniterror, which is all it can do;dd0c90c(rewrapped ind3bb84b) records it in DESIGN.md §5.13. The guests useddisable-modern=onfor the disk.Earlier text of this item, when the PR was opened while the test host was down: "Not run yet: the wrapper in the kernel with a real device. Its first user is the illumos-drm virtio-gpu driver, whose QEMU guest run is pending; the host was unreachable."
Two rows in DESIGN.md §5.13 (the
InitViewqueues and the repeated index) came from the local review, before any run.