From 9fe6b316c9ba13690a8d107a57e4bc2f701fa99e 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 --- tools/kvm/pci.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a/tools/kvm/pci.c b/tools/kvm/pci.c index ff0c09ded72d..b79ac17b32c5 100644 --- a/tools/kvm/pci.c +++ b/tools/kvm/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)) - p = &virtio_device; - else - p = &no_device; + if (pci_device_matches(0, 1, 0)) { + void *p = &virtio_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; } -- 2.39.5