[PATCH v3 14/16] iommu/vt-d: Add bind guest PASID support

2019-05-03 Thread Jacob Pan
When supporting guest SVA with emulated IOMMU, the guest PASID table is shadowed in VMM. Updates to guest vIOMMU PASID table will result in PASID cache flush which will be passed down to the host as bind guest PASID calls. For the SL page tables, it will be harvested from device's default domain

[PATCH v3 09/16] iommu: Introduce guest PASID bind function

2019-05-03 Thread Jacob Pan
Guest shared virtual address (SVA) may require host to shadow guest PASID tables. Guest PASID can also be allocated from the host via enlightened interfaces. In this case, guest needs to bind the guest mm, i.e. cr3 in guest physical address to the actual PASID table in the host IOMMU. Nesting will

[PATCH v3 12/16] iommu/vt-d: Add nested translation helper function

2019-05-03 Thread Jacob Pan
Nested translation mode is supported in VT-d 3.0 Spec.CH 3.8. With PASID granular translation type set to 0x11b, translation result from the first level(FL) also subject to a second level(SL) page table translation. This mode is used for SVA virtualization, where FL performs guest virtual to guest

[PATCH v3 15/16] iommu/vt-d: Support flushing more translation cache types

2019-05-03 Thread Jacob Pan
When Shared Virtual Memory is exposed to a guest via vIOMMU, scalable IOTLB invalidation may be passed down from outside IOMMU subsystems. This patch adds invalidation functions that can be used for additional translation cache types. Signed-off-by: Jacob Pan --- drivers/iommu/dmar.c|

[PATCH v3 16/16] iommu/vt-d: Add svm/sva invalidate function

2019-05-03 Thread Jacob Pan
When Shared Virtual Address (SVA) is enabled for a guest OS via vIOMMU, we need to provide invalidation support at IOMMU API and driver level. This patch adds Intel VT-d specific function to implement iommu passdown invalidate API for shared virtual address. The use case is for supporting caching

[PATCH v3 06/16] iommu/vt-d: Add custom allocator for IOASID

2019-05-03 Thread Jacob Pan
When VT-d driver runs in the guest, PASID allocation must be performed via virtual command interface. This patch registers a custom IOASID allocator which takes precedence over the default XArray based allocator. The resulting IOASID allocation will always come from the host. This ensures that

[PATCH v3 01/16] iommu: Introduce attach/detach_pasid_table API

2019-05-03 Thread 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 mappings onto the

[PATCH v3 02/16] iommu: Introduce cache_invalidate API

2019-05-03 Thread Jacob Pan
From: "Liu, Yi L" 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 v3 08/16] iommu/vt-d: Replace Intel specific PASID allocator with IOASID

2019-05-03 Thread Jacob Pan
Make use of generic IOASID code to manage PASID allocation, free, and lookup. Replace Intel specific code. Signed-off-by: Jacob Pan --- drivers/iommu/intel-iommu.c | 11 +-- drivers/iommu/intel-pasid.c | 36 drivers/iommu/intel-svm.c | 37

[PATCH v3 04/16] ioasid: Add custom IOASID allocator

2019-05-03 Thread Jacob Pan
Sometimes, IOASID allocation must be handled by platform specific code. The use cases are guest vIOMMU and pvIOMMU where IOASIDs need to be allocated by the host via enlightened or paravirt interfaces. This patch adds an extension to the IOASID allocator APIs such that platform drivers can

[PATCH v3 07/16] iommu/vtd: Optimize tlb invalidation for vIOMMU

2019-05-03 Thread Jacob Pan
Signed-off-by: Jacob Pan --- drivers/iommu/intel-svm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c index 8f87304..f5d1e1e 100644 --- a/drivers/iommu/intel-svm.c +++ b/drivers/iommu/intel-svm.c @@ -211,7 +211,9 @@

[PATCH v3 11/16] iommu/vt-d: Avoid duplicated code for PASID setup

2019-05-03 Thread Jacob Pan
After each setup for PASID entry, related translation caches must be flushed. We can combine duplicated code into one function which is less error prone. Signed-off-by: Jacob Pan --- drivers/iommu/intel-pasid.c | 48 + 1 file changed, 18

[PATCH v3 13/16] iommu/vt-d: Clean up for SVM device list

2019-05-03 Thread Jacob Pan
Use combined macro for_each_svm_dev() to simplify SVM device iteration. Suggested-by: Andy Shevchenko Signed-off-by: Jacob Pan Reviewed-by: Eric Auger --- drivers/iommu/intel-svm.c | 79 +++ 1 file changed, 39 insertions(+), 40 deletions(-) diff

[PATCH v3 10/16] iommu/vt-d: Move domain helper to header

2019-05-03 Thread Jacob Pan
Move domainer helper to header to be used by SVA code. Signed-off-by: Jacob Pan --- drivers/iommu/intel-iommu.c | 6 -- include/linux/intel-iommu.h | 6 ++ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index

[PATCH v3 03/16] iommu: Add I/O ASID allocator

2019-05-03 Thread Jacob Pan
From: Jean-Philippe Brucker Some devices might support multiple DMA address spaces, in particular those that have the PCI PASID feature. PASID (Process Address Space ID) allows to share process address spaces with devices (SVA), partition a device into VM-assignable entities (VFIO mdev) or

[PATCH v3 00/16] Shared virtual address IOMMU and VT-d support

2019-05-03 Thread Jacob Pan
Shared virtual address (SVA), a.k.a, Shared virtual memory (SVM) on Intel platforms allow address space sharing between device DMA and applications. SVA can reduce programming complexity and enhance security. This series is intended to enable SVA virtualization, i.e. shared guest application

[PATCH v3 05/16] iommu/vt-d: Enlightened PASID allocation

2019-05-03 Thread Jacob Pan
From: Lu Baolu If Intel IOMMU runs in caching mode, a.k.a. virtual IOMMU, the IOMMU driver should rely on the emulation software to allocate and free PASID IDs. The Intel vt-d spec revision 3.0 defines a register set to support this. This includes a capability register, a virtual command

Re: [PATCH v5 2/3] iommu/dma: Reserve IOVA for PCIe inaccessible DMA address

2019-05-03 Thread Lorenzo Pieralisi
On Fri, May 03, 2019 at 10:53:23AM +0530, Srinath Mannam wrote: > Hi Robin, Lorenzo, > > Thanks for review and guidance. > AFAIU, conclusion of discussion is, to return error if dma-ranges list > is not sorted. > > So that, Can I send a new patch with below change to return error if > dma-ranges

Re: [PATCH v5 2/3] iommu/dma: Reserve IOVA for PCIe inaccessible DMA address

2019-05-03 Thread Srinath Mannam via iommu
Hi Robin, On Fri, May 3, 2019 at 3:58 PM Robin Murphy wrote: > > On 03/05/2019 06:23, Srinath Mannam wrote: > > Hi Robin, Lorenzo, > > > > Thanks for review and guidance. > > AFAIU, conclusion of discussion is, to return error if dma-ranges list > > is not sorted. > > > > So that, Can I send a

Re: [PATCH v5 2/3] iommu/dma: Reserve IOVA for PCIe inaccessible DMA address

2019-05-03 Thread Robin Murphy
On 03/05/2019 06:23, Srinath Mannam wrote: Hi Robin, Lorenzo, Thanks for review and guidance. AFAIU, conclusion of discussion is, to return error if dma-ranges list is not sorted. So that, Can I send a new patch with below change to return error if dma-ranges list is not sorted? -static void

Re: [PATCH v5 2/3] iommu/dma: Reserve IOVA for PCIe inaccessible DMA address

2019-05-03 Thread Srinath Mannam via iommu
Hi Lorenzo, Thank you so much, Please see my reply below. On Fri, May 3, 2019 at 3:23 PM Lorenzo Pieralisi wrote: > > On Fri, May 03, 2019 at 10:53:23AM +0530, Srinath Mannam wrote: > > Hi Robin, Lorenzo, > > > > Thanks for review and guidance. > > AFAIU, conclusion of discussion is, to return

Re: [PATCH 04/25] iommu/dma: Remove the flush_page callback

2019-05-03 Thread Catalin Marinas
On Tue, Apr 30, 2019 at 06:51:53AM -0400, Christoph Hellwig wrote: > We now have a arch_dma_prep_coherent architecture hook that is used > for the generic DMA remap allocator, and we should use the same > interface for the dma-iommu code. > > Signed-off-by: Christoph Hellwig > Reviewed-by: Robin

Re: implement generic dma_map_ops for IOMMUs v4

2019-05-03 Thread Catalin Marinas
On Thu, May 02, 2019 at 03:22:08PM +0200, Christoph Hellwig wrote: > can you quickly look over the arm64 parts? I'd really like to still > get this series in for this merge window as it would conflict with > a lot of dma-mapping work for next merge window, and we also have > the amd and possibly

Re: implement generic dma_map_ops for IOMMUs v4

2019-05-03 Thread Christoph Hellwig
On Fri, May 03, 2019 at 12:47:31PM +0100, Catalin Marinas wrote: > On Thu, May 02, 2019 at 03:22:08PM +0200, Christoph Hellwig wrote: > > can you quickly look over the arm64 parts? I'd really like to still > > get this series in for this merge window as it would conflict with > > a lot of

Re: [PATCH 01/25] arm64/iommu: handle non-remapped addresses in ->mmap and ->get_sgtable

2019-05-03 Thread Catalin Marinas
On Tue, Apr 30, 2019 at 06:51:50AM -0400, Christoph Hellwig wrote: > DMA allocations that can't sleep may return non-remapped addresses, but > we do not properly handle them in the mmap and get_sgtable methods. > Resolve non-vmalloc addresses using virt_to_page to handle this corner > case. > >

Re: [PATCH 06/25] iommu/dma: move the arm64 wrappers to common code

2019-05-03 Thread Catalin Marinas
On Tue, Apr 30, 2019 at 06:51:55AM -0400, Christoph Hellwig wrote: > There is nothing really arm64 specific in the iommu_dma_ops > implementation, so move it to dma-iommu.c and keep a lot of symbols > self-contained. Note the implementation does depend on the > DMA_DIRECT_REMAP infrastructure for

Re: [PATCH v3 2/7] iommu/dma-iommu: Split iommu_dma_map_msi_msg() in two parts

2019-05-03 Thread Joerg Roedel
On Wed, May 01, 2019 at 02:58:19PM +0100, Julien Grall wrote: > On RT, iommu_dma_map_msi_msg() may be called from non-preemptible > context. This will lead to a splat with CONFIG_DEBUG_ATOMIC_SLEEP as > the function is using spin_lock (they can sleep on RT). > > iommu_dma_map_msi_msg() is used to

Re: [PATCH v6 0/3] PCIe Host request to reserve IOVA

2019-05-03 Thread Srinath Mannam via iommu
Hi Lorenzo, Thanks a lot. Regards, Srinath. On Fri, May 3, 2019 at 9:23 PM Lorenzo Pieralisi wrote: > > On Fri, May 03, 2019 at 07:35:31PM +0530, Srinath Mannam wrote: > > This patch set will reserve IOVA addresses for DMA memory holes. > > > > The IPROC host controller allows only a few

Re: [PATCH v3 6/7] irqchip/gic-v3-mbi: Don't map the MSI page in mbi_compose_m{b, s}i_msg()

2019-05-03 Thread Robin Murphy
On 03/05/2019 15:27, Marc Zyngier wrote: On 01/05/2019 14:58, Julien Grall wrote: The functions mbi_compose_m{b, s}i_msg may be called from non-preemptible context. However, on RT, iommu_dma_map_msi_msg() requires to be called from a preemptible context. A recent patch split

