[PATCH v2 4/4] arm64: dts: marvell: armada-ap806: add smmu support

2019-07-11 Thread Gregory CLEMENT
Add IOMMU node for Marvell AP806 based SoCs. Signed-off-by: Gregory CLEMENT --- arch/arm64/boot/dts/marvell/armada-ap806.dtsi | 17 + 1 file changed, 17 insertions(+) diff --git a/arch/arm64/boot/dts/marvell/armada-ap806.dtsi b/arch/arm64/boot/dts/marvell/armada-ap806.dtsi

Re: [PATCH] kernel/dma: export dma_alloc_from_contiguous to modules

2019-07-11 Thread Robin Murphy
On 11/07/2019 06:33, miles.c...@mediatek.com wrote: From: Miles Chen This change exports dma_alloc_from_contiguous and dma_release_from_contiguous to modules. Currently, we can add a reserve a memory node in dts files, make it a CMA memory by setting compatible = "shared-dma-pool", and setup

Re: [PATCH v8 07/21] iommu/io-pgtable-arm-v7s: Extend MediaTek 4GB Mode

2019-07-11 Thread Will Deacon
On Thu, Jul 11, 2019 at 07:53:56PM +0800, Yong Wu wrote: > On Wed, 2019-07-10 at 15:36 +0100, Will Deacon wrote: > > On Sat, Jun 29, 2019 at 10:09:13AM +0800, Yong Wu wrote: > > > MediaTek extend the arm v7s descriptor to support the dram over 4GB. > > > > > > In the mt2712 and mt8173, it's

[PATCH v9 01/11] vfio: VFIO_IOMMU_SET_PASID_TABLE

2019-07-11 Thread Eric Auger
From: "Liu, Yi L" This patch adds an VFIO_IOMMU_SET_PASID_TABLE ioctl which aims to pass the virtual iommu guest configuration to the host. This latter takes the form of the so-called PASID table. Signed-off-by: Jacob Pan Signed-off-by: Liu, Yi L Signed-off-by: Eric Auger --- v8 -> v9: -

[GIT PULL] dma-mapping updates for 5.3

2019-07-11 Thread Christoph Hellwig
Hi Linus, please pull the dma-mapping update below. Note that the tree is based on an branch from Joergs iommu tree that you have pulled earlier this week. There are a few of the usual Kconfig conflicts where different trees touch the same area, but not the same symbols, just take the changes

[PATCH v9 00/11] SMMUv3 Nested Stage Setup (VFIO part)

