diff --git a/drivers/gpu/vga/vgaarb.c b/drivers/gpu/vga/vgaarb.c index ace2b16..d488426 100644 --- a/drivers/gpu/vga/vgaarb.c +++ b/drivers/gpu/vga/vgaarb.c @@ -421,6 +421,50 @@ bail: } EXPORT_SYMBOL(vga_put); +#ifdef CONFIG_XEN +#include +#include +#include +#include +#include + +#define IO_BITMAP_BITS 65536 +#define IO_BITMAP_BYTES (IO_BITMAP_BITS/8) + +#define VGA_START_PORT 0x3B0 +#define VGA_END_PORT 0x3DF + +static void +vga_ioport_map(struct pci_dev *pdev) +{ + unsigned int i, j; + struct physdev_set_iobitmap op; + uint8_t *bitmap; + + bitmap = kmalloc(IO_BITMAP_BYTES, GFP_KERNEL); + memset(bitmap, 0xff, IO_BITMAP_BYTES); + + /* PCI io bars */ + for (i = 0; i < PCI_NUM_RESOURCES; i++) + if (pci_resource_flags(pdev, i) & IORESOURCE_IO) + for (j = pci_resource_start(pdev, i); + j <= pci_resource_end(pdev, i); j++) + __clear_bit(j, (unsigned long*)bitmap); + + /* legacy vga */ + for (i = VGA_START_PORT; i <= VGA_END_PORT; i++) + __clear_bit(i, (unsigned long*)bitmap); + + op.bitmap = bitmap; + op.nr_ports = IO_BITMAP_BITS; + if(HYPERVISOR_physdev_op(PHYSDEVOP_set_iobitmap, &op) != 0) + pr_info("PHYSDEVOP_set_iobitmap failed\n"); + +} +#else +#define vga_ioport_map(x) +#endif + /* * Currently, we assume that the "initial" setup of the system is * not sane, that is we come up with conflicting devices and let @@ -509,6 +553,7 @@ static bool vga_arbiter_add_pci_device(struct pci_dev *pdev) vga_iostate_to_str(vgadev->owns), vga_iostate_to_str(vgadev->locks)); + vga_ioport_map(pdev); spin_unlock_irqrestore(&vga_lock, flags); return true; fail: