summaryrefslogtreecommitdiff
path: root/src/dev/virtio/pci.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/dev/virtio/pci.cc')
-rw-r--r--src/dev/virtio/pci.cc10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/dev/virtio/pci.cc b/src/dev/virtio/pci.cc
index d8ec4f5f8..783b43e65 100644
--- a/src/dev/virtio/pci.cc
+++ b/src/dev/virtio/pci.cc
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014 ARM Limited
+ * Copyright (c) 2014, 2017 ARM Limited
* All rights reserved
*
* The license below extends only to copyright in the software and shall
@@ -39,6 +39,7 @@
#include "dev/virtio/pci.hh"
+#include "base/bitfield.hh"
#include "debug/VIOIface.hh"
#include "mem/packet_access.hh"
#include "params/PciVirtIO.hh"
@@ -49,7 +50,12 @@ PciVirtIO::PciVirtIO(const Params *params)
{
// Override the subsystem ID with the device ID from VirtIO
config.subsystemID = htole(vio.deviceId);
- BARSize[0] = BAR0_SIZE_BASE + vio.configSize;
+
+ // The kernel driver expects the BAR size to be an exact power of
+ // two. Nothing else is supported. Therefore, we need to force
+ // that alignment here. We do not touch vio.configSize as this is
+ // used to check accesses later on.
+ BARSize[0] = alignToPowerOfTwo(BAR0_SIZE_BASE + vio.configSize);
vio.registerKickCallback(&callbackKick);
}