[PATCH v2 6/7] iommu/vt-d: Add page request draining support

2020-04-14 Thread Lu Baolu
When a PASID is stopped or terminated, there can be pending PRQs (requests that haven't received responses) in remapping hardware. This adds the interface to drain page requests and call it when a PASID is terminated. Signed-off-by: Jacob Pan Signed-off-by: Liu Yi L Signed-off-by: Lu Baolu ---

[PATCH v2 3/7] iommu/vt-d: debugfs: Add support to show inv queue internals

2020-04-14 Thread Lu Baolu
Export invalidation queue internals of each iommu device through the debugfs. Example of such dump on a Skylake machine: $ sudo cat /sys/kernel/debug/iommu/intel/invalidation_queue Invalidation queue on IOMMU: dmar1 Base: 0x1672c9000 Head: 80Tail: 80 Index qw0

[PATCH v2 5/7] iommu/vt-d: Save prq descriptors in an internal list

2020-04-14 Thread Lu Baolu
Currently, the page request interrupt thread handles the page requests in the queue in this way: - Clear PPR bit to ensure new interrupt could come in; - Read and record the head and tail registers; - Handle all descriptors between head and tail; - Write tail to head register. This might cause

[PATCH v2 1/7] iommu/vt-d: Refactor parameters for qi_submit_sync()

2020-04-14 Thread Lu Baolu
Current qi_submit_sync() supports single invalidation descriptor per submission and appends wait descriptor after each submission to poll hardware completion. This patch adjusts the parameters of this function so that multiple descriptors per submission can be supported. Signed-off-by: Jacob Pan

[PATCH v2 2/7] iommu/vt-d: Multiple descriptors per qi_submit_sync()

2020-04-14 Thread Lu Baolu
Extend qi_submit_sync() function to support multiple descriptors. Signed-off-by: Jacob Pan Signed-off-by: Lu Baolu --- drivers/iommu/dmar.c| 39 +++-- include/linux/intel-iommu.h | 1 + 2 files changed, 25 insertions(+), 15 deletions(-) diff --git

[PATCH v2 4/7] iommu/vt-d: Refactor prq_event_thread()

2020-04-14 Thread Lu Baolu
Move the software processing page request descriptors part from prq_event_thread() into a separated function. No any functional changes. Signed-off-by: Lu Baolu --- drivers/iommu/intel-svm.c | 256 -- 1 file changed, 135 insertions(+), 121 deletions(-) diff

[PATCH v2 7/7] iommu/vt-d: Remove redundant IOTLB flush

2020-04-14 Thread Lu Baolu
IOTLB flush already included in the PASID tear down and the page request drain process. There is no need to flush again. Signed-off-by: Jacob Pan Signed-off-by: Lu Baolu --- drivers/iommu/intel-svm.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/iommu/intel-svm.c

[PATCH v2 0/7] iommu/vt-d: Add page request draining support

2020-04-14 Thread Lu Baolu
When a PASID is stopped or terminated, there can be pending PRQs (requests that haven't received responses) in the software and remapping hardware. The pending page requests must be drained so that the pasid could be reused. The register level interface for page request draining is defined in 7.11

Re: [PATCH 1/4] dma-mapping: move the remaining DMA API calls out of line

2020-04-14 Thread Alexey Kardashevskiy
On 14/04/2020 22:25, Christoph Hellwig wrote: > For a long time the DMA API has been implemented inline in dma-mapping.h, > but the function bodies can be quite large. Move them all out of line. > > Signed-off-by: Christoph Hellwig > --- > include/linux/dma-direct.h | 58 + >

RE: [PATCH] dt-bndings: iommu: renesas, ipmmu-vmsa: convert to json-schema

2020-04-14 Thread Yoshihiro Shimoda
Hi Robin, > From: Robin Murphy, Sent: Wednesday, April 15, 2020 2:16 AM > > On 2020-04-13 11:25 am, Yoshihiro Shimoda wrote: > [...] > > -Each bus master connected to an IPMMU must reference the IPMMU in its > > device > > -node with the following property: > > - > > - - iommus: A reference to

RE: [PATCH v1 2/2] vfio/pci: Emulate PASID/PRI capability for VFs

2020-04-14 Thread Tian, Kevin
> From: Alex Williamson > Sent: Wednesday, April 15, 2020 8:36 AM > > On Tue, 14 Apr 2020 23:57:33 + > "Tian, Kevin" wrote: > > > > From: Alex Williamson > > > Sent: Tuesday, April 14, 2020 11:24 PM > > > > > > On Tue, 14 Apr 2020 03:42:42 + > > > "Tian, Kevin" wrote: > > > > > > > >

Re: [PATCH v1 2/2] vfio/pci: Emulate PASID/PRI capability for VFs

2020-04-14 Thread Alex Williamson
On Tue, 14 Apr 2020 23:57:33 + "Tian, Kevin" wrote: > > From: Alex Williamson > > Sent: Tuesday, April 14, 2020 11:24 PM > > > > On Tue, 14 Apr 2020 03:42:42 + > > "Tian, Kevin" wrote: > > > > > > From: Alex Williamson > > > > Sent: Tuesday, April 14, 2020 11:29 AM > > > > > > > >

[patch 4/7] dma-direct: atomic allocations must come from atomic coherent pools

2020-04-14 Thread David Rientjes via iommu
When a device requires unencrypted memory and the context does not allow blocking, memory must be returned from the atomic coherent pools. This avoids the remap when CONFIG_DMA_DIRECT_REMAP is not enabled and the config only requires CONFIG_DMA_COHERENT_POOL. This will be used for

[patch 1/7] dma-remap: separate DMA atomic pools from direct remap code

2020-04-14 Thread David Rientjes via iommu
DMA atomic pools will be needed beyond only CONFIG_DMA_DIRECT_REMAP so separate them out into their own file. This also adds a new Kconfig option that can be subsequently used for options, such as CONFIG_AMD_MEM_ENCRYPT, that will utilize the coherent pools but do not have a dependency on direct

[patch 3/7] dma-pool: dynamically expanding atomic pools

2020-04-14 Thread David Rientjes via iommu
When an atomic pool becomes fully depleted because it is now relied upon for all non-blocking allocations through the DMA API, allow background expansion of each pool by a kworker. When an atomic pool has less than the default size of memory left, kick off a kworker to dynamically expand the pool

[patch 6/7] x86/mm: unencrypted non-blocking DMA allocations use coherent pools

2020-04-14 Thread David Rientjes via iommu
When CONFIG_AMD_MEM_ENCRYPT is enabled and a device requires unencrypted DMA, all non-blocking allocations must originate from the atomic DMA coherent pools. Select CONFIG_DMA_COHERENT_POOL for CONFIG_AMD_MEM_ENCRYPT. Signed-off-by: David Rientjes --- arch/x86/Kconfig | 1 + 1 file changed, 1

[patch 0/7] unencrypted atomic DMA pools with dynamic expansion

2020-04-14 Thread David Rientjes via iommu
set_memory_decrypted() may block so it is not possible to do non-blocking allocations through the DMA API for devices that required unencrypted memory. The solution is to expand the atomic DMA pools for the various possible gfp requirements as a means to prevent an unnecessary depletion of

[patch 7/7] dma-pool: scale the default DMA coherent pool size with memory capacity

2020-04-14 Thread David Rientjes via iommu
When AMD memory encryption is enabled, some devices may use more than 256KB/sec from the atomic pools. It would be more appropriate to scale the default size based on memory capacity unless the coherent_pool option is used on the kernel command line. This provides a slight optimization on

[patch 2/7] dma-pool: add additional coherent pools to map to gfp mask

2020-04-14 Thread David Rientjes via iommu
The single atomic pool is allocated from the lowest zone possible since it is guaranteed to be applicable for any DMA allocation. Devices may allocate through the DMA API but not have a strict reliance on GFP_DMA memory. Since the atomic pool will be used for all non-blockable allocations,

[patch 5/7] dma-pool: add pool sizes to debugfs

2020-04-14 Thread David Rientjes via iommu
The atomic DMA pools can dynamically expand based on non-blocking allocations that need to use it. Export the sizes of each of these pools, in bytes, through debugfs for measurement. Suggested-by: Christoph Hellwig Signed-off-by: David Rientjes --- kernel/dma/pool.c | 41

RE: [PATCH v1 2/2] vfio/pci: Emulate PASID/PRI capability for VFs

2020-04-14 Thread Tian, Kevin
> From: Alex Williamson > Sent: Tuesday, April 14, 2020 11:24 PM > > On Tue, 14 Apr 2020 03:42:42 + > "Tian, Kevin" wrote: > > > > From: Alex Williamson > > > Sent: Tuesday, April 14, 2020 11:29 AM > > > > > > On Tue, 14 Apr 2020 02:40:58 + > > > "Tian, Kevin" wrote: > > > > > > > >

RE: [PATCH v2 1/3] iommu/uapi: Define uapi version and capabilities

2020-04-14 Thread Tian, Kevin
> From: Jacob Pan > Sent: Wednesday, April 15, 2020 6:32 AM > > On Tue, 14 Apr 2020 10:13:04 -0700 > Jacob Pan wrote: > > > > > > In any of the proposed solutions, the > > > > > IOMMU driver is ultimately responsible for validating the user > > > > > data, so do we want vfio performing the

Re: [PATCH v2 1/3] iommu/uapi: Define uapi version and capabilities

2020-04-14 Thread Jacob Pan
On Tue, 14 Apr 2020 10:13:04 -0700 Jacob Pan wrote: > > > > In any of the proposed solutions, the > > > > IOMMU driver is ultimately responsible for validating the user > > > > data, so do we want vfio performing the copy_from_user() to an > > > > object that could later be assumed to be

Re: [PATCH v11 01/13] iommu: Introduce attach/detach_pasid_table API

2020-04-14 Thread Jacob Pan
Hi Eric, There are some discussions about how to size the uAPI data. https://lkml.org/lkml/2020/4/14/939 I think the problem with the current scheme is that when uAPI data gets extended, if VFIO continue to use: minsz = offsetofend(struct vfio_iommu_type1_set_pasid_table, config); if

Re: [rfc v2 3/6] dma-pool: dynamically expanding atomic pools

2020-04-14 Thread David Rientjes via iommu
On Tue, 14 Apr 2020, Christoph Hellwig wrote: > > I'll rely on Christoph to determine whether it makes sense to add some > > periodic scavening of the atomic pools, whether that's needed for this to > > be merged, or wheter we should enforce some maximum pool size. > > I don't really see the

Re: [rfc v2 4/6] dma-direct: atomic allocations must come from atomic coherent pools

2020-04-14 Thread David Rientjes via iommu
On Tue, 14 Apr 2020, Christoph Hellwig wrote: > > + /* > > +* Unencrypted memory must come directly from DMA atomic pools if > > +* blocking is not allowed. > > +*/ > > + if (IS_ENABLED(CONFIG_DMA_COHERENT_POOL) && > > + force_dma_unencrypted(dev) &&

Re: [rfc v2 4/6] dma-direct: atomic allocations must come from atomic coherent pools

2020-04-14 Thread David Rientjes via iommu
On Thu, 9 Apr 2020, Tom Lendacky wrote: > > When a device required unencrypted memory and the context does not allow > > required => requires > Fixed, thanks. > > blocking, memory must be returned from the atomic coherent pools. > > > > This avoids the remap when CONFIG_DMA_DIRECT_REMAP is

Re: [PATCH v5 01/25] mm/mmu_notifiers: pass private data down to alloc_notifier()

2020-04-14 Thread Jason Gunthorpe
On Tue, Apr 14, 2020 at 07:02:29PM +0200, Jean-Philippe Brucker wrote: > The new allocation scheme introduced by commit 2c7933f53f6b > ("mm/mmu_notifiers: add a get/put scheme for the registration") provides > a convenient way for users to attach notifier data to an mm. However, it > would be even

Re: [PATCH v5 23/25] PCI/ATS: Add PRI stubs

2020-04-14 Thread Kuppuswamy, Sathyanarayanan
Hi, On 4/14/20 10:02 AM, Jean-Philippe Brucker wrote: The SMMUv3 driver, which can be built without CONFIG_PCI, will soon gain support for PRI. Partially revert commit c6e9aefbf9db ("PCI/ATS: Remove unused PRI and PASID stubs") to re-introduce the PRI stubs, and avoid adding more #ifdefs to

Re: [PATCH v5 24/25] PCI/ATS: Export PRI functions

2020-04-14 Thread Kuppuswamy, Sathyanarayanan
Hi, On 4/14/20 10:02 AM, Jean-Philippe Brucker wrote: The SMMUv3 driver uses pci_{enable,disable}_pri() and related functions. Export those functions to allow the driver to be built as a module. Acked-by: Bjorn Helgaas Signed-off-by: Jean-Philippe Brucker Reviewed-by: Kuppuswamy

Re: [PATCH] dt-bndings: iommu: renesas, ipmmu-vmsa: convert to json-schema

2020-04-14 Thread Robin Murphy
On 2020-04-13 11:25 am, Yoshihiro Shimoda wrote: [...] -Each bus master connected to an IPMMU must reference the IPMMU in its device -node with the following property: - - - iommus: A reference to the IPMMU in two cells. The first cell is a phandle -to the IPMMU and the second cell the

Re: [PATCH v2 1/3] iommu/uapi: Define uapi version and capabilities

2020-04-14 Thread Jacob Pan
On Tue, 14 Apr 2020 10:13:58 -0600 Alex Williamson wrote: > On Mon, 13 Apr 2020 22:05:15 -0700 > Jacob Pan wrote: > > > Hi Alex, > > Thanks a lot for the feedback, my comments inline. > > > > On Mon, 13 Apr 2020 16:21:29 -0600 > > Alex Williamson wrote: > > > > > On Mon, 13 Apr 2020

[PATCH v5 14/25] iommu/arm-smmu-v3: Add support for VHE

2020-04-14 Thread Jean-Philippe Brucker
ARMv8.1 extensions added Virtualization Host Extensions (VHE), which allow to run a host kernel at EL2. When using normal DMA, Device and CPU address spaces are dissociated, and do not need to implement the same capabilities, so VHE hasn't been used in the SMMU until now. With shared address

[PATCH v5 24/25] PCI/ATS: Export PRI functions

2020-04-14 Thread Jean-Philippe Brucker
The SMMUv3 driver uses pci_{enable,disable}_pri() and related functions. Export those functions to allow the driver to be built as a module. Acked-by: Bjorn Helgaas Signed-off-by: Jean-Philippe Brucker --- drivers/pci/ats.c | 4 1 file changed, 4 insertions(+) diff --git

[PATCH v5 03/25] iommu: Add a page fault handler

2020-04-14 Thread Jean-Philippe Brucker
Some systems allow devices to handle I/O Page Faults in the core mm. For example systems implementing the PCI PRI extension or Arm SMMU stall model. Infrastructure for reporting these recoverable page faults was recently added to the IOMMU core. Add a page fault handler for host SVA. IOMMU driver

[PATCH v5 21/25] dt-bindings: document stall property for IOMMU masters

2020-04-14 Thread Jean-Philippe Brucker
On ARM systems, some platform devices behind an IOMMU may support stall, which is the ability to recover from page faults. Let the firmware tell us when a device supports stall. Reviewed-by: Rob Herring Signed-off-by: Jean-Philippe Brucker --- .../devicetree/bindings/iommu/iommu.txt|

[PATCH v5 18/25] iommu/arm-smmu-v3: Hook up ATC invalidation to mm ops

2020-04-14 Thread Jean-Philippe Brucker
iommu-sva calls us when an mm is modified. Perform the required ATC invalidations. Signed-off-by: Jean-Philippe Brucker --- v4->v5: more comments --- drivers/iommu/arm-smmu-v3.c | 70 ++--- 1 file changed, 58 insertions(+), 12 deletions(-) diff --git

[PATCH v5 12/25] iommu/arm-smmu-v3: Share process page tables

2020-04-14 Thread Jean-Philippe Brucker
With Shared Virtual Addressing (SVA), we need to mirror CPU TTBR, TCR, MAIR and ASIDs in SMMU contexts. Each SMMU has a single ASID space split into two sets, shared and private. Shared ASIDs correspond to those obtained from the arch ASID allocator, and private ASIDs are used for "classic"

[PATCH v5 10/25] iommu/arm-smmu-v3: Manage ASIDs with xarray

2020-04-14 Thread Jean-Philippe Brucker
In preparation for sharing some ASIDs with the CPU, use a global xarray to store ASIDs and their context. ASID#0 is now reserved, and the ASID space is global. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 27 ++- 1 file changed, 18

[PATCH v5 22/25] iommu/arm-smmu-v3: Add stall support for platform devices

2020-04-14 Thread Jean-Philippe Brucker
The SMMU provides a Stall model for handling page faults in platform devices. It is similar to PCI PRI, but doesn't require devices to have their own translation cache. Instead, faulting transactions are parked and the OS is given a chance to fix the page tables and retry the transaction. Enable

[PATCH v5 13/25] iommu/arm-smmu-v3: Seize private ASID

2020-04-14 Thread Jean-Philippe Brucker
The SMMU has a single ASID space, the union of shared and private ASID sets. This means that the SMMU driver competes with the arch allocator for ASIDs. Shared ASIDs are those of Linux processes, allocated by the arch, and contribute in broadcast TLB maintenance. Private ASIDs are allocated by the

[PATCH v5 05/25] iommu/iopf: Handle mm faults

2020-04-14 Thread Jean-Philippe Brucker
When a recoverable page fault is handled by the fault workqueue, find the associated mm and call handle_mm_fault. Signed-off-by: Jean-Philippe Brucker --- v4->v5: no need to call mmput_async() anymore, since the MMU release() doesn't flush the IOPF queue anymore. ---

[PATCH v5 02/25] iommu/sva: Manage process address spaces

2020-04-14 Thread Jean-Philippe Brucker
Add a small library to help IOMMU drivers manage process address spaces bound to their devices. Register an MMU notifier to track modification on each address space bound to one or more devices. IOMMU drivers must implement the io_mm_ops and can then use the helpers provided by this library to

[PATCH v5 00/25] iommu: Shared Virtual Addressing and SMMUv3 support

2020-04-14 Thread Jean-Philippe Brucker
Shared Virtual Addressing (SVA) allows to share process page tables with devices using the IOMMU. Add a generic implementation of the IOMMU SVA API, and add support in the Arm SMMUv3 driver. Since v4 [1] I changed the PASID lifetime. It isn't released when the corresponding process address space

[PATCH v5 25/25] iommu/arm-smmu-v3: Add support for PRI

2020-04-14 Thread Jean-Philippe Brucker
For PCI devices that support it, enable the PRI capability and handle PRI Page Requests with the generic fault handler. It is enabled on demand by iommu_sva_device_init(). Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 284 +--- 1 file

[PATCH v5 20/25] iommu/arm-smmu-v3: Maintain a SID->device structure

2020-04-14 Thread 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 | 179 +--- 1 file changed, 147 insertions(+), 32

[PATCH v5 04/25] iommu/sva: Search mm by PASID

2020-04-14 Thread Jean-Philippe Brucker
The fault handler will need to find an mm given its PASID. This is the reason we have an IDR for storing address spaces, so hook it up. Signed-off-by: Jean-Philippe Brucker --- include/linux/iommu.h | 9 + drivers/iommu/iommu-sva.c | 19 +++ 2 files changed, 28

[PATCH v5 23/25] PCI/ATS: Add PRI stubs

2020-04-14 Thread Jean-Philippe Brucker
The SMMUv3 driver, which can be built without CONFIG_PCI, will soon gain support for PRI. Partially revert commit c6e9aefbf9db ("PCI/ATS: Remove unused PRI and PASID stubs") to re-introduce the PRI stubs, and avoid adding more #ifdefs to the SMMU driver. Acked-by: Bjorn Helgaas Signed-off-by:

[PATCH v5 19/25] iommu/arm-smmu-v3: Add support for Hardware Translation Table Update

2020-04-14 Thread Jean-Philippe Brucker
If the SMMU supports it and the kernel was built with HTTU support, enable hardware update of access and dirty flags. This is essential for shared page tables, to reduce the number of access faults on the fault queue. We can enable HTTU even if CPUs don't support it, because the kernel always

[PATCH v5 01/25] mm/mmu_notifiers: pass private data down to alloc_notifier()

2020-04-14 Thread Jean-Philippe Brucker
The new allocation scheme introduced by commit 2c7933f53f6b ("mm/mmu_notifiers: add a get/put scheme for the registration") provides a convenient way for users to attach notifier data to an mm. However, it would be even better to create this notifier data atomically. Since the alloc_notifier()

[PATCH v5 16/25] iommu/arm-smmu-v3: Add SVA feature checking

2020-04-14 Thread Jean-Philippe Brucker
Aggregate all sanity-checks for sharing CPU page tables with the SMMU under a single ARM_SMMU_FEAT_SVA bit. For PCIe SVA, users also need to check FEAT_ATS and FEAT_PRI. For platform SVA, they will most likely have to check FEAT_STALLS. Cc: Suzuki K Poulose Signed-off-by: Jean-Philippe Brucker

[PATCH v5 06/25] iommu/sva: Register page fault handler

2020-04-14 Thread Jean-Philippe Brucker
When enabling SVA, register the fault handler. Device driver will register an I/O page fault queue before or after calling iommu_sva_enable. The fault queue must be flushed before any io_mm is freed, to make sure that its PASID isn't used in any fault queue, and can be reallocated. Signed-off-by:

[PATCH v5 11/25] arm64: cpufeature: Export symbol read_sanitised_ftr_reg()

2020-04-14 Thread Jean-Philippe Brucker
The SMMUv3 driver would like to read the MMFR0 PARANGE field in order to share CPU page tables with devices. Allow the driver to be built as module by exporting the read_sanitized_ftr_reg() cpufeature symbol. Cc: Suzuki K Poulose Signed-off-by: Jean-Philippe Brucker ---

[PATCH v5 09/25] iommu/io-pgtable-arm: Move some definitions to a header

2020-04-14 Thread Jean-Philippe Brucker
Extract some of the most generic TCR defines, so they can be reused by the page table sharing code. Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/io-pgtable-arm.h | 30 ++ drivers/iommu/io-pgtable-arm.c | 27 ++- 2 files changed, 32

[PATCH v5 08/25] arm64: mm: Pin down ASIDs for sharing mm with devices

2020-04-14 Thread Jean-Philippe Brucker
To enable address space sharing with the IOMMU, introduce mm_context_get() and mm_context_put(), that pin down a context and ensure that it will keep its ASID after a rollover. Export the symbols to let the modular SMMUv3 driver use them. Pinning is necessary because a device constantly needs a

[PATCH v5 17/25] iommu/arm-smmu-v3: Implement mm operations

2020-04-14 Thread Jean-Philippe Brucker
Hook SVA operations to support sharing page tables with the SMMUv3: * dev_enable/disable/has_feature for device drivers to modify the SVA state. * sva_bind/unbind and sva_get_pasid to bind device and address spaces. * The mm_attach/detach/clear/invalidate/free callbacks from iommu-sva The

[PATCH v5 07/25] arm64: mm: Add asid_gen_match() helper

2020-04-14 Thread Jean-Philippe Brucker
Add a macro to check if an ASID is from the current generation, since a subsequent patch will introduce a third user for this test. Signed-off-by: Jean-Philippe Brucker --- v4->v5: new --- arch/arm64/mm/context.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git

[PATCH v5 15/25] iommu/arm-smmu-v3: Enable broadcast TLB maintenance

2020-04-14 Thread Jean-Philippe Brucker
The SMMUv3 can handle invalidation targeted at TLB entries with shared ASIDs. If the implementation supports broadcast TLB maintenance, enable it and keep track of it in a feature bit. The SMMU will then be affected by inner-shareable TLB invalidations from other agents. A major side-effect of

Re: [PATCH 2/2] iommu/arm-smmu: Allow client devices to select direct mapping

2020-04-14 Thread Sai Prakash Ranjan
Hi Evan, On 2020-04-14 04:42, Evan Green wrote: On Wed, Jan 22, 2020 at 3:48 AM Sai Prakash Ranjan wrote: From: Jordan Crouse Some client devices want to directly map the IOMMU themselves instead of using the DMA domain. Allow those devices to opt in to direct mapping by way of a list of

Re: [PATCH v2 1/3] iommu/uapi: Define uapi version and capabilities

2020-04-14 Thread Alex Williamson
On Mon, 13 Apr 2020 22:05:15 -0700 Jacob Pan wrote: > Hi Alex, > Thanks a lot for the feedback, my comments inline. > > On Mon, 13 Apr 2020 16:21:29 -0600 > Alex Williamson wrote: > > > On Mon, 13 Apr 2020 13:41:57 -0700 > > Jacob Pan wrote: > > > > > Hi All, > > > > > > Just a gentle

Re: [PATCH v2 1/3] iommu/uapi: Define uapi version and capabilities

2020-04-14 Thread Jacob Pan
On Tue, 14 Apr 2020 01:11:07 -0700 Christoph Hellwig wrote: > On Mon, Apr 13, 2020 at 01:41:57PM -0700, Jacob Pan wrote: > > Hi All, > > > > Just a gentle reminder, any feedback on the options I listed below? > > New ideas will be even better. > > > > Christoph, does the explanation make sense

Re: [RFC PATCH 11/34] iommu: Split off default domain allocation from group assignment

2020-04-14 Thread j...@8bytes.org
Hi Jonathan, On Mon, Apr 13, 2020 at 10:10:50PM +, Derrick, Jonathan wrote: > I had to add the following for initial VMD support. The new PCIe domain > added on VMD endpoint probe didn't have the dev_iommu member set on the > VMD subdevices, which I'm guessing is due to probe_iommu_group

Re: [PATCH v1 2/2] vfio/pci: Emulate PASID/PRI capability for VFs

2020-04-14 Thread Alex Williamson
On Tue, 14 Apr 2020 03:42:42 + "Tian, Kevin" wrote: > > From: Alex Williamson > > Sent: Tuesday, April 14, 2020 11:29 AM > > > > On Tue, 14 Apr 2020 02:40:58 + > > "Tian, Kevin" wrote: > > > > > > From: Alex Williamson > > > > Sent: Tuesday, April 14, 2020 3:21 AM > > > > > > > >

Re: [PATCH 21/29] mm: remove the pgprot argument to __vmalloc

2020-04-14 Thread Wei Liu
On Tue, Apr 14, 2020 at 03:13:40PM +0200, Christoph Hellwig wrote: > The pgprot argument to __vmalloc is always PROT_KERNEL now, so remove > it. > > Signed-off-by: Christoph Hellwig > Reviewed-by: Michael Kelley [hyperv] > Acked-by: Gao Xiang [erofs] > Acked-by: Peter Zijlstra (Intel) > --- >

[PATCH v11 11/13] iommu/smmuv3: Enforce incompatibility between nested mode and HW MSI regions

2020-04-14 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 v11 13/13] iommu/smmuv3: Report non recoverable faults

2020-04-14 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 v11 10/13] iommu/smmuv3: Nested mode single MSI doorbell per domain enforcement

2020-04-14 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

[PATCH v11 12/13] iommu/smmuv3: Implement bind/unbind_guest_msi

2020-04-14 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 v11 03/13] iommu/arm-smmu-v3: Maintain a SID->device structure

2020-04-14 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: Eric Auger Signed-off-by: Jean-Philippe Brucker --- drivers/iommu/arm-smmu-v3.c | 112

[PATCH v11 09/13] dma-iommu: Implement NESTED_MSI cookie

2020-04-14 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 v11 05/13] iommu/smmuv3: Get prepared for nested stage support

2020-04-14 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 v11 08/13] iommu/smmuv3: Implement cache_invalidate

2020-04-14 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 -

[PATCH v11 06/13] iommu/smmuv3: Implement attach/detach_pasid_table

2020-04-14 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 v11 07/13] iommu/smmuv3: Allow stage 1 invalidation with unmanaged ASIDs

2020-04-14 Thread Eric Auger
With nested stage support, soon we will need to invalidate S1 contexts and ranges tagged with an unmanaged asid, this latter being managed by the guest. So let's introduce 2 helpers that allow to invalidate with externally managed ASIDs Signed-off-by: Eric Auger --- drivers/iommu/arm-smmu-v3.c

[PATCH v11 02/13] iommu: Introduce bind/unbind_guest_msi

2020-04-14 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 v11 04/13] iommu/smmuv3: Dynamically allocate s1_cfg and s2_cfg

2020-04-14 Thread Eric Auger
In preparation for the introduction of nested stages let's turn s1_cfg and s2_cfg fields into pointers which are dynamically allocated depending on the smmu_domain stage. In nested mode, both stages will coexist and s1_cfg will be allocated when the guest configuration gets passed.

[PATCH v11 00/13] SMMUv3 Nested Stage Setup (IOMMU part)

2020-04-14 Thread Eric Auger
This version fixes an issue observed by Shameer on an SMMU 3.2, when moving from dual stage config to stage 1 only config. The 2 high 64b of the STE now get reset. Otherwise, leaving the S2TTB set may cause a C_BAD_STE error. This series can be found at:

[PATCH v11 01/13] iommu: Introduce attach/detach_pasid_table API

2020-04-14 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

Re: [RFC PATCH 1/4] bus: fsl-mc: add custom .dma_configure implementation

2020-04-14 Thread Lorenzo Pieralisi
On Wed, Mar 25, 2020 at 06:48:55PM +0200, Laurentiu Tudor wrote: > Hi Lorenzo, > > On 3/25/2020 2:51 PM, Lorenzo Pieralisi wrote: > > On Thu, Feb 27, 2020 at 12:05:39PM +0200, laurentiu.tu...@nxp.com wrote: > >> From: Laurentiu Tudor > >> > >> The devices on this bus are not discovered by way of

[PATCH] iommu: spapr_tce: Disable compile testing to fix build on book3s_32 config

2020-04-14 Thread Krzysztof Kozlowski
Although SPAPR_TCE_IOMMU itself can be compile tested on certain PowerPC configurations, its presence makes arch/powerpc/kvm/Makefile to select modules which do not build in such configuration. The arch/powerpc/kvm/ modules use kvm_arch.spapr_tce_tables which exists only with

