virtio-devices: Fix some spec compliance issues - #8066
Merged
Merged
Conversation
rbradford
force-pushed
the
202604/virtio-fixes
branch
from
April 20, 2026 11:17
3daf90f to
8ed3adb
Compare
phip1611
reviewed
Apr 20, 2026
phip1611
left a comment
Member
There was a problem hiding this comment.
generally LGTM! Did you use an LLM to find all the spec inconsistencies?
rbradford
force-pushed
the
202604/virtio-fixes
branch
from
April 20, 2026 12:07
8ed3adb to
e94aea6
Compare
rbradford
marked this pull request as ready for review
April 20, 2026 12:07
Member
Author
Yes, I updated the PR description. |
The virtio spec says the used-ring length is bytes the device wrote to device writable descriptors. The net TX descriptors are device readable only (the device wrote nothing back) so the length needs to be 0. On the ctrl queue the number of bytes reported was wrongly the size of the status descriptor not the number of bytes written (the descriptor is permitted to be larger). Signed-off-by: Rob Bradford <[email protected]>
The virtio spec allows the use of larger descriptors (for future expansion). Relax the bounds check to only reject descriptors that are too small. Signed-off-by: Rob Bradford <[email protected]>
The virtio spec allows the use of larger descriptors (for future expansion). Relax the bounds check to only reject descriptors that are too small. Signed-off-by: Rob Bradford <[email protected]>
The virtio spec requires that a status response is always written on error. This was missing from the path where we had a valid request but not for one we support. Signed-off-by: Rob Bradford <[email protected]>
The virtio spec allows a chain of writable descriptors however the rng device was assuming just a single writable descriptor. Instead fill in all writable descriptors. There is no status byte (unlike e.g. block) and instead 0 bytes used is used to indicate error. Signed-off-by: Rob Bradford <[email protected]>
The number of bytes written into descriptors should be reported for `add_used()`. Here it is either just the status byte or also the size of serial ID for the block device. Signed-off-by: Rob Bradford <[email protected]>
The driver needs to be notified with the number of bytes written by the device. Ensure that the correct number of bytes is reported. Signed-off-by: Rob Bradford <[email protected]>
rbradford
force-pushed
the
202604/virtio-fixes
branch
from
April 20, 2026 13:34
e94aea6 to
88ff419
Compare
Member
Author
|
@phip1611 PTAL! |
phip1611
approved these changes
Apr 20, 2026
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.
Fix some basic spec compliance issues. :
add_used()I used Claude to compare the virtio spec with our implementation. There was a lot of issues; these are fixes for all those related to reporting wrong bytes written with
.add_used()and incorrect descriptor chain expectations (multiple writable, too strict.)