summary refs log tree commit diff
path: root/devices/src/virtio/virtio_pci_device.rs
diff options
context:
space:
mode:
authorDaniel Verkamp <dverkamp@chromium.org>2019-10-24 16:27:12 -0700
committerCommit Bot <commit-bot@chromium.org>2019-11-17 22:34:22 +0000
commit8ec87d6d334126f0a3c235e19470f707dc5f02e4 (patch)
treea21298cc9d74cccf9dd223984a53b85e9dc5524a /devices/src/virtio/virtio_pci_device.rs
parent8958407dcb3ba19cddf65579932ccad3d99bb9d5 (diff)
downloadcrosvm-8ec87d6d334126f0a3c235e19470f707dc5f02e4.tar
crosvm-8ec87d6d334126f0a3c235e19470f707dc5f02e4.tar.gz
crosvm-8ec87d6d334126f0a3c235e19470f707dc5f02e4.tar.bz2
crosvm-8ec87d6d334126f0a3c235e19470f707dc5f02e4.tar.lz
crosvm-8ec87d6d334126f0a3c235e19470f707dc5f02e4.tar.xz
crosvm-8ec87d6d334126f0a3c235e19470f707dc5f02e4.tar.zst
crosvm-8ec87d6d334126f0a3c235e19470f707dc5f02e4.zip
devices: pci: make get_bar_addr work for all BAR types
Previously, PciConfiguration::get_bar_addr would only correctly return
the value of a 32-bit memory region; implement support for the other
valid BAR types as well.

BUG=None
TEST=cargo test -p devices

Change-Id: I221187dfb96b31d7fead73eccf605a0886021d8b
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1880164
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Diffstat (limited to 'devices/src/virtio/virtio_pci_device.rs')
-rw-r--r--devices/src/virtio/virtio_pci_device.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/devices/src/virtio/virtio_pci_device.rs b/devices/src/virtio/virtio_pci_device.rs
index cbe56a2..43b3a74 100644
--- a/devices/src/virtio/virtio_pci_device.rs
+++ b/devices/src/virtio/virtio_pci_device.rs
@@ -458,7 +458,7 @@ impl PciDevice for VirtioPciDevice {
     }
 
     fn ioeventfds(&self) -> Vec<(&EventFd, u64, Datamatch)> {
-        let bar0 = self.config_regs.get_bar_addr(self.settings_bar as usize) as u64;
+        let bar0 = self.config_regs.get_bar_addr(self.settings_bar as usize);
         let notify_base = bar0 + NOTIFICATION_BAR_OFFSET;
         self.queue_evts()
             .iter()
@@ -504,7 +504,7 @@ impl PciDevice for VirtioPciDevice {
     #[allow(clippy::absurd_extreme_comparisons)]
     fn read_bar(&mut self, addr: u64, data: &mut [u8]) {
         // The driver is only allowed to do aligned, properly sized access.
-        let bar0 = self.config_regs.get_bar_addr(self.settings_bar as usize) as u64;
+        let bar0 = self.config_regs.get_bar_addr(self.settings_bar as usize);
         let offset = addr - bar0;
         match offset {
             o if COMMON_CONFIG_BAR_OFFSET <= o
@@ -556,7 +556,7 @@ impl PciDevice for VirtioPciDevice {
 
     #[allow(clippy::absurd_extreme_comparisons)]
     fn write_bar(&mut self, addr: u64, data: &[u8]) {
-        let bar0 = self.config_regs.get_bar_addr(self.settings_bar as usize) as u64;
+        let bar0 = self.config_regs.get_bar_addr(self.settings_bar as usize);
         let offset = addr - bar0;
         match offset {
             o if COMMON_CONFIG_BAR_OFFSET <= o