Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1499696
| From | Eric Auger <eric.auger@redhat.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v14 12/16] vfio/type1: Handle unmap/unpin and replay for VFIO_IOVA_RESERVED slots |
| Date | 2016-10-12 15:40 +0200 |
| Message-ID | <srrVf-52p-9@gated-at.bofh.it> (permalink) |
| References | <srrLz-4Wx-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Before allowing the end-user to create VFIO_IOVA_RESERVED dma slots,
let's implement the expected behavior for removal and replay.
As opposed to user dma slots, reserved IOVAs are not systematically bound
to PAs and PAs are not pinned. VFIO just initializes the IOVA "aperture".
IOVAs are allocated outside of the VFIO framework, by the MSI layer which
is responsible to free and unmap them. The MSI mapping resources are freed
by the IOMMU driver on domain destruction.
On the creation of a new domain, the "replay" of a reserved slot simply
needs to set the MSI aperture on the new domain.
Signed-off-by: Eric Auger <eric.auger@redhat.com>
---
v13 -> v14:
- make iommu_get_dma_msi_region_cookie's failure not passable
- remove useless "select IOMMU_DMA" causing cyclic dependency
- set the MSI region only if needed
v12 -> v13:
- use dma-iommu iommu_get_dma_msi_region_cookie
v9 -> v10:
- replay of a reserved slot sets the MSI aperture on the new domain
- use VFIO_IOVA_RESERVED_MSI enum value instead of VFIO_IOVA_RESERVED
v7 -> v8:
- do no destroy anything anymore, just bypass unmap/unpin and iommu_map
on replay
---
drivers/vfio/vfio_iommu_type1.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
index 1f120f9..2108e2e 100644
--- a/drivers/vfio/vfio_iommu_type1.c
+++ b/drivers/vfio/vfio_iommu_type1.c
@@ -36,6 +36,7 @@
#include <linux/uaccess.h>
#include <linux/vfio.h>
#include <linux/workqueue.h>
+#include <linux/dma-iommu.h>
#define DRIVER_VERSION "0.2"
#define DRIVER_AUTHOR "Alex Williamson <alex.williamson@redhat.com>"
@@ -386,7 +387,7 @@ static void vfio_unmap_unpin(struct vfio_iommu *iommu, struct vfio_dma *dma)
struct vfio_domain *domain, *d;
long unlocked = 0;
- if (!dma->size)
+ if (!dma->size || dma->type != VFIO_IOVA_USER)
return;
/*
* We use the IOMMU to track the physical addresses, otherwise we'd
@@ -717,12 +718,24 @@ static int vfio_iommu_replay(struct vfio_iommu *iommu,
return -EINVAL;
for (; n; n = rb_next(n)) {
+ struct iommu_domain_msi_resv msi_resv;
struct vfio_dma *dma;
dma_addr_t iova;
dma = rb_entry(n, struct vfio_dma, node);
iova = dma->iova;
+ if ((dma->type == VFIO_IOVA_RESERVED_MSI) &&
+ (!iommu_domain_get_attr(domain->domain,
+ DOMAIN_ATTR_MSI_RESV,
+ &msi_resv))) {
+ ret = iommu_get_dma_msi_region_cookie(domain->domain,
+ dma->iova,
+ dma->size);
+ if (ret)
+ return ret;
+ }
+
while (iova < dma->iova + dma->size) {
phys_addr_t phys = iommu_iova_to_phys(d->domain, iova);
size_t size;
--
1.9.1
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v14 00/16] KVM PCIe/MSI passthrough on ARM/ARM64 Eric Auger <eric.auger@redhat.com> - 2016-10-12 15:30 +0200
[PATCH v14 14/16] vfio/type1: Check doorbell safety Eric Auger <eric.auger@redhat.com> - 2016-10-12 15:40 +0200
[PATCH v14 11/16] vfio/type1: Implement recursive vfio_find_dma_from_node Eric Auger <eric.auger@redhat.com> - 2016-10-12 15:40 +0200
[PATCH v14 09/16] vfio: Introduce a vfio_dma type field Eric Auger <eric.auger@redhat.com> - 2016-10-12 15:40 +0200
[PATCH v14 12/16] vfio/type1: Handle unmap/unpin and replay for VFIO_IOVA_RESERVED slots Eric Auger <eric.auger@redhat.com> - 2016-10-12 15:40 +0200
[PATCH v14 13/16] vfio: Allow reserved msi iova registration Eric Auger <eric.auger@redhat.com> - 2016-10-12 15:40 +0200
[PATCH v14 10/16] vfio/type1: vfio_find_dma accepting a type argument Eric Auger <eric.auger@redhat.com> - 2016-10-12 15:40 +0200
[PATCH v14 15/16] iommu/arm-smmu: Do not advertise IOMMU_CAP_INTR_REMAP Eric Auger <eric.auger@redhat.com> - 2016-10-12 15:40 +0200
Re: [PATCH v14 00/16] KVM PCIe/MSI passthrough on ARM/ARM64 Punit Agrawal <punit.agrawal@arm.com> - 2016-10-14 13:30 +0200
Re: [PATCH v14 00/16] KVM PCIe/MSI passthrough on ARM/ARM64 Auger Eric <eric.auger@redhat.com> - 2016-10-17 16:20 +0200
Re: [PATCH v14 00/16] KVM PCIe/MSI passthrough on ARM/ARM64 Punit Agrawal <punit.agrawal@arm.com> - 2016-10-17 17:20 +0200
Re: [PATCH v14 00/16] KVM PCIe/MSI passthrough on ARM/ARM64 Will Deacon <will.deacon@arm.com> - 2016-10-20 19:40 +0200
Re: [PATCH v14 00/16] KVM PCIe/MSI passthrough on ARM/ARM64 Auger Eric <eric.auger@redhat.com> - 2016-10-21 11:30 +0200
Re: [PATCH v14 00/16] KVM PCIe/MSI passthrough on ARM/ARM64 Robin Murphy <robin.murphy@arm.com> - 2016-10-24 21:40 +0200
csiph-web