2019-07-11 Thread Eric Auger
This series brings the VFIO part of HW nested paging support in the SMMUv3. The series depends on: [PATCH v9 00/14] SMMUv3 Nested Stage Setup (IOMMU part) (https://www.spinics.net/lists/kernel/msg3187714.html) 3 new IOCTLs are introduced that allow the userspace to 1) pass the guest stage 1

[PATCH v9 03/11] vfio: VFIO_IOMMU_SET_MSI_BINDING

2019-07-11 Thread Eric Auger
This patch adds the VFIO_IOMMU_SET_MSI_BINDING ioctl which aim to (un)register the guest MSI binding to the host. This latter then can use those stage 1 bindings to build a nested stage binding targeting the physical MSIs. Signed-off-by: Eric Auger --- v8 -> v9: - merge

[PATCH v9 07/11] vfio: Use capability chains to handle device specific irq

2019-07-11 Thread Eric Auger
From: Tina Zhang Caps the number of irqs with fixed indexes and uses capability chains to chain device specific irqs. Signed-off-by: Tina Zhang Signed-off-by: Eric Auger [Eric: Put cap_offset at the end of the vfio_irq_info struct, remove GFX IRQ at the moment and remove any reference to this

[PATCH v9 08/11] vfio: Add new IRQ for DMA fault reporting

2019-07-11 Thread Eric Auger
Add a new IRQ type/subtype to get notification on nested stage DMA faults. Signed-off-by: Eric Auger --- include/uapi/linux/vfio.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/uapi/linux/vfio.h b/include/uapi/linux/vfio.h index b53714ae02c5..58607809e81a 100644 ---

[PATCH v9 09/11] vfio/pci: Add framework for custom interrupt indices

2019-07-11 Thread Eric Auger
Implement IRQ capability chain infrastructure. All interrupt indexes beyond VFIO_PCI_NUM_IRQS are handled as extended interrupts. They are registered with a specific type/subtype and supported flags. Signed-off-by: Eric Auger --- drivers/vfio/pci/vfio_pci.c | 100

[PATCH v9 10/11] vfio/pci: Register and allow DMA FAULT IRQ signaling

2019-07-11 Thread Eric Auger
Register the VFIO_IRQ_TYPE_NESTED/VFIO_IRQ_SUBTYPE_DMA_FAULT IRQ that allows to signal a nested mode DMA fault. Signed-off-by: Eric Auger --- drivers/vfio/pci/vfio_pci.c | 22 -- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/drivers/vfio/pci/vfio_pci.c

[PATCH v9 11/11] vfio: Document nested stage control

2019-07-11 Thread Eric Auger
The VFIO API was enhanced to support nested stage control: a bunch of new iotcls, one DMA FAULT region and an associated specific IRQ. Let's document the process to follow to set up nested mode. Signed-off-by: Eric Auger --- v8 -> v9: - new names for SET_MSI_BINDING and SET_PASID_TABLE - new

[PATCH v9 02/11] vfio: VFIO_IOMMU_CACHE_INVALIDATE

2019-07-11 Thread Eric Auger
From: "Liu, Yi L" When the guest "owns" the stage 1 translation structures, the host IOMMU driver has no knowledge of caching structure updates unless the guest invalidation requests are trapped and passed down to the host. This patch adds the VFIO_IOMMU_CACHE_INVALIDATE ioctl with aims at

[PATCH v9 04/11] vfio/pci: Add VFIO_REGION_TYPE_NESTED region type

2019-07-11 Thread Eric Auger
Add a new specific DMA_FAULT region aiming to exposed nested mode translation faults. The region has a ring buffer that contains the actual fault records plus a header allowing to handle it (tail/head indices, max capacity, entry size). At the moment the region is dimensionned for 512 fault

[PATCH v9 05/11] vfio/pci: Register an iommu fault handler

2019-07-11 Thread Eric Auger
Register an IOMMU fault handler which records faults in the DMA FAULT region ring buffer. In a subsequent patch, we will add the signaling of a specific eventfd to allow the userspace to be notified whenever a new fault as shown up. Signed-off-by: Eric Auger --- v8 -> v9: - handler now takes

[PATCH v9 06/11] vfio/pci: Allow to mmap the fault queue

2019-07-11 Thread Eric Auger
The DMA FAULT region contains the fault ring buffer. There is benefit to let the userspace mmap this area. Expose this mmappable area through a sparse mmap entry and implement the mmap operation. Signed-off-by: Eric Auger --- v8 -> v9: - remove unused index local variable in

Re: [PATCH v8 26/29] vfio-pci: Register an iommu fault handler

2019-07-11 Thread Auger Eric
Hi Jean, Jacob, On 6/18/19 4:04 PM, Jean-Philippe Brucker wrote: > On 12/06/2019 19:53, Jacob Pan wrote: You are right, the worst case of the spurious PS is to terminate the group prematurely. Need to know the scope of the HW damage in case of mdev where group IDs can be shared

Re: [PATCH] kernel/dma: export dma_alloc_from_contiguous to modules

2019-07-11 Thread Christoph Hellwig
On Thu, Jul 11, 2019 at 09:50:58AM +0100, Robin Murphy wrote: > On 11/07/2019 06:33, miles.c...@mediatek.com wrote: >> From: Miles Chen >> >> This change exports dma_alloc_from_contiguous and >> dma_release_from_contiguous to modules. >> >> Currently, we can add a reserve a memory node in dts

Re: [RFC PATCH] iommu: io-pgtable: Drop WARN for empty PTEs on unmap

2019-07-11 Thread Will Deacon
On Wed, Jul 10, 2019 at 04:31:19PM -0600, Rob Herring wrote: > If a region has been mapped sparsely (such as on page faults), the user > has to keep track of what was mapped or not in order to avoid warnings > when unmapping the entire region. Remove the WARN on empty PTEs to allow > unmapping

[PATCH v9 01/14] iommu: Introduce attach/detach_pasid_table API

2019-07-11 Thread Eric Auger
From: Jacob Pan In virtualization use case, when a guest is assigned a PCI host device, protected by a virtual IOMMU on the guest, the physical IOMMU must be programmed to be consistent with the guest mappings. If the physical IOMMU supports two translation stages it makes sense to program guest

[PATCH v9 00/14] SMMUv3 Nested Stage Setup (IOMMU part)

2019-07-11 Thread Eric Auger
This series brings the IOMMU part of HW nested paging support in the SMMUv3. The VFIO part is submitted separately. The IOMMU API is extended to support 3 new API functionalities: 1) pass the guest stage 1 configuration 2) pass stage 1 MSI bindings 3) invalidate stage 1 related caches 3) is also

Re: [PATCH v8 07/21] iommu/io-pgtable-arm-v7s: Extend MediaTek 4GB Mode

2019-07-11 Thread Yong Wu
On Wed, 2019-07-10 at 15:36 +0100, Will Deacon wrote: > On Sat, Jun 29, 2019 at 10:09:13AM +0800, Yong Wu wrote: > > MediaTek extend the arm v7s descriptor to support the dram over 4GB. > > > > In the mt2712 and mt8173, it's called "4GB mode", the physical address > > is from 0x4000_ to

Re: [PATCH] kernel/dma: export dma_alloc_from_contiguous to modules

2019-07-11 Thread Miles Chen
On Thu, 2019-07-11 at 09:50 +0100, Robin Murphy wrote: > On 11/07/2019 06:33, miles.c...@mediatek.com wrote: > > From: Miles Chen > > > > This change exports dma_alloc_from_contiguous and > > dma_release_from_contiguous to modules. > > > > Currently, we can add a reserve a memory node in dts

[PATCH v9 13/14] iommu/smmuv3: Implement bind/unbind_guest_msi

2019-07-11 Thread Eric Auger
The bind/unbind_guest_msi() callbacks check the domain is NESTED and redirect to the dma-iommu implementation. Signed-off-by: Eric Auger --- v6 -> v7: - remove device handle argument --- drivers/iommu/arm-smmu-v3.c | 43 + 1 file changed, 43 insertions(+)

[PATCH v9 14/14] iommu/smmuv3: Report non recoverable faults

2019-07-11 Thread Eric Auger
When a stage 1 related fault event is read from the event queue, let's propagate it to potential external fault listeners, ie. users who registered a fault handler. Signed-off-by: Eric Auger --- v8 -> v9: - adapt to the removal of IOMMU_FAULT_UNRECOV_PERM_VALID: only look at

[PATCH v9 06/14] iommu/smmuv3: Get prepared for nested stage support

2019-07-11 Thread Eric Auger
When nested stage translation is setup, both s1_cfg and s2_cfg are allocated. We introduce a new smmu domain abort field that will be set upon guest stage1 configuration passing. arm_smmu_write_strtab_ent() is modified to write both stage fields in the STE and deal with the abort field. In

[PATCH v9 08/14] iommu/smmuv3: Introduce __arm_smmu_tlb_inv_asid/s1_range_nosync

2019-07-11 Thread Eric Auger
Introduce helpers to invalidate a given asid/vmid or invalidate address ranges associated to a given asid/vmid. S1 helpers will be used to invalidate stage 1 caches upon userspace request, in nested mode. Signed-off-by: Eric Auger --- --- drivers/iommu/arm-smmu-v3.c | 98

[PATCH v9 10/14] dma-iommu: Implement NESTED_MSI cookie

2019-07-11 Thread Eric Auger
Up to now, when the type was UNMANAGED, we used to allocate IOVA pages within a reserved IOVA MSI range. If both the host and the guest are exposed with SMMUs, each would allocate an IOVA. The guest allocates an IOVA (gIOVA) to map onto the guest MSI doorbell (gDB). The Host allocates another

[PATCH v9 03/14] iommu: Introduce bind/unbind_guest_msi

2019-07-11 Thread Eric Auger
On ARM, MSI are translated by the SMMU. An IOVA is allocated for each MSI doorbell. If both the host and the guest are exposed with SMMUs, we end up with 2 different IOVAs allocated by each. guest allocates an IOVA (gIOVA) to map onto the guest MSI doorbell (gDB). The Host allocates another IOVA

[PATCH v9 05/14] iommu/smmuv3: Dynamically allocate s1_cfg and s2_cfg

