diff options
author | Chirantan Ekbote <chirantan@chromium.org> | 2019-07-26 18:54:16 +0900 |
---|---|---|
committer | Commit Bot <commit-bot@chromium.org> | 2019-10-06 05:35:47 +0000 |
commit | 41e61d1fc373a38d37961793bb342c207d7adeea (patch) | |
tree | c0a6ae04029fda0a18c6887a36c3fa392667284e /devices/src/virtio/descriptor_utils.rs | |
parent | 28a9d2b70d98e4fd8ce466190a52b85cf270e7bb (diff) | |
download | crosvm-41e61d1fc373a38d37961793bb342c207d7adeea.tar crosvm-41e61d1fc373a38d37961793bb342c207d7adeea.tar.gz crosvm-41e61d1fc373a38d37961793bb342c207d7adeea.tar.bz2 crosvm-41e61d1fc373a38d37961793bb342c207d7adeea.tar.lz crosvm-41e61d1fc373a38d37961793bb342c207d7adeea.tar.xz crosvm-41e61d1fc373a38d37961793bb342c207d7adeea.tar.zst crosvm-41e61d1fc373a38d37961793bb342c207d7adeea.zip |
virtio: queue: Enforce DescriptorChain ordering
The virtio spec requires that all read-only descriptors appear in the chain before any write-only descriptors. Enforce this in the `checked_new` function by adding a new `required_flags` parameter. The `next_descriptor` function will set this to `VIRTQ_DESC_F_WRITE` if the current descriptor is write-only. This ensures that once we see a write-only descriptor, all following descriptors must be write-only. BUG=b:136127316 TEST=none Change-Id: Id8f942a4236a20f62f35439f3648dbec17e14c00 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1757239 Auto-Submit: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Diffstat (limited to 'devices/src/virtio/descriptor_utils.rs')
-rw-r--r-- | devices/src/virtio/descriptor_utils.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/devices/src/virtio/descriptor_utils.rs b/devices/src/virtio/descriptor_utils.rs index 2233931..409134e 100644 --- a/devices/src/virtio/descriptor_utils.rs +++ b/devices/src/virtio/descriptor_utils.rs @@ -517,7 +517,8 @@ pub fn create_descriptor_chain( ); } - DescriptorChain::checked_new(memory, descriptor_array_addr, 0x100, 0).ok_or(Error::InvalidChain) + DescriptorChain::checked_new(memory, descriptor_array_addr, 0x100, 0, 0) + .ok_or(Error::InvalidChain) } #[cfg(test)] |