Re: [PATCH] iommu/exynos: Get rid of 'struct exynos_iommu_owner' exynos_iommu_owner

2020-04-14 Thread Joerg Roedel
On Thu, Apr 09, 2020 at 03:58:00PM +0200, Marek Szyprowski wrote: > I've checked and it works fine on top of > ff68eb23308e6538ec7864c83d39540f423bbe90. However I'm not a fan of > removing this 'owner' structure. It gave a nice abstraction for the all > SYSMMU controllers for the given device

Re: [RFC PATCH 33/34] iommu: Remove add_device()/remove_device() code-paths

2020-04-14 Thread Joerg Roedel
Hi Marek, On Fri, Apr 10, 2020 at 12:39:38PM +0200, Marek Szyprowski wrote: > > + if (!group->default_domain) > > + continue; > > It doesn't look straight from the above diff, but this continue leaks > group->lock taken. You are right, thanks for the review! I fixed

[PATCH 26/29] mm: remove vmalloc_user_node_flags

2020-04-14 Thread Christoph Hellwig
Open code it in __bpf_map_area_alloc, which is the only caller. Also clean up __bpf_map_area_alloc to have a single vmalloc call with slightly different flags instead of the current two different calls. For this to compile for the nommu case add a __vmalloc_node_range stub to nommu.c.