Re: [PATCH v2] iommu/amd: flush not present cache in iommu_map_page

2019-05-03 Thread Joerg Roedel
On Mon, Apr 29, 2019 at 12:47:02AM +0100, Tom Murphy wrote: > check if there is a not-present cache present and flush it if there is. > > Signed-off-by: Tom Murphy > --- > drivers/iommu/amd_iommu.c | 19 +++ > 1 file changed, 15 insertions(+), 4 deletions(-) Applied, thanks.

Re: [PATCH 0/2] iommu/vt-d: Small fixes for 5.2-rc1

2019-05-03 Thread Joerg Roedel
On Thu, May 02, 2019 at 09:34:24AM +0800, Lu Baolu wrote: > Lu Baolu (2): > iommu/vt-d: Set intel_iommu_gfx_mapped correctly > iommu/vt-d: Make kernel parameter igfx_off work with vIOMMU Applied both, thanks. ___ iommu mailing list

Re: Linux crash when using FTDI FT232R USB to serial converter on AMD boards.

2019-05-03 Thread Joerg Roedel
On Mon, Apr 29, 2019 at 11:48:47AM +0200, Johan Hovold wrote: > So this is a debian 4.18 kernel seemingly crashing due to a xhci or > iommu issue. > > Can you reproduce this on a mainline kernel? > > If so, please post the corresponding logs to the lists and CC the xhci > and iommu maintainers

Re: [PATCH v6 0/3] PCIe Host request to reserve IOVA

2019-05-03 Thread Lorenzo Pieralisi
On Fri, May 03, 2019 at 07:35:31PM +0530, Srinath Mannam wrote: > This patch set will reserve IOVA addresses for DMA memory holes. > > The IPROC host controller allows only a few ranges of physical address > as inbound PCI addresses which are listed through dma-ranges DT property. > Added

Re: [PATCH 02/25] dma-mapping: add a Kconfig symbol to indicated arch_dma_prep_coherent presence

2019-05-03 Thread Catalin Marinas
On Tue, Apr 30, 2019 at 06:51:51AM -0400, Christoph Hellwig wrote: > Add a Kconfig symbol that indicates an architecture provides a > arch_dma_prep_coherent implementation, and provide a stub otherwise. > > This will allow the generic dma-iommu code to use it while still > allowing to be built

Re: [PATCH 04/25] iommu/dma: Remove the flush_page callback

2019-05-03 Thread Catalin Marinas
On Fri, May 03, 2019 at 12:43:35PM +0100, Catalin Marinas wrote: > On Tue, Apr 30, 2019 at 06:51:53AM -0400, Christoph Hellwig wrote: > > We now have a arch_dma_prep_coherent architecture hook that is used > > for the generic DMA remap allocator, and we should use the same > > interface for the

Re: [PATCH 24/25] arm64: switch copyright boilerplace to SPDX in dma-mapping.c

2019-05-03 Thread Catalin Marinas
On Tue, Apr 30, 2019 at 06:52:13AM -0400, Christoph Hellwig wrote: > Signed-off-by: Christoph Hellwig > Acked-by: Robin Murphy > Reviewed-by: Mukesh Ojha Acked-by: Catalin Marinas ___ iommu mailing list iommu@lists.linux-foundation.org

Re: [PATCH 25/25] arm64: trim includes in dma-mapping.c

2019-05-03 Thread Catalin Marinas
On Tue, Apr 30, 2019 at 06:52:14AM -0400, Christoph Hellwig wrote: > With most of the previous functionality now elsewhere a lot of the > headers included in this file are not needed. > > Signed-off-by: Christoph Hellwig Acked-by: Catalin Marinas ___

[PATCH v6 2/3] iommu/dma: Reserve IOVA for PCIe inaccessible DMA address

