mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-09-04 12:41:37 +00:00
kvm, pci: Fix device probe accesses
The register number is offset in bytes, not in words. Signed-off-by: Pekka Enberg <penberg@cs.helsinki.fi>
This commit is contained in:
committed by
Will Deacon
parent
76f9c84103
commit
e498ea085f
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user