s390x/pci: fix up IOMMU size
commitf0a399dbae6a2d0e2e15eb7ce0783286bbd9fe04
authorYi Min Zhao <zyimin@linux.vnet.ibm.com>
Wed, 4 Nov 2015 07:50:45 +0000 (4 15:50 +0800)
committerCornelia Huck <cornelia.huck@de.ibm.com>
Tue, 1 Dec 2015 08:57:28 +0000 (1 09:57 +0100)
tree4d1e64b3c672cba3f8b3fddb2a07515d33287f71
parent567c88c354904d669dfac6170b8ac5f60b41d9bd
s390x/pci: fix up IOMMU size

Present code uses @size==UINT64_MAX to initialize IOMMU. It infers that it
can map any 64-bit IOVA whatsoever. But in fact, the largest DMA range for
each PCI Device on s390x is from ZPCI_SDMA_ADDR to ZPCI_EDMA_ADDR. The largest
value is returned from hardware, which is to indicate the largest range
hardware can support. But the real IOMMU size for specific PCI Device is
obtained once qemu intercepts mpcifc instruction that guest is requesting a
DMA range for that PCI Device. Therefore, before intercepting mpcifc instruction,
qemu cannot be aware of the size of IOMMU region that guest will use.

Moreover, iommu replay during device initialization for the whole region in
4k steps takes a very long time.

In conclusion, this patch intializes IOMMU region for each PCI Device when
intercept mpcifc instruction which is to register DMA range for the PCI Device.
And then, destroy IOMMU region when guest wants to deregister IOAT.

Signed-off-by: Yi Min Zhao <zyimin@linux.vnet.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Signed-off-by: Cornelia Huck <cornelia.huck@de.ibm.com>
hw/s390x/s390-pci-bus.c
hw/s390x/s390-pci-bus.h
hw/s390x/s390-pci-inst.c