feat(virtq): add packed virtio ring primitives#1382
feat(virtq): add packed virtio ring primitives#1382andreiltd wants to merge 5 commits intohyperlight-dev:mainfrom
Conversation
3db3820 to
bd2fd96
Compare
b4c8142 to
16de50c
Compare
dblnz
left a comment
There was a problem hiding this comment.
Great stuff, @andreiltd !
I left a few comments, most are small remarks, others are things I might have missed.
This is part 1 of my review, I still have some things left to look at that I plan on doing tomorrow.
| /// and readable buffers must be added before writable buffers. | ||
| #[derive(Debug, Default)] | ||
| pub struct BufferChainBuilder<T> { | ||
| elems: SmallVec<[BufferElement; 16]>, |
There was a problem hiding this comment.
Maybe documenting this 16 inline capacity as an optimization for the user to be aware
dbc4b97 to
60563c4
Compare
Add low-level packed virtqueue ring implementation in hyperlight_common::virtq, based on the virtio packed ring format. Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
60563c4 to
f356539
Compare
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
f356539 to
3aaa98e
Compare
Signed-off-by: Tomasz Andrzejak <andreiltd@gmail.com>
857f4bf to
2c6adcb
Compare
| let mut val = T::zeroed(); | ||
| let bytes = bytemuck::bytes_of_mut(&mut val); | ||
|
|
||
| self.read(addr, bytes)?; |
There was a problem hiding this comment.
The read method returns Result<usize, Error> but this discards the read count. If read returns less than the full length, this could silently produce corrupted data.
| /// The caller ensures that `ptr` is valid. | ||
| fn write_val<T: Pod>(&self, addr: u64, val: T) -> Result<(), Self::Error> { | ||
| let bytes = bytemuck::bytes_of(&val); | ||
| self.write(addr, bytes)?; |
There was a problem hiding this comment.
The write method returns Result<usize, Error> but this discards the write count. If write returns less than the full length, this could silently produce corrupted data.
Add low-level packed virtqueue ring implementation in
hyperlight_common::virtq, based on the virtio packed ring format.This is split from: #1368 and does not include any actual plumbing for guest/host communication.
Useful materials: