mirror of
https://github.com/clearlinux/kvmtool.git
synced 2026-09-06 05:31:50 +00:00
kvm: Fix unaligned PCI_CONFIG_ADDRESS accesses
This patch fixes unaligned PCI_CONFIG_ADDRESS accesses to use the same mechanism as with PCI_CONFIG_DATA. Signed-off-by: Pekka Enberg <penberg@kernel.org>
This commit is contained in:
committed by
Will Deacon
parent
2065a6f762
commit
ba8246776e
@@ -6,20 +6,31 @@
|
||||
|
||||
static struct pci_config_address pci_config_address;
|
||||
|
||||
static void *pci_config_address_ptr(uint16_t port)
|
||||
{
|
||||
unsigned long offset;
|
||||
void *base;
|
||||
|
||||
offset = port - PCI_CONFIG_ADDRESS;
|
||||
base = &pci_config_address;
|
||||
|
||||
return base + offset;
|
||||
}
|
||||
|
||||
static bool pci_config_address_out(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
|
||||
{
|
||||
struct pci_config_address *addr = data;
|
||||
void *p = pci_config_address_ptr(port);
|
||||
|
||||
pci_config_address = *addr;
|
||||
memcpy(p, data, size);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool pci_config_address_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count)
|
||||
{
|
||||
struct pci_config_address *addr = data;
|
||||
void *p = pci_config_address_ptr(port);
|
||||
|
||||
*addr = pci_config_address;
|
||||
memcpy(data, p, size);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -108,13 +119,15 @@ static struct ioport_operations virtio_io_ops = {
|
||||
|
||||
void pci__init(void)
|
||||
{
|
||||
ioport__register(IOPORT_VIRTIO, &virtio_io_ops);
|
||||
|
||||
ioport__register(IOPORT_VIRTIO, &virtio_io_ops);
|
||||
ioport__register(PCI_CONFIG_DATA + 0, &pci_config_data_ops);
|
||||
ioport__register(PCI_CONFIG_DATA + 1, &pci_config_data_ops);
|
||||
ioport__register(PCI_CONFIG_DATA + 2, &pci_config_data_ops);
|
||||
ioport__register(PCI_CONFIG_DATA + 3, &pci_config_data_ops);
|
||||
|
||||
ioport__register(PCI_CONFIG_DATA + 0, &pci_config_data_ops);
|
||||
ioport__register(PCI_CONFIG_DATA + 1, &pci_config_data_ops);
|
||||
ioport__register(PCI_CONFIG_DATA + 2, &pci_config_data_ops);
|
||||
ioport__register(PCI_CONFIG_DATA + 3, &pci_config_data_ops);
|
||||
|
||||
ioport__register(PCI_CONFIG_ADDRESS, &pci_config_address_ops);
|
||||
ioport__register(PCI_CONFIG_ADDRESS + 0, &pci_config_address_ops);
|
||||
ioport__register(PCI_CONFIG_ADDRESS + 1, &pci_config_address_ops);
|
||||
ioport__register(PCI_CONFIG_ADDRESS + 2, &pci_config_address_ops);
|
||||
ioport__register(PCI_CONFIG_ADDRESS + 3, &pci_config_address_ops);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user