[PATCH v2 00/33] iommu: Move iommu_group setup to IOMMU core code

2020-04-14 Thread Joerg Roedel
Hi, here is the second version of this patch-set. The first version with some more introductory text can be found here: https://lore.kernel.org/lkml/20200407183742.4344-1-j...@8bytes.org/ Changes v1->v2: * Rebased to v5.7-rc1 * Re-wrote the arm-smmu changes as

[PATCH v2 33/33] iommu: Unexport iommu_group_get_for_dev()

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel The function is now only used in IOMMU core code and shouldn't be used outside of it anyway, so remove the export for it. Signed-off-by: Joerg Roedel --- drivers/iommu/iommu.c | 4 ++-- include/linux/iommu.h | 1 - 2 files changed, 2 insertions(+), 3 deletions(-) diff

[PATCH 25/29] mm: switch the test_vmalloc module to use __vmalloc_node

2020-04-14 Thread Christoph Hellwig
No need to export the very low-level __vmalloc_node_range when the test module can use a slightly higher level variant. Signed-off-by: Christoph Hellwig Acked-by: Peter Zijlstra (Intel) --- lib/test_vmalloc.c | 26 +++--- mm/vmalloc.c | 17 - 2 files

[PATCH 18/29] mm: remove the prot argument from vm_map_ram

