New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plat/drivers/virtio: Fix virtio read write #970
Conversation
✅ Checkpatch passed Beep boop! I ran Unikraft's
|
All looks good to me. Reviewed-by: Tu Dinh Ngoc dinhngoc.tu@irit.fr |
Thanks for fixing this, @zhxj9823. I'm fine with the changes. I would only add a comment as to why we are handling virtio-net (mac address) and virtio-9p (tag) in this manner, especially given that the VirtIO 1.0/1.1 specs state that the driver shouldn't do a byte by byte handling: 4.2.2.2 Driver Requirements: MMIO Device Register Layout
Since we cannot avoid braking the atomicity (the mac address has 6 bytes), I would say this change is fine. The only issue with removing the assertions is that when we do so, we might silence a future bug. IMO, the risk is quite low, as hopefully these code paths won't be require many changes in the future. Without additional refactoring, which I don't believe is necessary at this time, I don't see a clear method to handle this appropriately. |
Thanks for the comment. An alternative way of handling this issue is to explicitly use Besides, I think we can add a warning message in this case to give a hint if anything wrong arises. |
@zhxj9823 please add a comment on the You can also add a warning if you wish on the |
fa4a7ea
to
3ca421f
Compare
Add support for variable length of virtio read and write. The original error message is replaced by a warning message. Two cases in virtio_net and virtio_9p uses this feature and the comments are added to note the usage. Signed-off-by: Xingjian Zhang <zhxj9823@qq.com>
3ca421f
to
33eb9bd
Compare
@Krechals, @eduardvintila please provide your feedback / sign-off so that we can merge this in 0.14, thanks! 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, thanks.
Reviewed-by: Eduard Vintilă eduard.vintila47@gmail.com
LGTM. Thank you, @zhxj9823! Reviewed-by: Andrei Topala topala.andrei@gmail.com |
Approved-by: Michalis Pappas <michalis.unikraft.io> |
Add support for variable length of virtio read and write.
Prerequisite checklist
checkpatch.uk
on your commit series before opening this PR;Base target
kvm
Description of changes
The
vm_get
andvm_set
invirtio_mmio
can only handle reading/writing 1/2/4/8 bytes. However, there are several cases, such as in virtio_net and virtio_9p, that the length of bytes to read is not supported by this function. This PR adds support to this case by using_virtio_cread_bytes
and_virtio_cwrite_bytes
functions in the default case ofvm_set
andvm_get
functions correspondingly. This approach turns ann
-byte read/write operation inton
1-byte read/write operations.