2019-07-11 Thread Eric Auger
In preparation for the introduction of nested configuration let's turn s1_cfg and s2_cfg fields into pointers which are dynamically allocated depending on the smmu_domain stage. In nested mode, s1_cfg will only be allocated when setting up S1 translation. Signed-off-by: Eric Auger ---

[PATCH v9 02/14] iommu: Introduce cache_invalidate API

2019-07-11 Thread Eric Auger
From: Yi L Liu In any virtualization use case, when the first translation stage is "owned" by the guest OS, the host IOMMU driver has no knowledge of caching structure updates unless the guest invalidation activities are trapped by the virtualizer and passed down to the host. Since the

[PATCH v9 07/14] iommu/smmuv3: Implement attach/detach_pasid_table

2019-07-11 Thread Eric Auger
On attach_pasid_table() we program STE S1 related info set by the guest into the actual physical STEs. At minimum we need to program the context descriptor GPA and compute whether the stage1 is translated/bypassed or aborted. Signed-off-by: Eric Auger --- v7 -> v8: - remove smmu->features

[PATCH v9 04/14] iommu/arm-smmu-v3: Maintain a SID->device structure

2019-07-11 Thread Eric Auger
From: Jean-Philippe Brucker When handling faults from the event or PRI queue, we need to find the struct device associated to a SID. Add a rb_tree to keep track of SIDs. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 134 ++-- 1 file

Re: [PATCH] dma-direct: Force unencrypted DMA under SME for certain DMA masks

2019-07-11 Thread Thomas Gleixner
On Thu, 11 Jul 2019, Christoph Hellwig wrote: > Hi Tom, > > this looks good to me. I'll wait a bit for feedback from the x86 folks, > and if everything is fine I'll apply it to the dma-mapping tree. Go ahead.

Re: [PATCH] dma-direct: Force unencrypted DMA under SME for certain DMA masks

2019-07-11 Thread Christoph Hellwig
Hi Tom, this looks good to me. I'll wait a bit for feedback from the x86 folks, and if everything is fine I'll apply it to the dma-mapping tree.

[PATCH v9 12/14] iommu/smmuv3: Enforce incompatibility between nested mode and HW MSI regions

2019-07-11 Thread Eric Auger
Nested mode currently is not compatible with HW MSI reserved regions. Indeed MSI transactions targeting this MSI doorbells bypass the SMMU. Let's check nested mode is not attempted in such configuration. Signed-off-by: Eric Auger --- drivers/iommu/arm-smmu-v3.c | 23 +-- 1

[PATCH v9 09/14] iommu/smmuv3: Implement cache_invalidate

2019-07-11 Thread Eric Auger
Implement domain-selective and page-selective IOTLB invalidations. Signed-off-by: Eric Auger --- v7 -> v8: - ASID based invalidation using iommu_inv_pasid_info - check ARCHID/PASID flags in addr based invalidation - use __arm_smmu_tlb_inv_context and __arm_smmu_tlb_inv_range_nosync v6 -> v7 -

Re: [PATCH] dma-direct: Force unencrypted DMA under SME for certain DMA masks

2019-07-11 Thread Thomas Gleixner
On Wed, 10 Jul 2019, Lendacky, Thomas wrote: > From: Tom Lendacky > > If a device doesn't support DMA to a physical address that includes the > encryption bit (currently bit 47, so 48-bit DMA), then the DMA must > occur to unencrypted memory. SWIOTLB is used to satisfy that requirement > if an

[PATCH v9 11/14] iommu/smmuv3: Nested mode single MSI doorbell per domain enforcement

2019-07-11 Thread Eric Auger
In nested mode we enforce the rule that all devices belonging to the same iommu_domain share the same msi_domain. Indeed if there were several physical MSI doorbells being used within a single iommu_domain, it becomes really difficult to resolve the nested stage mapping translating into the

Re: [PATCH v2] iommu/amd: fix a crash in iova_magazine_free_pfns

2019-07-11 Thread Christoph Hellwig
Thanks, the change looks good to me: Reviewed-by: Christoph Hellwig

[PATCH v2 1/4] iommu/arm-smmu: Introduce wrapper for writeq/readq