2019-05-03 Thread Srinath Mannam via iommu
The dma_ranges list field of PCI host bridge structure has resource entries in sorted order representing address ranges allowed for DMA transfers. Process the list and reserve IOVA addresses that are not present in its resource entries (ie DMA memory holes) to prevent allocating IOVA addresses

Re: [PATCH v3 7/7] iommu/dma-iommu: Remove iommu_dma_map_msi_msg()

2019-05-03 Thread Joerg Roedel
On Wed, May 01, 2019 at 02:58:24PM +0100, Julien Grall wrote: > A recent change split iommu_dma_map_msi_msg() in two new functions. The > function was still implemented to avoid modifying all the callers at > once. > > Now that all the callers have been reworked, iommu_dma_map_msi_msg() can > be

[PATCH v6 3/3] PCI: iproc: Add sorted dma ranges resource entries to host bridge

2019-05-03 Thread Srinath Mannam via iommu
The IPROC host controller allows only a subset of physical address space as target of inbound PCI memory transactions addresses. PCIe devices memory transactions targeting memory regions that are not allowed for inbound transactions in the host controller are rejected by the host controller and

[PATCH v6 0/3] PCIe Host request to reserve IOVA

2019-05-03 Thread Srinath Mannam via iommu
This patch set will reserve IOVA addresses for DMA memory holes. The IPROC host controller allows only a few ranges of physical address as inbound PCI addresses which are listed through dma-ranges DT property. Added dma_ranges list field of PCI host bridge structure to hold these allowed inbound

[PATCH v6 1/3] PCI: Add dma_ranges window list

2019-05-03 Thread Srinath Mannam via iommu
Add a dma_ranges field in PCI host bridge structure to hold resource entries list of memory regions in sorted order representing memory ranges that can be accessed through DMA transactions. Based-on-patch-by: Oza Pawandeep Signed-off-by: Srinath Mannam [lorenzo.pieral...@arm.com: updated commit

Re: [PATCH v3 6/7] irqchip/gic-v3-mbi: Don't map the MSI page in mbi_compose_m{b, s}i_msg()

2019-05-03 Thread Marc Zyngier
On 01/05/2019 14:58, Julien Grall wrote: > The functions mbi_compose_m{b, s}i_msg may be called from non-preemptible > context. However, on RT, iommu_dma_map_msi_msg() requires to be called > from a preemptible context. > > A recent patch split iommu_dma_map_msi_msg in two new functions: > one

Re: [PATCH 1/1] iommu/vt-d: Cleanup: no spaces at the start of a line

2019-05-03 Thread Joerg Roedel
On Mon, Apr 29, 2019 at 09:16:02AM +0800, Lu Baolu wrote: > Replace the whitespaces at the start of a line with tabs. No > functional changes. > > Signed-off-by: Lu Baolu > --- > drivers/iommu/intel-iommu.c | 53 +++-- > 1 file changed, 27 insertions(+), 26

Re: [PATCH] iommu/vt-d: Fix leak in intel_pasid_alloc_table on error path

2019-05-03 Thread Joerg Roedel
On Tue, Apr 30, 2019 at 09:30:04AM +0200, Eric Auger wrote: > If alloc_pages_node() fails, pasid_table is leaked. Free it. > > Fixes: cc580e41260db ("iommu/vt-d: Per PCI device pasid table interfaces") > > Signed-off-by: Eric Auger > --- > drivers/iommu/intel-pasid.c | 4 +++- > 1 file

Re: "iommu/amd: Set exclusion range correctly" causes smartpqi offline

2019-05-03 Thread Qian Cai
On Mon, 2019-04-29 at 16:23 +0200, Joerg Roedel wrote: > On Fri, Apr 26, 2019 at 11:55:12AM -0400, Qian Cai wrote: > > https://git.sr.ht/~cai/linux-debug/blob/master/dmesg > > Thanks, I can't see any definitions for unity ranges or exclusion ranges > in the IVRS table dump, which makes it even