From: Pekka Enberg Date: Sat, 31 Jul 2010 19:51:07 +0000 (+0300) Subject: kvm, pci: Fix device probe accesses X-Git-Tag: next-20110824~3^2~528^2~69 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=9fe6b316c9ba13690a8d107a57e4bc2f701fa99e;p=karo-tx-linux.git kvm, pci: Fix device probe accesses The register number is offset in bytes, not in words. Signed-off-by: Pekka Enberg --- 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; }