[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-arm] [RFC 4/7] hw: vfio: common: introduce vfio_register_reserved_
From: |
Eric Auger |
Subject: |
[Qemu-arm] [RFC 4/7] hw: vfio: common: introduce vfio_register_reserved_iova |
Date: |
Wed, 27 Jan 2016 13:51:52 +0000 |
vfio_register_reserved_iova allows to register the reserved IOVA region,
typically for MSI frame binding purpose. The kernel allows registering
a single reserved IOVA region.
Unregistration is handled through legacy vfio_dma_unmap.
The function will become static in subsequent patches. However, since
there is no user yet, the compiler argues; the function is currently
not static and a dummy declaration needs to be added.
Signed-off-by: Eric Auger <address@hidden>
---
hw/vfio/common.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 6797208..247c87b 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -208,6 +208,36 @@ static int vfio_dma_unmap(VFIOContainer *container,
return 0;
}
+/**
+ * vfio_register_reserved_iova: registers the iova reserved region
+ *
+ * @container: container handle
+ * @iova: base iova of the reserved region
+ * @size: reserved region size
+ *
+ * unregistration is handled using vfio_dma_unmap
+ */
+int vfio_register_reserved_iova(VFIOContainer *container, hwaddr iova,
+ ram_addr_t size);
+int vfio_register_reserved_iova(VFIOContainer *container, hwaddr iova,
+ ram_addr_t size)
+{
+ struct vfio_iommu_type1_dma_map map = {
+ .argsz = sizeof(map),
+ .flags = VFIO_DMA_MAP_FLAG_MSI_RESERVED_IOVA,
+ .iova = iova,
+ .size = size,
+ };
+
+ if (ioctl(container->fd, VFIO_IOMMU_MAP_DMA, &map) == 0) {
+ return 0;
+ }
+
+ error_report("VFIO_MAP_DMA/MSI_RESERVED_IOVA: %d", -errno);
+ return -errno;
+
+}
+
static int vfio_dma_map(VFIOContainer *container, hwaddr iova,
ram_addr_t size, void *vaddr, bool readonly)
{
--
1.9.1
- [Qemu-arm] [RFC 0/7] KVM PCI/MSI passthrough with mach-virt, Eric Auger, 2016/01/27
- [Qemu-arm] [RFC 1/7] linux-headers: partial update for VFIO reserved IOVA registration, Eric Auger, 2016/01/27
- [Qemu-arm] [RFC 2/7] Add a function to determine interrupt number for INTx routing, Eric Auger, 2016/01/27
- [Qemu-arm] [RFC 3/7] Generic PCIe host bridge INTx determination for INTx routing, Eric Auger, 2016/01/27
- [Qemu-arm] [RFC 4/7] hw: vfio: common: introduce vfio_register_reserved_iova,
Eric Auger <=
- [Qemu-arm] [RFC 5/7] memory: add reserved_iova region type, Eric Auger, 2016/01/27
- [Qemu-arm] [RFC 6/7] hw: arm: virt: register reserved IOVA region, Eric Auger, 2016/01/27
- [Qemu-arm] [RFC 7/7] hw: vfio: common: adapt vfio_listeners for reserved_iova region, Eric Auger, 2016/01/27