Repository navigation
Conversation
Per VirtIO 1.4 Sec 2.8.1, both driver and device ring wrap counters in packed virtqueues are initialized to 1. For packed rings, vhost and vhost-user SET_VRING_BASE encode the avail wrap counter in bit 15 and the used wrap counter in bit 31. Set the initial vring base to (1 << 15) | (1 << 31) when RING_PACKED is negotiated in VuFrontend::activate and VhostVsock::activate instead of hardcoding 0. Signed-off-by: Changyuan Lyu <changyuanl@google.com>
Filter VuFrontend::feature() so only supported VirtIO transport features (INDIRECT_DESC, EVENT_IDX, VERSION_1, ACCESS_PLATFORM, RING_PACKED) and device-specific feature bits (0..24 and 50..64) are exposed to the guest, stripping VHOST_PROTOCOL (bit 30) and unsupported transport or reserved bits (24..50). Also only include VHOST_PROTOCOL in VuFrontend::activate SET_FEATURES when advertised by the backend, and strip VHOST_PROTOCOL in VhostVsock::new. Replace unreachable!() in VuFrontend::handle_event with vu_error::QueueErr (draining the error eventfd on error and reset so re-activation does not loop), and replace unreachable!() in VuFrontend::handle_queue and VhostVsock::handle_queue with kick forwarding or error logging so unexpected notifications never crash the VMM. Signed-off-by: Changyuan Lyu <changyuanl@google.com>
Coverage Report for CI Build 42955106147Coverage increased (+0.9%) to 44.521%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats💛 - Coveralls |
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
Fixes two critical issues in Alioth's
vhostandvhost-userfrontend implementations:Packed virtqueue
SET_VRING_BASEwrap counter initialization:1.VIRTIO_F_RING_PACKEDis negotiated,vhostandvhost-userSET_VRING_BASEencodeavail_wrap_counterin bit 15 andused_wrap_counterin bit 31.VuFrontend::activateandVhostVsock::activateto set initialbaseto(1 << 15) | (1 << 31)for packed rings (0for split rings).VuFrontendfeature filtering and VMM crash prevention:VuFrontend::feature()to expose only supported VirtIO transport features (INDIRECT_DESC,EVENT_IDX,VERSION_1,ACCESS_PLATFORM,RING_PACKED) alongside device-specific feature bits (0..24and50..64), strippingVHOST_PROTOCOL(bit 30) and unsupported transport/reserved bits (24..50). Also stripVHOST_PROTOCOLinVhostVsock::newand only includeVHOST_PROTOCOLinVuFrontend::activateSET_FEATURESwhen advertised by the backend.unreachable!()inVuFrontend::handle_eventwithvu_error::QueueErr(draining the erroreventfdon error and reset so re-activation does not loop), and replaceunreachable!()inVuFrontend::handle_queueandVhostVsock::handle_queuewith kick notification forwarding or error logging so unexpected notifications never crash the VMM.Testing
alioth/src/virtio/vu/frontend_test.rsandalioth/src/virtio/dev/vsock/vhost_vsock_test.rscovering split vs. packedSET_VRING_BASE, conditionalVHOST_PROTOCOLinSET_FEATURES, feature bit filtering, queue error event handling, and unexpected queue notification handling.cargo +nightly fmt --check,cargo test --workspace,cargo clippy --all-targets -- -D warnings, andcargo clippy --all-targets --target x86_64-unknown-linux-gnu -- -D warnings.