[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v3 5/8] vfio/pci: Fixup PCI option ROMs
From: |
Alex Williamson |
Subject: |
[Qemu-devel] [PULL v3 5/8] vfio/pci: Fixup PCI option ROMs |
Date: |
Fri, 11 Mar 2016 09:01:01 -0700 |
User-agent: |
StGit/0.17.1-dirty |
Devices like Intel graphics are known to not only have bad checksums,
but also the wrong device ID. This is not so surprising given that
the video BIOS is typically part of the system firmware image rather
that embedded into the device and needs to support any IGD device
installed into the system.
Signed-off-by: Alex Williamson <address@hidden>
---
hw/vfio/pci.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 82c3771..ebbc9d6 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -832,6 +832,36 @@ static void vfio_pci_load_rom(VFIOPCIDevice *vdev)
break;
}
}
+
+ /*
+ * Test the ROM signature against our device, if the vendor is correct
+ * but the device ID doesn't match, store the correct device ID and
+ * recompute the checksum. Intel IGD devices need this and are known
+ * to have bogus checksums so we can't simply adjust the checksum.
+ */
+ if (pci_get_word(vdev->rom) == 0xaa55 &&
+ pci_get_word(vdev->rom + 0x18) + 8 < vdev->rom_size &&
+ !memcmp(vdev->rom + pci_get_word(vdev->rom + 0x18), "PCIR", 4)) {
+ uint16_t vid, did;
+
+ vid = pci_get_word(vdev->rom + pci_get_word(vdev->rom + 0x18) + 4);
+ did = pci_get_word(vdev->rom + pci_get_word(vdev->rom + 0x18) + 6);
+
+ if (vid == vdev->vendor_id && did != vdev->device_id) {
+ int i;
+ uint8_t csum, *data = vdev->rom;
+
+ pci_set_word(vdev->rom + pci_get_word(vdev->rom + 0x18) + 6,
+ vdev->device_id);
+ data[6] = 0;
+
+ for (csum = 0, i = 0; i < vdev->rom_size; i++) {
+ csum += data[i];
+ }
+
+ data[6] = -csum;
+ }
+ }
}
static uint64_t vfio_rom_read(void *opaque, hwaddr addr, unsigned size)
- [Qemu-devel] [PULL v3 0/8] VFIO updates 2016-03-11, Alex Williamson, 2016/03/11
- [Qemu-devel] [PULL v3 1/8] vfio: Add sysfsdev property for pci & platform, Alex Williamson, 2016/03/11
- [Qemu-devel] [PULL v3 2/8] vfio: Wrap VFIO_DEVICE_GET_REGION_INFO, Alex Williamson, 2016/03/11
- [Qemu-devel] [PULL v3 3/8] vfio: Generalize region support, Alex Williamson, 2016/03/11
- [Qemu-devel] [PULL v3 4/8] vfio/pci: Convert all MemoryRegion to dynamic alloc and consistent functions, Alex Williamson, 2016/03/11
- [Qemu-devel] [PULL v3 5/8] vfio/pci: Fixup PCI option ROMs,
Alex Williamson <=
- [Qemu-devel] [PULL v3 6/8] vfio/pci: Split out VGA setup, Alex Williamson, 2016/03/11
- [Qemu-devel] [PULL v3 7/8] vfio/pci: replace fixed string limit by g_strdup_printf, Alex Williamson, 2016/03/11
- [Qemu-devel] [PULL v3 8/8] MAINTAINERS: Add entry for the include/hw/vfio/ folder, Alex Williamson, 2016/03/11
- Re: [Qemu-devel] [PULL v3 0/8] VFIO updates 2016-03-11, Peter Maydell, 2016/03/14