2020-04-14 Thread Christoph Hellwig
This is always PAGE_KERNEL - for long term mappings with other properties vmap should be used. Signed-off-by: Christoph Hellwig Acked-by: Peter Zijlstra (Intel) --- drivers/gpu/drm/i915/gem/selftests/mock_dmabuf.c | 2 +- drivers/media/common/videobuf2/videobuf2-dma-sg.c | 3 +--

[PATCH v2 25/33] iommu/rockchip: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the Rockchip IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/rockchip-iommu.c | 26 +++--- 1 file

[PATCH 20/29] gpu/drm: remove the powerpc hack in drm_legacy_sg_alloc

2020-04-14 Thread Christoph Hellwig
The non-cached vmalloc mapping was initially added as a hack for the first-gen amigaone platform (6xx/book32s), isn't fully supported upstream, and which used the legacy radeon driver together with non-coherent DMA. However this only ever worked reliably for DRI . Remove the hack as it is the

[PATCH v2 26/33] iommu/tegra: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the Tegra IOMMU drivers to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/tegra-gart.c | 24 ++--

[PATCH v2 27/33] iommu/renesas: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the Renesas IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/ipmmu-vmsa.c | 60 +- 1

[PATCH v2 21/33] iommu/msm: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the MSM IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/msm_iommu.c | 34 +++--- 1 file

