]> xenbits.xensource.com Git - people/pauldu/demu.git/commitdiff
Fixes for non-power-2 PCI BAR and proper IO range spanning
authorPaul Durrant <paul.durrant@citrix.com>
Mon, 19 May 2014 13:40:21 +0000 (14:40 +0100)
committerPaul Durrant <paul.durrant@citrix.com>
Mon, 19 May 2014 13:40:21 +0000 (14:40 +0100)
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
pci.c
vga.c

diff --git a/pci.c b/pci.c
index 07fba58515cf8f010f54009d400b22d4c1137721..73c3b461a03ec8b6350f8d813570dca26762f294 100644 (file)
--- a/pci.c
+++ b/pci.c
@@ -268,6 +268,12 @@ pci_bar_register(unsigned int index, uint8_t type, uint64_t size,
     uint32_t    mask;
     uint8_t     offset;
 
+    if ((size & (size - 1)) != 0) {
+        int         n = __builtin_clzl(size);
+
+        size = 1ul << (64 - n);
+    }
+
     DBG("%d: %"PRIx64"\n", index, size);
 
     if (index >= PCI_NUM_BAR)
diff --git a/vga.c b/vga.c
index 4f6496b85a826914b2af113926f993e0eead04e8..4b9e0812e2b99525f03686100704350e18a56cc7 100644 (file)
--- a/vga.c
+++ b/vga.c
@@ -1086,11 +1086,11 @@ vga_register(void)
     vga_state.vbe_regs[VBE_DISPI_INDEX_ID] = VBE_DISPI_ID0;
     vga_state.vbe_bank_mask = ((vga_state.vram_size >> 16) - 1);
 
-    rc = demu_register_port_space(0x1ce, 2, &vbe_port_ops, NULL);
+    rc = demu_register_port_space(0x1ce, 4, &vbe_port_ops, NULL);
     if (rc < 0)
         goto fail6;
 
-    rc = demu_register_port_space(0xff80, 2, &vbe_port_ops, NULL);
+    rc = demu_register_port_space(0xff80, 4, &vbe_port_ops, NULL);
     if (rc < 0)
         goto fail7;