From e498ea085fb4a22b9a2211b03e20721d117288eb Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Sat, 31 Jul 2010 22:51:07 +0300 Subject: [PATCH] kvm, pci: Fix device probe accesses The register number is offset in bytes, not in words. Signed-off-by: Pekka Enberg --- pci.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/pci.c b/pci.c index ff0c09d..b79ac17 100644 --- a/pci.c +++ b/pci.c @@ -34,13 +34,6 @@ static bool pci_config_data_out(struct kvm *self, uint16_t port, void *data, int return true; } -static struct pci_device_header no_device = { - .vendor_id = 0xffff, - .device_id = 0xffff, - .revision_id = 0xff, - .class = 0xffffff, -}; - #define PCI_VENDOR_ID_REDHAT_QUMRANET 0x1af4 #define PCI_DEVICE_ID_VIRTIO_BLK 0x1001 @@ -63,14 +56,12 @@ static bool pci_device_matches(uint8_t bus_number, uint8_t device_number, uint8_ static bool pci_config_data_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) { - void *p; + if (pci_device_matches(0, 1, 0)) { + void *p = &virtio_device; - if (pci_device_matches(0, 1, 0)) - p = &virtio_device; - else - p = &no_device; - - memcpy(data, p + (pci_config_address.register_number * 4), size); + memcpy(data, p + pci_config_address.register_number, size); + } else + memset(data, 0xff, size); return true; }