[PATCH v2 04/33] iommu/vt-d: Wire up iommu_ops->def_domain_type

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel The Intel VT-d driver already has a matching function to determine the default domain type for a device. Wire it up in intel_iommu_ops. Signed-off-by: Joerg Roedel --- drivers/iommu/intel-iommu.c | 1 + 1 file changed, 1 insertion(+) diff --git

[PATCH v2 12/33] iommu: Move iommu_group_create_direct_mappings() out of iommu_group_add_device()

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel After the previous changes the iommu group may not have a default domain when iommu_group_add_device() is called. With no default domain iommu_group_create_direct_mappings() will do nothing and no direct mappings will be created. Rename iommu_group_create_direct_mappings() to

[PATCH v2 14/33] iommu/amd: Remove dev_data->passthrough

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Make use of generic IOMMU infrastructure to gather the same information carried in dev_data->passthrough and remove the struct member. Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 10 +- drivers/iommu/amd_iommu_types.h | 1 - 2 files changed, 5

[PATCH v2 31/33] iommu/exynos: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the Exynos IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/exynos-iommu.c | 26 ++ 1 file changed,

[PATCH v2 24/33] iommu/qcom: Convert to probe/release_device() call-backs

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel Convert the QCOM IOMMU driver to use the probe_device() and release_device() call-backs of iommu_ops, so that the iommu core code does the group and sysfs setup. Signed-off-by: Joerg Roedel --- drivers/iommu/qcom_iommu.c | 24 +++- 1 file changed, 7

[PATCH v2 30/33] iommu/exynos: Use first SYSMMU in controllers list for IOMMU core

2020-04-14 Thread Joerg Roedel
From: Joerg Roedel On Exynos platforms there can be more than one SYSMMU (IOMMU) for one DMA master device. Since the IOMMU core code expects only one hardware IOMMU, use the first SYSMMU in the list. Signed-off-by: Joerg Roedel --- drivers/iommu/exynos-iommu.c | 10 ++ 1 file

[PATCH v2 02/33] iommu: Add def_domain_type() callback in iommu_ops

2020-04-14 Thread Joerg Roedel
From: Sai Praneeth Prakhya Some devices are reqired to use a specific type (identity or dma) of default domain when they are used with a vendor iommu. When the system level default domain type is different from it, the vendor iommu driver has to request a new default domain with

[PATCH 17/29] mm: remove unmap_vmap_area

2020-04-14 Thread Christoph Hellwig
This function just has a single caller, open code it there. Signed-off-by: Christoph Hellwig Acked-by: Peter Zijlstra (Intel) --- mm/vmalloc.c | 10 +- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/mm/vmalloc.c b/mm/vmalloc.c index b0c7cdc8701a..258220b203f1 100644 ---

  1   2   >