mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 00:03:54 -06:00
virtio: convert to use DMA api
Currently, all virtio devices bypass IOMMU completely. This is because address_space_memory is assumed and used during DMA emulation. This patch converts the virtio core API to use DMA API. This idea is - introducing a new transport specific helper to query the dma address space. (only pci version is implemented). - query and use this address space during virtio device guest memory accessing when iommu platform (VIRTIO_F_IOMMU_PLATFORM) was enabled for this device. Cc: Michael S. Tsirkin <mst@redhat.com> Cc: Stefan Hajnoczi <stefanha@redhat.com> Cc: Kevin Wolf <kwolf@redhat.com> Cc: Amit Shah <amit.shah@redhat.com> Cc: Paolo Bonzini <pbonzini@redhat.com> Cc: qemu-block@nongnu.org Signed-off-by: Jason Wang <jasowang@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
This commit is contained in:
parent
a08aaff811
commit
8607f5c307
9 changed files with 93 additions and 36 deletions
|
@ -1144,6 +1144,14 @@ static int virtio_pci_query_nvectors(DeviceState *d)
|
|||
return proxy->nvectors;
|
||||
}
|
||||
|
||||
static AddressSpace *virtio_pci_get_dma_as(DeviceState *d)
|
||||
{
|
||||
VirtIOPCIProxy *proxy = VIRTIO_PCI(d);
|
||||
PCIDevice *dev = &proxy->pci_dev;
|
||||
|
||||
return pci_get_address_space(dev);
|
||||
}
|
||||
|
||||
static int virtio_pci_add_mem_cap(VirtIOPCIProxy *proxy,
|
||||
struct virtio_pci_cap *cap)
|
||||
{
|
||||
|
@ -1601,6 +1609,11 @@ static void virtio_pci_device_plugged(DeviceState *d, Error **errp)
|
|||
}
|
||||
|
||||
if (legacy) {
|
||||
if (virtio_host_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM)) {
|
||||
error_setg(errp, "VIRTIO_F_IOMMU_PLATFORM was supported by"
|
||||
"neither legacy nor transitional device.");
|
||||
return ;
|
||||
}
|
||||
/* legacy and transitional */
|
||||
pci_set_word(config + PCI_SUBSYSTEM_VENDOR_ID,
|
||||
pci_get_word(config + PCI_VENDOR_ID));
|
||||
|
@ -2520,6 +2533,7 @@ static void virtio_pci_bus_class_init(ObjectClass *klass, void *data)
|
|||
k->query_nvectors = virtio_pci_query_nvectors;
|
||||
k->ioeventfd_enabled = virtio_pci_ioeventfd_enabled;
|
||||
k->ioeventfd_assign = virtio_pci_ioeventfd_assign;
|
||||
k->get_dma_as = virtio_pci_get_dma_as;
|
||||
}
|
||||
|
||||
static const TypeInfo virtio_pci_bus_info = {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue