[PATCH v2 6/6] dmaengine: pl330: Make sure microcode is privileged-executable

2016-07-08 Thread Mitchel Humpherys
The PL330 can perform privileged instruction fetches. This can result in SMMU permission faults on SMMUs that implement the ARMv8 VMSA, which specifies that mappings that are writeable at one execution level shall not be executable at any higher-privileged level. Fix this by using the

[PATCH v2 4/6] common: DMA-mapping: add DMA_ATTR_PRIVILEGED_EXECUTABLE attribute

2016-07-08 Thread Mitchel Humpherys
This patch adds the DMA_ATTR_PRIVILEGED_EXECUTABLE attribute to the DMA-mapping subsystem. Some architectures require that writable mappings also be non-executable at lesser-privileged levels of execution. This attribute is used to indicate to the DMA-mapping subsystem that it should do whatever

[PATCH v2 3/6] Revert "iommu/arm-smmu: Treat all device transactions as unprivileged"

2016-07-08 Thread Mitchel Humpherys
This reverts commit d346180e70b9 ("iommu/arm-smmu: Treat all device transactions as unprivileged") since some platforms actually make use of privileged transactions. Signed-off-by: Mitchel Humpherys --- drivers/iommu/arm-smmu.c | 5 + 1 file changed, 1 insertion(+),

[PATCH v2 5/6] arm64/dma-mapping: Implement DMA_ATTR_PRIVILEGED_EXECUTABLE

2016-07-08 Thread Mitchel Humpherys
The newly added DMA_ATTR_PRIVILEGED_EXECUTABLE is useful for creating mappings that are executable by privileged DMA engines. Implement it in dma-iommu.c so that the ARM64 DMA IOMMU mapper can make use of it. Signed-off-by: Mitchel Humpherys ---

[PATCH v2 1/6] iommu: add IOMMU_PRIV attribute

2016-07-08 Thread Mitchel Humpherys
Add the IOMMU_PRIV attribute, which is used to indicate privileged mappings. Signed-off-by: Mitchel Humpherys --- include/linux/iommu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 664683aedcce..01c9f2667f2b

[PATCH v2 0/6] Add support for privileged mappings

2016-07-08 Thread Mitchel Humpherys
The following patch to the ARM SMMU driver: commit d346180e70b91b3d5a1ae7e5603e65593d4622bc Author: Robin Murphy Date: Tue Jan 26 18:06:34 2016 + iommu/arm-smmu: Treat all device transactions as unprivileged started forcing all SMMU

Re: [PATCH 0/3] Add support for privileged mappings

2016-07-08 Thread Mitchel Humpherys
On Thu, Jul 07 2016 at 02:58:21 PM, Jordan Crouse wrote: >> Whilst this series is a step in the right direction for fixing that, I >> don't think you can claim that only low-level users need this, given that >> we have in-tree code which would break without it. Perhaps

[PATCH v2 2/6] iommu/io-pgtable-arm: add support for the IOMMU_PRIV flag

2016-07-08 Thread Mitchel Humpherys
From: Jeremy Gebben Allow the creation of privileged mode mappings, for stage 1 only. Signed-off-by: Jeremy Gebben --- drivers/iommu/io-pgtable-arm.c | 16 +++- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git

Re: [PATCH v4 1/8] arm64: mm: change IOMMU notifier action to attach DMA ops

2016-07-08 Thread Catalin Marinas
On Fri, Jul 08, 2016 at 03:55:21PM +0100, Will Deacon wrote: > On Fri, Jul 01, 2016 at 05:50:10PM +0100, Robin Murphy wrote: > > From: Lorenzo Pieralisi > > > > Current bus notifier in ARM64 (__iommu_attach_notifier) > > attempts to attach dma_ops to a device on

[GIT PULL] iommu/arm-smmu: Updates for 4.8

2016-07-08 Thread Will Deacon
Hi Joerg, Please pull these arm-smmu updates for 4.8. There's really not a lot here, but the highlight is the fix to iova_to_phys which really improves our VFIO teardown performance, where we previously did everything on a page-by-page basis. Whilst Robin had an SMMUv3 series in good shape for

Re: [PATCH v4 1/8] arm64: mm: change IOMMU notifier action to attach DMA ops

2016-07-08 Thread Will Deacon
Hi Catalin, On Fri, Jul 01, 2016 at 05:50:10PM +0100, Robin Murphy wrote: > From: Lorenzo Pieralisi > > Current bus notifier in ARM64 (__iommu_attach_notifier) > attempts to attach dma_ops to a device on BUS_NOTIFY_ADD_DEVICE > action notification. > > This will

[git pull] IOMMU Fixes for Linux v4.7-rc6

2016-07-08 Thread Joerg Roedel
Hi Linus, The following changes since commit a99cde438de0c4c0cecc1d1af1a55a75b10bfdef: Linux 4.7-rc6 (2016-07-03 23:01:00 -0700) are available in the git repository at: git://git.kernel.org/pub/scm/linux/kernel/git/joro/iommu.git tags/iommu-fixes-v4.7-rc6 for you to fetch changes up to

[PATCH 16/20] iommu/amd: Optimize map_sg and unmap_sg

2016-07-08 Thread Joerg Roedel
From: Joerg Roedel Optimize these functions so that they need only one call into the address alloctor. This also saves a couple of io-tlb flushes in the unmap_sg path. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 77

[PATCH 19/20] iommu/amd: Flush iova queue before releasing dma_ops_domain

