-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
driver/virtio/blk: Ensure request header stays in-page boundaries **AND** some minor sglist cleanup #1290
driver/virtio/blk: Ensure request header stays in-page boundaries **AND** some minor sglist cleanup #1290
Conversation
4fc766a
to
020f7fa
Compare
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,
Reviewed-by: Andrei Stan andreistan2003@gmail.com
020f7fa
to
fb3dbe3
Compare
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 to me, thanks @mogasergiu!
Only one nitpick: I suggest having some consistency about the "scatter-gather" writing.
For instance, in this comment the two words are separated by a dash, while in this one they are not.
Reviewed-by: Razvan Virtan virtanrazvan@gmail.com
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.
Hey @mogasergiu, I have only some minor comments, otherwise, this PR looks good. 👍🏻
It may come in handy to do scatter-gather list save and restore in places other than the scatter-gather library. Therefore, allow others to see the corresponding definitions by placing them in the header. Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
Rename `uk_sglist_append_netbuf` to `uk_netbuf_sglist_append` and move it to the libuknetdev, since that is its only client. Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
The header (first descriptor) of the virtio-blk request must always come in one piece! By aligning to its size (16), we ensure that it will be contained entirely in one page only, i.e. the scatter-gather list will not process it as two segments, which would result in two descriptors. E.g. If the address ends something like 0x...ff8 then the header will span 0x...ff8 -> 0x...008 crossing the next page and resulting in the scatter-gather list splitting it into two segments and thus into two descriptors, which QEMU seems to not like. To help with this, declare the request header at the beginning of the virtio-blk request structure and make its allocation 16-byte aligned, guaranteeing its length will never cross the page boundary. Signed-off-by: Sergiu Moga <sergiu@unikraft.io>
fb3dbe3
to
fb49749
Compare
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.
Thanks for the updates.
Approved-by: Simon Kuenzer simon@unikraft.io
It may come in handy to do scatter-gather list save and restore in places other than the scatter-gather library. Therefore, allow others to see the corresponding definitions by placing them in the header. Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com> Approved-by: Simon Kuenzer <simon@unikraft.io> GitHub-Closes: #1290
Rename `uk_sglist_append_netbuf` to `uk_netbuf_sglist_append` and move it to the libuknetdev, since that is its only client. Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com> Approved-by: Simon Kuenzer <simon@unikraft.io> GitHub-Closes: #1290
The header (first descriptor) of the virtio-blk request must always come in one piece! By aligning to its size (16), we ensure that it will be contained entirely in one page only, i.e. the scatter-gather list will not process it as two segments, which would result in two descriptors. E.g. If the address ends something like 0x...ff8 then the header will span 0x...ff8 -> 0x...008 crossing the next page and resulting in the scatter-gather list splitting it into two segments and thus into two descriptors, which QEMU seems to not like. To help with this, declare the request header at the beginning of the virtio-blk request structure and make its allocation 16-byte aligned, guaranteeing its length will never cross the page boundary. Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com> Approved-by: Simon Kuenzer <simon@unikraft.io> GitHub-Closes: #1290
It may come in handy to do scatter-gather list save and restore in places other than the scatter-gather library. Therefore, allow others to see the corresponding definitions by placing them in the header. Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com> Approved-by: Simon Kuenzer <simon@unikraft.io> GitHub-Closes: unikraft#1290
Rename `uk_sglist_append_netbuf` to `uk_netbuf_sglist_append` and move it to the libuknetdev, since that is its only client. Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com> Approved-by: Simon Kuenzer <simon@unikraft.io> GitHub-Closes: unikraft#1290
The header (first descriptor) of the virtio-blk request must always come in one piece! By aligning to its size (16), we ensure that it will be contained entirely in one page only, i.e. the scatter-gather list will not process it as two segments, which would result in two descriptors. E.g. If the address ends something like 0x...ff8 then the header will span 0x...ff8 -> 0x...008 crossing the next page and resulting in the scatter-gather list splitting it into two segments and thus into two descriptors, which QEMU seems to not like. To help with this, declare the request header at the beginning of the virtio-blk request structure and make its allocation 16-byte aligned, guaranteeing its length will never cross the page boundary. Signed-off-by: Sergiu Moga <sergiu@unikraft.io> Reviewed-by: Razvan Virtan <virtanrazvan@gmail.com> Approved-by: Simon Kuenzer <simon@unikraft.io> GitHub-Closes: unikraft#1290
Prerequisite checklist
checkpatch.uk
on your commit series before opening this PR;Base target
kvm
Additional configuration
Description of changes
Move some sglist stuff
lib/uknetdev/netbuf.c
The important addition of the PR:
The header (first descriptor) of the virtio-blk request must always
come in one piece! By aligning to its size (16), we ensure that
it will be contained entirely in one page only, i.e. the
scatter-gather list will not process it as two segments, which
would result in two descriptors.
E.g. If the address ends something like 0x...ff8 then the header
will span 0x...ff8 -> 0x...008 crossing the next page and resulting
in the scatter-gather list splitting it into two segments and
thus into two descriptors, which QEMU seems to not like.
To help with this, declare the request header at the beginning
of the virtio-blk request structure and make its allocation
16-byte aligned, guaranteeing its length will never cross the page
boundary.