Re: [PATCH v4 6/9] iommu/vt-d: Per PCI device pasid table interfaces

2018-07-11 Thread Lu Baolu
Hi, On 07/11/2018 10:18 AM, Peter Xu wrote: > On Mon, Jul 09, 2018 at 01:22:55PM +0800, Lu Baolu wrote: >> This patch adds the interfaces for per PCI device pasid >> table management. Currently we allocate one pasid table >> for all PCI devices under the scope of an IOMMU. It's >> insecure in some

Re: [PATCH 1/2] mm/cma: remove unsupported gfp_mask parameter from cma_alloc()

2018-07-11 Thread Joonsoo Kim
2018-07-10 18:50 GMT+09:00 Michal Hocko : > On Tue 10-07-18 16:19:32, Joonsoo Kim wrote: >> Hello, Marek. >> >> 2018-07-09 21:19 GMT+09:00 Marek Szyprowski : >> > cma_alloc() function doesn't really support gfp flags other than >> > __GFP_NOWARN, so convert gfp_mask parameter to boolean no_warn par

Re: [PATCH v4 6/9] iommu/vt-d: Per PCI device pasid table interfaces

2018-07-11 Thread Peter Xu
On Wed, Jul 11, 2018 at 03:26:21PM +0800, Lu Baolu wrote: [...] > >> +int intel_pasid_alloc_table(struct device *dev) > >> +{ > >> + struct device_domain_info *info; > >> + struct pasid_table *pasid_table; > >> + struct pasid_table_opaque data; > >> + struct page *pages; > >> + size_t size,

Re: [PATCH 1/2] mm/cma: remove unsupported gfp_mask parameter from cma_alloc()

2018-07-11 Thread Michal Hocko
On Wed 11-07-18 16:35:28, Joonsoo Kim wrote: > 2018-07-10 18:50 GMT+09:00 Michal Hocko : > > On Tue 10-07-18 16:19:32, Joonsoo Kim wrote: > >> Hello, Marek. > >> > >> 2018-07-09 21:19 GMT+09:00 Marek Szyprowski : > >> > cma_alloc() function doesn't really support gfp flags other than > >> > __GFP_N

Re: [PATCH v12 1/4] iommu/arm-smmu: Add pm_runtime/sleep ops

2018-07-11 Thread Rafael J. Wysocki
On Sunday, July 8, 2018 7:34:10 PM CEST Vivek Gautam wrote: > From: Sricharan R > > The smmu needs to be functional only when the respective > master's using it are active. The device_link feature > helps to track such functional dependencies, so that the > iommu gets powered when the master devi

Re: [PATCH v12 2/4] iommu/arm-smmu: Invoke pm_runtime during probe, add/remove device

2018-07-11 Thread Rafael J. Wysocki
On Sunday, July 8, 2018 7:34:11 PM CEST Vivek Gautam wrote: > From: Sricharan R > > The smmu device probe/remove and add/remove master device callbacks > gets called when the smmu is not linked to its master, that is without > the context of the master device. So calling runtime apis in those pla

Re: [PATCH v12 3/4] iommu/arm-smmu: Add the device_link between masters and smmu

2018-07-11 Thread Rafael J. Wysocki
On Sunday, July 8, 2018 7:34:12 PM CEST Vivek Gautam wrote: > From: Sricharan R > > Finally add the device link between the master device and > smmu, so that the smmu gets runtime enabled/disabled only when the > master needs it. This is done from add_device callback which gets > called once when

Re: [PATCH v12 2/4] iommu/arm-smmu: Invoke pm_runtime during probe, add/remove device

2018-07-11 Thread Tomasz Figa
Hi Rafael, Thanks for review. On Wed, Jul 11, 2018 at 6:53 PM Rafael J. Wysocki wrote: > > On Sunday, July 8, 2018 7:34:11 PM CEST Vivek Gautam wrote: > > From: Sricharan R > > > > The smmu device probe/remove and add/remove master device callbacks > > gets called when the smmu is not linked to

Re: [PATCH v12 3/4] iommu/arm-smmu: Add the device_link between masters and smmu

2018-07-11 Thread Vivek Gautam
Hi Rafael, On 7/11/2018 3:23 PM, Rafael J. Wysocki wrote: On Sunday, July 8, 2018 7:34:12 PM CEST Vivek Gautam wrote: From: Sricharan R Finally add the device link between the master device and smmu, so that the smmu gets runtime enabled/disabled only when the master needs it. This is done f

Re: [PATCH v12 1/4] iommu/arm-smmu: Add pm_runtime/sleep ops

2018-07-11 Thread Vivek Gautam
Hi Rafael, On Wed, Jul 11, 2018 at 3:20 PM, Rafael J. Wysocki wrote: > On Sunday, July 8, 2018 7:34:10 PM CEST Vivek Gautam wrote: >> From: Sricharan R >> >> The smmu needs to be functional only when the respective >> master's using it are active. The device_link feature >> helps to track such

Re: [PATCH v12 2/4] iommu/arm-smmu: Invoke pm_runtime during probe, add/remove device

2018-07-11 Thread Rafael J. Wysocki
On Wed, Jul 11, 2018 at 12:05 PM, Tomasz Figa wrote: > Hi Rafael, > > Thanks for review. > > On Wed, Jul 11, 2018 at 6:53 PM Rafael J. Wysocki wrote: >> >> On Sunday, July 8, 2018 7:34:11 PM CEST Vivek Gautam wrote: >> > From: Sricharan R >> > >> > The smmu device probe/remove and add/remove mas

Re: [PATCH v12 1/4] iommu/arm-smmu: Add pm_runtime/sleep ops

2018-07-11 Thread Rafael J. Wysocki
On Wed, Jul 11, 2018 at 12:55 PM, Vivek Gautam wrote: > Hi Rafael, > > > On Wed, Jul 11, 2018 at 3:20 PM, Rafael J. Wysocki wrote: >> On Sunday, July 8, 2018 7:34:10 PM CEST Vivek Gautam wrote: >>> From: Sricharan R >>> >>> The smmu needs to be functional only when the respective >>> master's us

Re: [PATCH v12 2/4] iommu/arm-smmu: Invoke pm_runtime during probe, add/remove device

2018-07-11 Thread Vivek Gautam
On 7/11/2018 4:29 PM, Rafael J. Wysocki wrote: On Wed, Jul 11, 2018 at 12:05 PM, Tomasz Figa wrote: Hi Rafael, Thanks for review. On Wed, Jul 11, 2018 at 6:53 PM Rafael J. Wysocki wrote: On Sunday, July 8, 2018 7:34:11 PM CEST Vivek Gautam wrote: From: Sricharan R The smmu device probe

Re: [PATCH 12/25] MIPS: loongson: untangle dma implementations

2018-07-11 Thread Christoph Hellwig
On Wed, Jul 11, 2018 at 01:46:31PM +0100, Maciej W. Rozycki wrote: > > Only loongson-3 is DMA coherent and uses swiotlb. So move the dma > > address translations stubs directly to the loongson-3 code, and remove > > a few Kconfig indirections. > > SiByte should too though, at least for those boa

Re: [PATCH v12 1/4] iommu/arm-smmu: Add pm_runtime/sleep ops

2018-07-11 Thread Tomasz Figa
On Wed, Jul 11, 2018 at 8:11 PM Rafael J. Wysocki wrote: > > On Wed, Jul 11, 2018 at 12:55 PM, Vivek Gautam > wrote: > > Hi Rafael, > > > > > > On Wed, Jul 11, 2018 at 3:20 PM, Rafael J. Wysocki > > wrote: > >> On Sunday, July 8, 2018 7:34:10 PM CEST Vivek Gautam wrote: > >>> From: Sricharan R

Re: [PATCH 12/25] MIPS: loongson: untangle dma implementations

2018-07-11 Thread Maciej W. Rozycki
On Fri, 25 May 2018, Christoph Hellwig wrote: > Only loongson-3 is DMA coherent and uses swiotlb. So move the dma > address translations stubs directly to the loongson-3 code, and remove > a few Kconfig indirections. SiByte should too though, at least for those boards, such as the SWARM and th

Re: [PATCH 12/25] MIPS: loongson: untangle dma implementations

2018-07-11 Thread Maciej W. Rozycki
On Wed, 11 Jul 2018, Christoph Hellwig wrote: > > SiByte should too though, at least for those boards, such as the SWARM > > and the BigSur, that can have DRAM over 4GiB (and 32-bit PCI devices > > plugged). > > Only in this case refers to loonson boards. Right! > > I never got to have the

Re: [PATCH v12 1/4] iommu/arm-smmu: Add pm_runtime/sleep ops

2018-07-11 Thread Marek Szyprowski
Hi Tomasz, On 2018-07-11 14:51, Tomasz Figa wrote: > On Wed, Jul 11, 2018 at 8:11 PM Rafael J. Wysocki wrote: >> On Wed, Jul 11, 2018 at 12:55 PM, Vivek Gautam >> wrote: >>> On Wed, Jul 11, 2018 at 3:20 PM, Rafael J. Wysocki >>> wrote: On Sunday, July 8, 2018 7:34:10 PM CEST Vivek Gautam

Re: [RFC PATCH 0/4] Stop losing firmware-set DMA masks

2018-07-11 Thread Rob Herring
On Tue, Jul 10, 2018 at 12:43 PM Robin Murphy wrote: > > Whilst the common firmware code invoked by dma_configure() initialises > devices' DMA masks according to limitations described by the respective > properties ("dma-ranges" for OF and _DMA/IORT for ACPI), the nature of > the dma_set_mask() AP

Re: [PATCH] nios2: use generic dma_noncoherent_ops

2018-07-11 Thread Christoph Hellwig
ping? Any comments? On Tue, Jun 19, 2018 at 09:01:37AM +0200, Christoph Hellwig wrote: > Switch to the generic noncoherent direct mapping implementation. > > Signed-off-by: Christoph Hellwig > --- > arch/nios2/Kconfig | 3 + > arch/nios2/include/asm/Kbuild| 1 + >

Re: [PATCH] xtensa: use generic dma_noncoherent_ops

2018-07-11 Thread Christoph Hellwig
ping? Any comments? On Tue, Jun 19, 2018 at 09:03:16AM +0200, Christoph Hellwig wrote: > Switch to the generic noncoherent direct mapping implementation. > > Signed-off-by: Christoph Hellwig > --- > arch/xtensa/Kconfig | 3 + > arch/xtensa/include/asm/Kbuild| 1 +

Re: convert parisc to the generic dma-noncoherent code

2018-07-11 Thread Christoph Hellwig
ping? Any comments? On Tue, Jun 19, 2018 at 09:04:52AM +0200, Christoph Hellwig wrote: > This should address all the comments raised last time. > > > ___ > iommu mailing list > iommu@lists.linux-foundation.org > https://lists.linuxfoundation.org/mailm

Re: [RFC PATCH 0/4] Stop losing firmware-set DMA masks

2018-07-11 Thread Robin Murphy
On 11/07/18 15:40, Rob Herring wrote: On Tue, Jul 10, 2018 at 12:43 PM Robin Murphy wrote: Whilst the common firmware code invoked by dma_configure() initialises devices' DMA masks according to limitations described by the respective properties ("dma-ranges" for OF and _DMA/IORT for ACPI), the

Re: [RFC PATCH 1/4] dma-mapping: Generalise dma_32bit_limit flag

2018-07-11 Thread Robin Murphy
On 10/07/18 19:04, Christoph Hellwig wrote: On Tue, Jul 10, 2018 at 06:17:16PM +0100, Robin Murphy wrote: diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index 8be8106270c2..95e185347e34 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c @@ -183,7 +183,7 @@ int dma_direct_supporte

Re: [PATCH] xtensa: use generic dma_noncoherent_ops

2018-07-11 Thread Christoph Hellwig
On Wed, Jul 11, 2018 at 10:57:30AM -0700, Max Filippov wrote: > > config XTENSA > > def_bool y > > select ARCH_NO_COHERENT_DMA_MMAP if !MMU > > + select ARCH_HAS_SYNC_DMA_FOR_CPU > > + select ARCH_HAS_SYNC_DMA_FOR_DEVICE > > This breaks alphabetical order of selects. O

Re: [PATCH] xtensa: use generic dma_noncoherent_ops

2018-07-11 Thread Max Filippov
Hi Christoph, On Tue, Jun 19, 2018 at 12:03 AM, Christoph Hellwig wrote: > Switch to the generic noncoherent direct mapping implementation. > > Signed-off-by: Christoph Hellwig > --- > arch/xtensa/Kconfig | 3 + > arch/xtensa/include/asm/Kbuild| 1 + > arch/xtensa/

Re: [RFC PATCH 2/4] ACPI/IORT: Set bus DMA mask as appropriate

2018-07-11 Thread Robin Murphy
On 10/07/18 19:04, Christoph Hellwig wrote: On Tue, Jul 10, 2018 at 06:17:17PM +0100, Robin Murphy wrote: When an explicit DMA limit is described by firmware, we need to remember it regardless of how drivers might subsequently update their devices' masks. The new bus_dma_mask field does that.

Re: [PATCH] xtensa: use generic dma_noncoherent_ops

2018-07-11 Thread Max Filippov
On Wed, Jul 11, 2018 at 11:00 AM, Christoph Hellwig wrote: > On Wed, Jul 11, 2018 at 10:57:30AM -0700, Max Filippov wrote: >> > config XTENSA >> > def_bool y >> > select ARCH_NO_COHERENT_DMA_MMAP if !MMU >> > + select ARCH_HAS_SYNC_DMA_FOR_CPU >> > + select ARCH_HAS_SY

Re: [PATCH] swiotlb: Clean up reporting

2018-07-11 Thread Konrad Rzeszutek Wilk
On Tue, Jul 10, 2018 at 04:22:22PM -0700, Kees Cook wrote: > This removes needless use of '%p', and refactors the printk calls to > use pr_*() helpers instead. > > Signed-off-by: Kees Cook Reviewed-by: Konrad Rzeszutek Wilk Christoph, volunteered to pick this patch up in his tree. Thank you! >

Re: [PATCH v12 1/4] iommu/arm-smmu: Add pm_runtime/sleep ops

2018-07-11 Thread Rafael J. Wysocki
On Wed, Jul 11, 2018 at 3:40 PM, Marek Szyprowski wrote: > Hi Tomasz, > > On 2018-07-11 14:51, Tomasz Figa wrote: >> On Wed, Jul 11, 2018 at 8:11 PM Rafael J. Wysocki wrote: >>> On Wed, Jul 11, 2018 at 12:55 PM, Vivek Gautam >>> wrote: On Wed, Jul 11, 2018 at 3:20 PM, Rafael J. Wysocki >>

[PATCH 1/2] iommu: Add config option to set passthrough as default

2018-07-11 Thread Olof Johansson
This allows the default behavior to be controlled by a kernel config option instead of changing the commandline for the kernel to include "iommu.passthrough=on" on machines where this is desired. Signed-off-by: Olof Johansson --- drivers/iommu/Kconfig | 10 ++ drivers/iommu/iommu.c | 4

[PATCH 2/2] iommu: add sysfs attribyte for domain type

2018-07-11 Thread Olof Johansson
While we could print it at setup time, this is an easier way to match each device to their default IOMMU allocation type. Signed-off-by: Olof Johansson --- drivers/iommu/iommu.c | 32 1 file changed, 32 insertions(+) diff --git a/drivers/iommu/iommu.c b/drivers/

Re: [PATCH 1/2] iommu: Add config option to set passthrough as default

2018-07-11 Thread Yang, Shunyong
Hi, Olof, Tired of changing command line. I like this patch. Thanks. Shunyong.  On Wed, 2018-07-11 at 13:59 -0700, Olof Johansson wrote: > This allows the default behavior to be controlled by a kernel config > option instead of changing the commandline for the kernel to include > "iommu.passthro

Re: [PATCH 1/2] mm/cma: remove unsupported gfp_mask parameter from cma_alloc()

2018-07-11 Thread Joonsoo Kim
2018-07-11 17:54 GMT+09:00 Michal Hocko : > On Wed 11-07-18 16:35:28, Joonsoo Kim wrote: >> 2018-07-10 18:50 GMT+09:00 Michal Hocko : >> > On Tue 10-07-18 16:19:32, Joonsoo Kim wrote: >> >> Hello, Marek. >> >> >> >> 2018-07-09 21:19 GMT+09:00 Marek Szyprowski : >> >> > cma_alloc() function doesn't

[PATCH v3 3/6] iommu/amd: use default branch to deal with all non-supported capabilities

2018-07-11 Thread Zhen Lei
Avoid below warning when new capabilities added: drivers/iommu/amd_iommu.c: In function 'amd_iommu_capable': drivers/iommu/amd_iommu.c:3053:2: warning: enumeration value 'IOMMU_CAP_NON_STRICT' not handled in switch [-Wswitch] switch (cap) { Signed-off-by: Zhen Lei --- drivers/iommu/amd_io

[PATCH v3 4/6] iommu/io-pgtable-arm: add support for non-strict mode

2018-07-11 Thread Zhen Lei
To support the non-strict mode, now we only tlbi and sync for the strict mode. But for the non-leaf case, always follow strict mode. Use the lowest bit of the iova parameter to pass the strict mode: 0, IOMMU_STRICT; 1, IOMMU_NON_STRICT; Treat 0 as IOMMU_STRICT, so that the unmap operation can comp

[PATCH v3 5/6] iommu/arm-smmu-v3: add support for non-strict mode

2018-07-11 Thread Zhen Lei
1. Add IOMMU_CAP_NON_STRICT capability. 2. Dynamic choose strict or non-strict mode base on the iommu domain type. Signed-off-by: Zhen Lei --- drivers/iommu/arm-smmu-v3.c | 6 -- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smm

[PATCH v3 0/6] add non-strict mode support for arm-smmu-v3

2018-07-11 Thread Zhen Lei
v2 -> v3: Add a bootup option "iommu_strict_mode" to make the manager can choose which mode to be used. The first 5 patches have not changed. + iommu_strict_mode= [arm-smmu-v3] + 0 - strict mode (default) + 1 - non-strict mode v1 -> v2: Use the lowest bit of

[PATCH v3 1/6] iommu/arm-smmu-v3: fix the implementation of flush_iotlb_all hook

2018-07-11 Thread Zhen Lei
.flush_iotlb_all can not just wait for previous tlbi operations to be completed, but should also invalid all TLBs of the related domain. Signed-off-by: Zhen Lei --- drivers/iommu/arm-smmu-v3.c | 10 +- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/arm-smmu-v3

[PATCH v3 2/6] iommu/dma: add support for non-strict mode

2018-07-11 Thread Zhen Lei
1. Save the related domain pointer in struct iommu_dma_cookie, make iovad capable call domain->ops->flush_iotlb_all to flush TLB. 2. Add a new iommu capability: IOMMU_CAP_NON_STRICT, which used to indicate that the iommu domain support non-strict mode. 3. During the iommu domain initializatio

[PATCH v3 6/6] iommu/arm-smmu-v3: add bootup option "iommu_strict_mode"

2018-07-11 Thread Zhen Lei
Because the non-strict mode introduces a vulnerability window, so add a bootup option to make the manager can choose which mode to be used. The default mode is IOMMU_STRICT. Signed-off-by: Zhen Lei --- Documentation/admin-guide/kernel-parameters.txt | 12 ++ drivers/iommu/arm-smmu-v3.c