2019-07-11 Thread Gregory CLEMENT
From: Hanna Hawa This patch introduces the smmu_writeq_relaxed/smmu_readq_relaxed helpers, as preparation to add specific Marvell work-around for accessing 64 bits width registers of ARM SMMU. Signed-off-by: Hanna Hawa Signed-off-by: Gregory CLEMENT --- drivers/iommu/arm-smmu.c | 36

[PATCH v2 2/4] iommu/arm-smmu: Workaround for Marvell Armada-AP806 SoC erratum #582743

2019-07-11 Thread Gregory CLEMENT
From: Hanna Hawa Due to erratum #582743, the Marvell Armada-AP806 can't access 64bit to ARM SMMUv2 registers. This patch split the writeq/readq to two accesses of writel/readl. We also mask the MMU_IDR2.PTFSv8 fields to not use AArch64 format but only AARCH32_L. Indeed with AArch64 format 32

[PATCH v2 0/4] Add system mmu support for Armada-806

2019-07-11 Thread Gregory CLEMENT
Hello, last year a first version of this series was submitted to add support for IOMMU for AP806, including workaround for accessing ARM SMMU 64bit registers[1]. For the record, AP-806 can't access SMMU registers with 64bit width, this patches split the readq/writeq for 32bit access, due to

[PATCH v2 3/4] dt-bindings: iommu/arm,smmu: add compatible string for Marvell

2019-07-11 Thread Gregory CLEMENT
From: Hanna Hawa Add specific compatible string for Marvell usage due errata of accessing 64bits registers of ARM SMMU, in AP806. AP806 SoC uses the generic ARM-MMU500, and there's no specific implementation of Marvell, this compatible is used for errata only. Signed-off-by: Hanna Hawa

[PATCH v2] iommu/amd: fix a crash in iova_magazine_free_pfns

2019-07-11 Thread Qian Cai
The commit b3aa14f02254 ("iommu: remove the mapping_error dma_map_ops method") incorrectly changed the checking from dma_ops_alloc_iova() in map_sg() causes a crash under memory pressure as dma_ops_alloc_iova() never return DMA_MAPPING_ERROR on failure but 0, so the error handling is all wrong.

[RFC PATCH v2 01/19] iommu: Remove empty iommu_tlb_range_add() callback from iommu_ops

2019-07-11 Thread Will Deacon
Commit add02cfdc9bc ("iommu: Introduce Interface for IOMMU TLB Flushing") added three new TLB flushing operations to the IOMMU API so that the underlying driver operations can be batched when unmapping large regions of IO virtual address space. However, the ->iotlb_range_add() callback has not

[RFC PATCH v2 03/19] iommu/io-pgtable: Rename iommu_gather_ops to iommu_flush_ops

2019-07-11 Thread Will Deacon
In preparation for TLB flush gathering in the IOMMU API, rename the iommu_gather_ops structure in io-pgtable to iommu_flush_ops, which better describes its purpose and avoids the potential for confusion between different levels of the API. $ find linux/ -type f -name '*.[ch]' | xargs sed -i

[RFC PATCH v2 02/19] iommu/io-pgtable-arm: Remove redundant call to io_pgtable_tlb_sync()

2019-07-11 Thread Will Deacon
Commit b6b65ca20bc9 ("iommu/io-pgtable-arm: Add support for non-strict mode") added an unconditional call to io_pgtable_tlb_sync() immediately after the case where we replace a block entry with a table entry during an unmap() call. This is redundant, since the IOMMU API will call iommu_tlb_sync()

[RFC PATCH v2 00/19] Try to reduce lock contention on the SMMUv3 command queue

2019-07-11 Thread Will Deacon
Hi everyone, This is a significant rework of the RFC I previously posted here: https://lkml.kernel.org/r/20190611134603.4253-1-will.dea...@arm.com But this time, it looks like it might actually be worthwhile according to my perf profiles, where __iommu_unmap() falls a long way down the

[RFC PATCH v2 19/19] iommu/arm-smmu-v3: Defer TLB invalidation until ->iotlb_sync()

2019-07-11 Thread Will Deacon
Update the iommu_iotlb_gather structure passed to ->tlb_add_page() and use this information to defer all TLB invalidation until ->iotlb_sync(). This drastically reduces contention on the command queue, since we can insert our commands in batches rather than one-by-one. Signed-off-by: Will Deacon

[RFC PATCH v2 18/19] iommu/arm-smmu-v3: Reduce contention during command-queue insertion

