From mboxrd@z Thu Jan 1 00:00:00 1970 From: Thiago Jung Bauermann Subject: [RFC PATCH 06/11] powerpc/svm: Use SWIOTLB DMA API for all virtio devices Date: Fri, 24 Aug 2018 13:25:30 -0300 Message-ID: <20180824162535.22798-7-bauerman@linux.ibm.com> References: <20180824162535.22798-1-bauerman@linux.ibm.com> Return-path: In-Reply-To: <20180824162535.22798-1-bauerman@linux.ibm.com> Sender: linux-kernel-owner@vger.kernel.org To: linuxppc-dev@lists.ozlabs.org Cc: iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Alexey Kardashevskiy , Anshuman Khandual , Benjamin Herrenschmidt , Christoph Hellwig , Michael Ellerman , Mike Anderson , Paul Mackerras , Ram Pai , Anshuman Khandual , Thiago Jung Bauermann List-Id: iommu@lists.linux-foundation.org From: Anshuman Khandual Secure guest memory (GPA range) is isolated and inaccessible from the host. But virtio ring transactions require the back end drivers to process incoming scatter gather buffers which require their access in host. Hence a portion of guest memory can be converted to shared memory and all buffers need to be bounced into the pool before being passed on to the host. SWIOTLB buffers can be pre-allocated and converted as shared memory during early boot. Generic SWIOTLB DMA API (swiotlb_dma_ops) callbacks can be used to bounce each incoming scatter gather I/O buffer addresses into this pool of shared memory before being passed on to the host. All virtio devices on secure guest platform need to use generic SWIOTLB DMA API. Utilize the new virtio core platform hook platform_override_dma_ops() to achieve this. Signed-off-by: Anshuman Khandual Signed-off-by: Thiago Jung Bauermann --- arch/powerpc/platforms/pseries/iommu.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/platforms/pseries/iommu.c b/arch/powerpc/platforms/pseries/iommu.c index 5773bc7eb4bd..56b894d65dba 100644 --- a/arch/powerpc/platforms/pseries/iommu.c +++ b/arch/powerpc/platforms/pseries/iommu.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -51,6 +52,7 @@ #include #include #include +#include #include "pseries.h" @@ -1400,5 +1402,7 @@ machine_subsys_initcall_sync(pseries, tce_iommu_bus_notifier_init); void platform_override_dma_ops(struct virtio_device *vdev) { - /* Override vdev->parent.dma_ops if required */ + if (is_svm_platform() && + !virtio_has_feature(vdev, VIRTIO_F_IOMMU_PLATFORM)) + set_dma_ops(vdev->dev.parent, &swiotlb_dma_ops); }