summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Verkamp <dverkamp@chromium.org>2019-11-15 11:25:09 -0800
committerCommit Bot <commit-bot@chromium.org>2020-01-23 20:11:06 +0000
commite43d300aef5fa4cc6eaf8539580acce1e2990a98 (patch)
tree387312e1e39a916746b5f2c48b4f570948ad203e
parent42bff13009bfa0361ad1572997aba5f457cf38f3 (diff)
downloadcrosvm-e43d300aef5fa4cc6eaf8539580acce1e2990a98.tar
crosvm-e43d300aef5fa4cc6eaf8539580acce1e2990a98.tar.gz
crosvm-e43d300aef5fa4cc6eaf8539580acce1e2990a98.tar.bz2
crosvm-e43d300aef5fa4cc6eaf8539580acce1e2990a98.tar.lz
crosvm-e43d300aef5fa4cc6eaf8539580acce1e2990a98.tar.xz
crosvm-e43d300aef5fa4cc6eaf8539580acce1e2990a98.tar.zst
crosvm-e43d300aef5fa4cc6eaf8539580acce1e2990a98.zip
devices: xhci: use get_bar_addr() to find BAR 0
Don't store the BAR value, as it can potentially be updated by the
guest. (This is not supported by our PCI device model just yet, but this
is still the correct thing to do and matches other crosvm PCI devices.)

BUG=None
TEST=Add USB device on nami

Change-Id: Ie42d08429e7ff124178c818877b4cee83003d66f
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1924782
Reviewed-by: Zach Reizner <zachr@chromium.org>
-rw-r--r--devices/src/usb/xhci/xhci_controller.rs7
1 files changed, 2 insertions, 5 deletions
diff --git a/devices/src/usb/xhci/xhci_controller.rs b/devices/src/usb/xhci/xhci_controller.rs
index db06b6e..b77a73a 100644
--- a/devices/src/usb/xhci/xhci_controller.rs
+++ b/devices/src/usb/xhci/xhci_controller.rs
@@ -96,7 +96,6 @@ pub struct XhciController {
     config_regs: PciConfiguration,
     pci_bus_dev: Option<(u8, u8)>,
     mem: GuestMemory,
-    bar0: u64, // bar0 in config_regs will be changed by guest. Not sure why.
     state: XhciControllerState,
 }
 
@@ -117,7 +116,6 @@ impl XhciController {
             config_regs,
             pci_bus_dev: None,
             mem,
-            bar0: 0,
             state: XhciControllerState::Created {
                 device_provider: usb_provider,
             },
@@ -228,7 +226,6 @@ impl PciDevice for XhciController {
         self.config_regs
             .add_pci_bar(&bar0_config)
             .map_err(|e| PciDeviceError::IoRegistrationFailed(bar0_addr, e))?;
-        self.bar0 = bar0_addr;
         Ok(vec![(bar0_addr, XHCI_BAR0_SIZE)])
     }
 
@@ -241,7 +238,7 @@ impl PciDevice for XhciController {
     }
 
     fn read_bar(&mut self, addr: u64, data: &mut [u8]) {
-        let bar0 = self.bar0;
+        let bar0 = self.config_regs.get_bar_addr(0);
         if addr < bar0 || addr > bar0 + XHCI_BAR0_SIZE {
             return;
         }
@@ -257,7 +254,7 @@ impl PciDevice for XhciController {
     }
 
     fn write_bar(&mut self, addr: u64, data: &[u8]) {
-        let bar0 = self.bar0;
+        let bar0 = self.config_regs.get_bar_addr(0);
         if addr < bar0 || addr > bar0 + XHCI_BAR0_SIZE {
             return;
         }