Supporting more accesses sizes actually makes the case slightly simpler,
thanks to mmio_perform_access. Moreover, this will help introducing PCI
support on ARM where accesses of less than 4 bytes take place.

Signed-off-by: Jan Kiszka <[email protected]>
---
 hypervisor/pci.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/hypervisor/pci.c b/hypervisor/pci.c
index 3806073..d92ce3b 100644
--- a/hypervisor/pci.c
+++ b/hypervisor/pci.c
@@ -1,7 +1,7 @@
 /*
  * Jailhouse, a Linux-based partitioning hypervisor
  *
- * Copyright (c) Siemens AG, 2014, 2015
+ * Copyright (c) Siemens AG, 2014-2016
  *
  * Authors:
  *  Ivan Kolchin <[email protected]>
@@ -421,37 +421,37 @@ static enum mmio_result pci_mmconfig_access_handler(void 
*arg,
                                                    struct mmio_access *mmio)
 {
        u32 reg_addr = mmio->address & 0xfff;
+       u16 bdf = mmio->address >> 12;
        struct pci_device *device;
        enum pci_access result;
        u32 val;
 
-       /* access must be DWORD-aligned */
-       if (reg_addr & 0x3)
+       /* only up to 4-byte accesses supported */
+       if (mmio->size > 4)
                goto invalid_access;
 
-       device = pci_get_assigned_device(this_cell(), mmio->address >> 12);
+       device = pci_get_assigned_device(this_cell(), bdf);
 
        if (mmio->is_write) {
-               result = pci_cfg_write_moderate(device, reg_addr, 4,
+               result = pci_cfg_write_moderate(device, reg_addr, mmio->size,
                                                mmio->value);
                if (result == PCI_ACCESS_REJECT)
                        goto invalid_access;
-               if (result == PCI_ACCESS_PERFORM)
-                       mmio_write32(pci_space + mmio->address, mmio->value);
        } else {
-               result = pci_cfg_read_moderate(device, reg_addr, 4, &val);
-               if (result == PCI_ACCESS_PERFORM)
-                       mmio->value = mmio_read32(pci_space + mmio->address);
-               else
+               result = pci_cfg_read_moderate(device, reg_addr, mmio->size,
+                                              &val);
+               if (result != PCI_ACCESS_PERFORM)
                        mmio->value = val;
        }
+       if (result == PCI_ACCESS_PERFORM)
+               mmio_perform_access(pci_space, mmio);
 
        return MMIO_HANDLED;
 
 invalid_access:
        panic_printk("FATAL: Invalid PCI MMCONFIG write, device %02x:%02x.%x, "
-                    "reg: %x\n", PCI_BDF_PARAMS((u32)mmio->address >> 12),
-                    reg_addr);
+                    "reg: %x, size: %d\n", PCI_BDF_PARAMS(bdf), reg_addr,
+                    mmio->size);
        return MMIO_ERROR;
 
 }
-- 
2.1.4

-- 
You received this message because you are subscribed to the Google Groups 
"Jailhouse" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to