summary refs log tree commit diff
path: root/devices/src/virtio/block.rs
diff options
context:
space:
mode:
authorDaniel Verkamp <dverkamp@chromium.org>2018-10-24 11:30:34 -0700
committerchrome-bot <chrome-bot@chromium.org>2018-11-21 01:25:28 -0800
commite81a3e66cc266821fa5faec258d33c2eb3d8e102 (patch)
treee968ec22d1db178aa08ffc3f4d067c47a9dc88b1 /devices/src/virtio/block.rs
parent5c4ad02dd4865949e7f4df1a04f4c1cc603e6c64 (diff)
downloadcrosvm-e81a3e66cc266821fa5faec258d33c2eb3d8e102.tar
crosvm-e81a3e66cc266821fa5faec258d33c2eb3d8e102.tar.gz
crosvm-e81a3e66cc266821fa5faec258d33c2eb3d8e102.tar.bz2
crosvm-e81a3e66cc266821fa5faec258d33c2eb3d8e102.tar.lz
crosvm-e81a3e66cc266821fa5faec258d33c2eb3d8e102.tar.xz
crosvm-e81a3e66cc266821fa5faec258d33c2eb3d8e102.tar.zst
crosvm-e81a3e66cc266821fa5faec258d33c2eb3d8e102.zip
devices: convert virtio features to a u64
The virtio specification only defines feature bits in the 0-63 range
currently, so we can represent the features as a u64.  The Linux kernel
makes the same simplifying assumption, and very few features have been
defined beyond the first 32 bits, so this is probably safe for a while.

This allows the device models to be simplified, since they no longer
need to deal with the features paging mechanism (it is handled by the
generic virtio transport code).

BUG=None
TEST=build_test; boot termina on kevin

Change-Id: I6fd86907b2bdf494466c205e85072ebfeb7f5b73
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1313012
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Diffstat (limited to 'devices/src/virtio/block.rs')
-rw-r--r--devices/src/virtio/block.rs12
1 files changed, 4 insertions, 8 deletions
diff --git a/devices/src/virtio/block.rs b/devices/src/virtio/block.rs
index c1e7be8..f2ddb2c 100644
--- a/devices/src/virtio/block.rs
+++ b/devices/src/virtio/block.rs
@@ -686,12 +686,8 @@ impl<T: 'static + AsRawFd + DiskFile + Send> VirtioDevice for Block<T> {
         keep_fds
     }
 
-    fn features(&self, page: u32) -> u32 {
-        match page {
-            0 => self.avail_features as u32,
-            1 => (self.avail_features >> 32) as u32,
-            _ => 0,
-        }
+    fn features(&self) -> u64 {
+        self.avail_features
     }
 
     fn device_type(&self) -> u32 {
@@ -803,7 +799,7 @@ mod tests {
             let b = Block::new(f, false).unwrap();
             // writable device should set VIRTIO_BLK_F_FLUSH + VIRTIO_BLK_F_DISCARD
             // + VIRTIO_BLK_F_WRITE_ZEROES
-            assert_eq!(0x6200, b.features(0));
+            assert_eq!(0x6200, b.features());
         }
 
         // read-only block device
@@ -811,7 +807,7 @@ mod tests {
             let f = File::create(&path).unwrap();
             let b = Block::new(f, true).unwrap();
             // read-only device should set VIRTIO_BLK_F_FLUSH and VIRTIO_BLK_F_RO
-            assert_eq!(0x220, b.features(0));
+            assert_eq!(0x220, b.features());
         }
     }
 }