2019-07-11 Thread Will Deacon
The SMMU command queue is a bottleneck in large systems, thanks to the spin_lock which serialises accesses from all CPUs to the single queue supported by the hardware. Attempt to improve this situation by moving to a new algorithm for inserting commands into the queue, which is lock-free on the

[RFC PATCH v2 14/19] iommu/arm-smmu-v3: Separate s/w and h/w views of prod and cons indexes

2019-07-11 Thread Will Deacon
In preparation for rewriting the command queue insertion code to use a new algorithm, separate the software and hardware views of the prod and cons indexes so that manipulating the software state doesn't automatically update the hardware state at the same time. No functional change.

[RFC PATCH v2 13/19] iommu/io-pgtable: Pass struct iommu_iotlb_gather to ->tlb_add_page()

2019-07-11 Thread Will Deacon
With all the pieces in place, we can finally propagate the iommu_iotlb_gather structure from the call to unmap() down to the IOMMU drivers' implementation of ->tlb_add_page(). Currently everybody ignores it, but the machinery is now there to defer invalidation. Signed-off-by: Will Deacon ---

[RFC PATCH v2 15/19] iommu/arm-smmu-v3: Drop unused 'q' argument from Q_OVF macro

2019-07-11 Thread Will Deacon
The Q_OVF macro doesn't need to access the arm_smmu_queue structure, so drop the unused macro argument. No functional change. Signed-off-by: Will Deacon --- drivers/iommu/arm-smmu-v3.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/arm-smmu-v3.c

[RFC PATCH v2 16/19] iommu/arm-smmu-v3: Move low-level queue fields out of arm_smmu_queue

2019-07-11 Thread Will Deacon
In preparation for rewriting the command queue insertion code to use a new algorithm, introduce a new arm_smmu_ll_queue structure which contains only the information necessary to perform queue arithmetic for a queue and will later be extended so that we can perform complex atomic manipulation on

[RFC PATCH v2 17/19] iommu/arm-smmu-v3: Operate directly on low-level queue where possible

2019-07-11 Thread Will Deacon
In preparation for rewriting the command queue insertion code to use a new algorithm, rework many of our queue macro accessors and manipulation functions so that they operate on the arm_smmu_ll_queue structure where possible. This will allow us to call these helpers on local variables without

[RFC PATCH v2 07/19] iommu/io-pgtable: Introduce tlb_flush_walk() and tlb_flush_leaf()

2019-07-11 Thread Will Deacon
In preparation for deferring TLB flushes to iommu_tlb_sync(), introduce two new synchronous invalidation helpers to the io-pgtable API, which allow the unmap() code to force invalidation in cases where it cannot be deferred (e.g. when replacing a table with a block or when TLBI_ON_MAP is set).

[RFC PATCH v2 08/19] iommu/io-pgtable: Hook up ->tlb_flush_walk() and ->tlb_flush_leaf() in drivers

2019-07-11 Thread Will Deacon
Hook up ->tlb_flush_walk() and ->tlb_flush_leaf() in drivers using the io-pgtable API so that we can start making use of them in the page-table code. For now, they can just wrap the implementations of ->tlb_add_flush and ->tlb_sync pending future optimisation in each driver. Signed-off-by: Will

[RFC PATCH v2 06/19] iommu: Pass struct iommu_iotlb_gather to ->unmap() and ->iotlb_sync()

2019-07-11 Thread Will Deacon
To allow IOMMU drivers to batch up TLB flushing operations and postpone them until ->iotlb_sync() is called, extend the prototypes for the ->unmap() and ->iotlb_sync() IOMMU ops callbacks to take a pointer to the current iommu_iotlb_gather structure. All affected IOMMU drivers are updated, but

[RFC PATCH v2 05/19] iommu: Introduce iommu_iotlb_gather_add_page()

2019-07-11 Thread Will Deacon
Introduce a helper function for drivers to use when updating an iommu_iotlb_gather structure in response to an ->unmap() call, rather than having to open-code the logic in every page-table implementation. Signed-off-by: Will Deacon --- include/linux/iommu.h | 31 +++

[RFC PATCH v2 10/19] iommu/io-pgtable: Replace ->tlb_add_flush() with ->tlb_add_page()