2016-07-08 Thread Joerg Roedel
From: Joerg Roedel Before a dma_ops_domain can be freed, we need to make sure it is not longer referenced by the flush queue. So empty the queue before a dma_ops_domain can be freed. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 17

[PATCH 18/20] iommu/amd: Handle IOMMU_DOMAIN_DMA in ops->domain_free call-back

2016-07-08 Thread Joerg Roedel
From: Joerg Roedel This domain type is not yet handled in the iommu_ops->domain_free() call-back. Fix that. Fixes: 0bb6e243d7fb ('iommu/amd: Support IOMMU_DOMAIN_DMA type allocation') Cc: sta...@vger.kernel.org # v4.2+ Signed-off-by: Joerg Roedel ---

[PATCH 09/20] iommu/amd: Remove other remains of old address allocator

2016-07-08 Thread Joerg Roedel
From: Joerg Roedel There are other remains in the code from the old allocatore. Remove them all. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 305 +- 1 file changed, 5 insertions(+), 300 deletions(-)

[PATCH 12/20] iommu/amd: Allow NULL pointer parameter for domain_flush_complete()

2016-07-08 Thread Joerg Roedel
From: Joerg Roedel If domain == NULL is passed to the function, it will queue a completion-wait command on all IOMMUs in the system. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git

[PATCH 13/20] iommu/amd: Implement flush queue

2016-07-08 Thread Joerg Roedel
From: Joerg Roedel With the flush queue the IOMMU TLBs will not be flushed at every dma-ops unmap operation. The unmapped ranges will be queued and flushed at once, when the queue is full. This makes unmapping operations a lot faster (on average) and restores the performance of

[PATCH 17/20] iommu/amd: Use dev_data->domain in get_domain()

2016-07-08 Thread Joerg Roedel
From: Joerg Roedel Using the cached value is much more efficient than calling into the IOMMU core code. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 7 +-- 1 file changed, 1 insertion(+), 6 deletions(-) diff --git

[PATCH 11/20] iommu/amd: Set up data structures for flush queue

2016-07-08 Thread Joerg Roedel
From: Joerg Roedel The flush queue is the equivalent to defered-flushing in the Intel VT-d driver. This patch sets up the data structures needed for this. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 40 +++-

[PATCH 06/20] iommu/amd: Pass gfp-flags to iommu_map_page()

2016-07-08 Thread Joerg Roedel
From: Joerg Roedel Make this function ready to be used in the DMA-API path. Reorder parameters a bit while at it. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 7 --- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git

[PATCH 14/20] iommu/amd: Implement timeout to flush unmap queues

2016-07-08 Thread Joerg Roedel
From: Joerg Roedel In case the queue doesn't fill up, we flush the TLB at least 10ms after the unmap happened to make sure that the TLB is cleaned up. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 28 1 file changed,

[PATCH 15/20] iommu/amd: Introduce dir2prot() helper

2016-07-08 Thread Joerg Roedel
From: Joerg Roedel This function converts dma_data_direction to iommu-protection flags. This will be needed on multiple places in the code, so this will save some code. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 20 +--- 1

[PATCH 10/20] iommu/amd: Remove align-parameter from __map_single()

2016-07-08 Thread Joerg Roedel
From: Joerg Roedel This parameter is not required anymore because the iova-allocations are always aligned to its size. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 13 +++-- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git

[PATCH 00/20] iommu/amd: Use generic IOVA allocator

2016-07-08 Thread Joerg Roedel
Hi, here is a patch-set to make the AMD IOMMU driver use the generic IOVA allocator, which is already used in the Intel VT-d driver and a few other places. The main reason for the conversion is to make the driver benefit from the recent scalability improvements to the IOVA code. Some of these

[PATCH 04/20] iommu/amd: Create a list of reserved iova addresses

2016-07-08 Thread Joerg Roedel
From: Joerg Roedel Put the MSI-range, the HT-range and the MMIO ranges of PCI devices into that range, so that these addresses are not allocated for DMA. Copy this address list into every created dma_ops_domain. Signed-off-by: Joerg Roedel ---

[PATCH 08/20] iommu/amd: Make use of the generic IOVA allocator

2016-07-08 Thread Joerg Roedel
From: Joerg Roedel Remove the old address allocation code and make use of the generic IOVA allocator that is also used by other dma-ops implementations. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 183

[PATCH 01/20] iommu: Add apply_dm_region call-back to iommu-ops

2016-07-08 Thread Joerg Roedel
From: Joerg Roedel This new call-back will be used by the iommu driver to do reserve the given dm_region in its iova space before the mapping is created. The call-back is temporary until the dma-ops implementation is part of the common iommu code. Signed-off-by: Joerg Roedel

[PATCH 03/20] iommu/amd: Allocate iova_domain for dma_ops_domain

2016-07-08 Thread Joerg Roedel
From: Joerg Roedel Use it later for allocating the IO virtual addresses. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 20 +++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/amd_iommu.c

[PATCH 05/20] iommu/amd: Implement apply_dm_region call-back

2016-07-08 Thread Joerg Roedel
From: Joerg Roedel It is used to reserve the dm-regions in the iova-tree. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c

[PATCH 02/20] iommu/amd: Select IOMMU_IOVA for AMD IOMMU

2016-07-08 Thread Joerg Roedel
From: Joerg Roedel Include the generic IOVA code to make use of it in the AMD IOMMU driver too. Signed-off-by: Joerg Roedel --- drivers/iommu/Kconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/iommu/Kconfig b/drivers/iommu/Kconfig index