2019-07-11 Thread Will Deacon
The ->tlb_add_flush() callback in the io-pgtable API now looks a bit silly: - It takes a size and a granule, which are always the same - It takes a 'bool leaf', which is always true - It only ever flushes a single page With that in mind, replace it with an optional ->tlb_add_page()

[RFC PATCH v2 04/19] iommu: Introduce struct iommu_iotlb_gather for batching TLB flushes

2019-07-11 Thread Will Deacon
To permit batching of TLB flushes across multiple calls to the IOMMU driver's ->unmap() implementation, introduce a new structure for tracking the address range to be flushed and the granularity at which the flushing is required. This is hooked into the IOMMU API and its caller are updated to

[RFC PATCH v2 11/19] iommu/io-pgtable: Remove unused ->tlb_sync() callback

2019-07-11 Thread Will Deacon
The ->tlb_sync() callback is no longer used, so it can be removed. Signed-off-by: Will Deacon --- drivers/gpu/drm/panfrost/panfrost_mmu.c | 1 - drivers/iommu/arm-smmu-v3.c | 8 drivers/iommu/arm-smmu.c| 17 +

[RFC PATCH v2 12/19] iommu/io-pgtable: Pass struct iommu_iotlb_gather to ->unmap()

2019-07-11 Thread Will Deacon
Update the io-pgtable ->unmap() function to take an iommu_iotlb_gather pointer as an argument, and update the callers as appropriate. Signed-off-by: Will Deacon --- drivers/gpu/drm/panfrost/panfrost_mmu.c | 2 +- drivers/iommu/arm-smmu-v3.c | 2 +- drivers/iommu/arm-smmu.c

[RFC PATCH v2 09/19] iommu/io-pgtable-arm: Call ->tlb_flush_walk() and ->tlb_flush_leaf()

2019-07-11 Thread Will Deacon
Now that all IOMMU drivers using the io-pgtable API implement the ->tlb_flush_walk() and ->tlb_flush_leaf() callbacks, we can use them in the io-pgtable code instead of ->tlb_add_flush() immediately followed by ->tlb_sync(). Signed-off-by: Will Deacon --- drivers/iommu/io-pgtable-arm-v7s.c | 25

Re: [RFC PATCH] iommu: io-pgtable: Drop WARN for empty PTEs on unmap

2019-07-11 Thread Rob Herring
On Thu, Jul 11, 2019 at 4:23 AM Will Deacon wrote: > > On Wed, Jul 10, 2019 at 04:31:19PM -0600, Rob Herring wrote: > > If a region has been mapped sparsely (such as on page faults), the user > > has to keep track of what was mapped or not in order to avoid warnings > > when unmapping the entire

[PATCH 1/3] x86/Kconfig: Move ARCH_HAS_MEM_ENCRYPT to arch/Kconfig

2019-07-11 Thread Thiago Jung Bauermann
powerpc and s390 are going to use this feature as well, so put it in a generic location. Signed-off-by: Thiago Jung Bauermann --- arch/Kconfig | 3 +++ arch/x86/Kconfig | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/Kconfig b/arch/Kconfig index

[PATCH 2/3] DMA mapping: Move SME handling to x86-specific files

2019-07-11 Thread Thiago Jung Bauermann
Secure Memory Encryption is an x86-specific feature, so it shouldn't appear in generic kernel code. Introduce ARCH_HAS_DMA_CHECK_MASK so that x86 can define its own dma_check_mask() for the SME check. In SWIOTLB code, there's no need to mention which memory encryption feature is active. Also,

[PATCH 3/3] fs/core/vmcore: Move sev_active() reference to x86 arch code

2019-07-11 Thread Thiago Jung Bauermann
Secure Encrypted Virtualization is an x86-specific feature, so it shouldn't appear in generic kernel code because it forces non-x86 architectures to define the sev_active() function, which doesn't make a lot of sense. To solve this problem, add an x86 elfcorehdr_read() function to override the

[PATCH 0/3] Remove x86-specific code from generic headers

2019-07-11 Thread Thiago Jung Bauermann
Hello, Both powerpc¹ and s390² are adding headers. Currently, they have to supply definitions for functions and macros which only have a meaning on x86: sme_me_mask, sme_active() and sev_active(). Christoph Hellwig made a suggestion to "clean up the Kconfig and generic headers bits for memory