[PATCH v15 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing

2021-06-24 Thread Claire Chang
Propagate the swiotlb_force into io_tlb_default_mem->force_bounce and use it to determine whether to bounce the data or not. This will be useful later to allow for different pools. Signed-off-by: Claire Chang Reviewed-by: Christoph Hellwig Tested-by: Stefano Stabellini Tested-by: Will Deacon

Re: [PATCH v14 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing

2021-06-24 Thread Konrad Rzeszutek Wilk
On Thu, Jun 24, 2021 at 10:10:51AM -0400, Qian Cai wrote: > > > On 6/24/2021 7:48 AM, Will Deacon wrote: > > Ok, diff below which attempts to tackle the offset issue I mentioned as > > well. Qian Cai -- please can you try with these changes? > > This works fine. Cool. Let me squash this patch

[PATCH v15 05/12] swiotlb: Update is_swiotlb_active to add a struct device argument

2021-06-24 Thread Claire Chang
Update is_swiotlb_active to add a struct device argument. This will be useful later to allow for different pools. Signed-off-by: Claire Chang Reviewed-by: Christoph Hellwig Tested-by: Stefano Stabellini Tested-by: Will Deacon Acked-by: Stefano Stabellini ---

[PATCH v15 07/12] swiotlb: Move alloc_size to swiotlb_find_slots

2021-06-24 Thread Claire Chang
Rename find_slots to swiotlb_find_slots and move the maintenance of alloc_size to it for better code reusability later. Signed-off-by: Claire Chang Reviewed-by: Christoph Hellwig Tested-by: Stefano Stabellini Tested-by: Will Deacon --- kernel/dma/swiotlb.c | 17 + 1 file

[PATCH v15 08/12] swiotlb: Refactor swiotlb_tbl_unmap_single

2021-06-24 Thread Claire Chang
Add a new function, swiotlb_release_slots, to make the code reusable for supporting different bounce buffer pools. Signed-off-by: Claire Chang Reviewed-by: Christoph Hellwig Tested-by: Stefano Stabellini Tested-by: Will Deacon --- kernel/dma/swiotlb.c | 35 ---

[PATCH v2 2/3] iommu/arm-smmu: Check for strictness after calling impl->init_context()

2021-06-24 Thread Douglas Anderson
Implementations should be able to affect the strictness so reorder a little bit so we call them before we look at the strictness. Signed-off-by: Douglas Anderson --- Changes in v2: - Patch moving check for strictness in arm-smmu new for v2. drivers/iommu/arm/arm-smmu/arm-smmu.c | 6 +++--- 1

[PATCH v2 3/3] mmc: sdhci-msm: Request non-strict IOMMU mode

2021-06-24 Thread Douglas Anderson
The concept of IOMMUs being in strict vs. non-strict mode is a pre-existing Linux concept. I've included a rough summary here to help evaluate this patch. IOMMUs can be run in "strict" mode or in "non-strict" mode. The quick-summary difference between the two is that in "strict" mode we wait

[PATCH v2 0/3] iommu: Enable non-strict DMA on QCom SD/MMC

2021-06-24 Thread Douglas Anderson
The goal of this patch series is to get better SD/MMC performance on Qualcomm eMMC controllers and in generally nudge us forward on the path of allowing some devices to be in strict mode and others to be in non-strict mode. This patch series doesn't save the world but hopefully at least moves us

[PATCH v2 1/3] iommu: Add per-domain strictness and combine with the global default

2021-06-24 Thread Douglas Anderson
Strictness has the semantic of being a per-domain property. This is why iommu_get_dma_strict() takes a "struct iommu_domain" as a parameter. Let's add knowledge to the "struct iommu_domain" so we can know whether we'd like each domain to be strict. In this patch nothing sets the per-domain

Re: [PATCH V3 1/2] dt-bindings: iommu: arm-smmu: Add binding for sm6125

2021-06-24 Thread Rob Herring
On Sat, 12 Jun 2021 11:46:04 +0200, Martin Botka wrote: > This patch adds binding for sm6125 SoC > > Signed-off-by: Martin Botka > --- > Changes in V2: > Add commit description > Changes in V3: > None > Documentation/devicetree/bindings/iommu/arm,smmu.yaml | 1 + > 1 file changed, 1

[PATCH v15 04/12] swiotlb: Update is_swiotlb_buffer to add a struct device argument

2021-06-24 Thread Claire Chang
Update is_swiotlb_buffer to add a struct device argument. This will be useful later to allow for different pools. Signed-off-by: Claire Chang Reviewed-by: Christoph Hellwig Tested-by: Stefano Stabellini Tested-by: Will Deacon Acked-by: Stefano Stabellini --- drivers/iommu/dma-iommu.c | 12

[PATCH v15 02/12] swiotlb: Refactor swiotlb_create_debugfs

2021-06-24 Thread Claire Chang
Split the debugfs creation to make the code reusable for supporting different bounce buffer pools. Signed-off-by: Claire Chang Reviewed-by: Christoph Hellwig Tested-by: Stefano Stabellini Tested-by: Will Deacon --- kernel/dma/swiotlb.c | 21 ++--- 1 file changed, 14

[PATCH v15 12/12] of: Add plumbing for restricted DMA pool

2021-06-24 Thread Claire Chang
If a device is not behind an IOMMU, we look up the device node and set up the restricted DMA when the restricted-dma-pool is presented. Signed-off-by: Claire Chang Tested-by: Stefano Stabellini Tested-by: Will Deacon --- drivers/of/address.c| 33 +

Re: [PATCH 0/6] iommu: Enable devices to request non-strict DMA, starting with QCom SD/MMC

2021-06-24 Thread Doug Anderson
Hi, On Wed, Jun 23, 2021 at 10:29 AM Doug Anderson wrote: > > * Instead of putting the details in per-device nodes, maybe it makes > sense to accept that we should be specifying these things at the IOMMU > level? If specifying things at the device tree level then the > device-tree node of the

[PATCH v15 00/12] Restricted DMA

2021-06-24 Thread Claire Chang
This series implements mitigations for lack of DMA access control on systems without an IOMMU, which could result in the DMA accessing the system memory at unexpected times and/or unexpected addresses, possibly leading to data leakage or corruption. For example, we plan to use the PCI-e bus for

[PATCH v15 01/12] swiotlb: Refactor swiotlb init functions

2021-06-24 Thread Claire Chang
Add a new function, swiotlb_init_io_tlb_mem, for the io_tlb_mem struct initialization to make the code reusable. Signed-off-by: Claire Chang Reviewed-by: Christoph Hellwig Tested-by: Stefano Stabellini Tested-by: Will Deacon Acked-by: Stefano Stabellini --- kernel/dma/swiotlb.c | 50

[PATCH v15 10/12] swiotlb: Add restricted DMA pool initialization

2021-06-24 Thread Claire Chang
Add the initialization function to create restricted DMA pools from matching reserved-memory nodes. Regardless of swiotlb setting, the restricted DMA pool is preferred if available. The restricted DMA pools provide a basic level of protection against the DMA overwriting buffer contents at

[PATCH v15 11/12] dt-bindings: of: Add restricted DMA pool

2021-06-24 Thread Claire Chang
Introduce the new compatible string, restricted-dma-pool, for restricted DMA. One can specify the address and length of the restricted DMA memory region by restricted-dma-pool in the reserved-memory node. Signed-off-by: Claire Chang Tested-by: Stefano Stabellini Tested-by: Will Deacon ---

IOMMU regression in 5.11 kernel related to device removal from PCI topolgy

2021-06-24 Thread Andrey Grodzovsky via iommu
Hello, We are testing AMD GPU removal from PCI topology using sysfs 'remove' hook. We encountered a crash in IOMMU code related to double free. Note that the crash happens without even loading AMD graphic driver - amdgpu. The dmesg with KASAN report and PCI topology is attached here in log. I

[PATCH v15 03/12] swiotlb: Set dev->dma_io_tlb_mem to the swiotlb pool used

2021-06-24 Thread Claire Chang
Always have the pointer to the swiotlb pool used in struct device. This could help simplify the code for other pools. Signed-off-by: Claire Chang Reviewed-by: Christoph Hellwig Tested-by: Stefano Stabellini Tested-by: Will Deacon Acked-by: Stefano Stabellini --- drivers/base/core.c| 4

Re: [PATCH] iommu/arm-smmu-v3: Add default domain quirk for Arm Fast Models

2021-06-24 Thread Andre Przywara
On Fri, 18 Jun 2021 17:24:49 +0100 Robin Murphy wrote: Hi Robin, > Arm Fast Models are still implementing legacy virtio-pci devices behind > the SMMU, which continue to be problematic as "real hardware" devices > (from the point of view of the simulated system) without the mitigating >

Re: [PATCH v14 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing

2021-06-24 Thread Claire Chang
On Thu, Jun 24, 2021 at 11:56 PM Konrad Rzeszutek Wilk wrote: > > On Thu, Jun 24, 2021 at 10:10:51AM -0400, Qian Cai wrote: > > > > > > On 6/24/2021 7:48 AM, Will Deacon wrote: > > > Ok, diff below which attempts to tackle the offset issue I mentioned as > > > well. Qian Cai -- please can you try

Re: [PATCH v15 00/12] Restricted DMA

2021-06-24 Thread Konrad Rzeszutek Wilk
On Thu, Jun 24, 2021 at 11:55:14PM +0800, Claire Chang wrote: > This series implements mitigations for lack of DMA access control on > systems without an IOMMU, which could result in the DMA accessing the > system memory at unexpected times and/or unexpected addresses, possibly > leading to data

[PATCH v15 09/12] swiotlb: Add restricted DMA alloc/free support

2021-06-24 Thread Claire Chang
Add the functions, swiotlb_{alloc,free} and is_swiotlb_for_alloc to support the memory allocation from restricted DMA pool. The restricted DMA pool is preferred if available. Note that since coherent allocation needs remapping, one must set up another device coherent pool by shared-dma-pool and

Re: [PATCH v14 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing

2021-06-24 Thread Konrad Rzeszutek Wilk
On Thu, Jun 24, 2021 at 11:58:57PM +0800, Claire Chang wrote: > On Thu, Jun 24, 2021 at 11:56 PM Konrad Rzeszutek Wilk > wrote: > > > > On Thu, Jun 24, 2021 at 10:10:51AM -0400, Qian Cai wrote: > > > > > > > > > On 6/24/2021 7:48 AM, Will Deacon wrote: > > > > Ok, diff below which attempts to

Re: [PATCH RFC 0/2] dma-pool: allow user to disable atomic pool

2021-06-24 Thread Robin Murphy
On 2021-06-24 10:29, Baoquan He wrote: On 06/24/21 at 08:40am, Christoph Hellwig wrote: So reduce the amount allocated. But the pool is needed for proper operation on systems with memory encryption. And please add the right maintainer or at least mailing list for the code you're touching next

Re: [PATCH v14 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing

2021-06-24 Thread Robin Murphy
On 2021-06-24 07:05, Claire Chang wrote: On Thu, Jun 24, 2021 at 1:43 PM Christoph Hellwig wrote: On Wed, Jun 23, 2021 at 02:44:34PM -0400, Qian Cai wrote: is_swiotlb_force_bounce at /usr/src/linux-next/./include/linux/swiotlb.h:119 is_swiotlb_force_bounce() was the new function introduced

Re: Plan for /dev/ioasid RFC v2

2021-06-24 Thread Jason Gunthorpe
On Thu, Jun 24, 2021 at 02:37:31PM +1000, David Gibson wrote: > On Thu, Jun 17, 2021 at 08:04:38PM -0300, Jason Gunthorpe wrote: > > On Thu, Jun 17, 2021 at 03:02:33PM +1000, David Gibson wrote: > > > > > In other words, do we really have use cases where we need to identify > > > different

Re: [PATCH RFC 0/2] dma-pool: allow user to disable atomic pool

2021-06-24 Thread Christoph Hellwig
On Thu, Jun 24, 2021 at 11:47:31AM +0100, Robin Murphy wrote: > Hmm, I think the Kconfig reshuffle has actually left a slight wrinkle here. > For DMA_DIRECT_REMAP=y we can assume an atomic pool is always needed, since > that was the original behaviour anyway. However the implications of >

Re: [PATCH 2/6] drivers: base: Add bits to struct device to control iommu strictness

2021-06-24 Thread Greg KH
On Mon, Jun 21, 2021 at 04:52:44PM -0700, Douglas Anderson wrote: > How to control the "strictness" of an IOMMU is a bit of a mess right > now. As far as I can tell, right now: > * You can set the default to "non-strict" and some devices (right now, > only PCI devices) can request to run in

Re: [PATCH 6/6] mmc: sdhci-msm: Request non-strict IOMMU mode

2021-06-24 Thread Greg KH
On Mon, Jun 21, 2021 at 04:52:48PM -0700, Douglas Anderson wrote: > IOMMUs can be run in "strict" mode or in "non-strict" mode. The > quick-summary difference between the two is that in "strict" mode we > wait until everything is flushed out when we unmap DMA memory. In > "non-strict" we don't. >

Re: [PATCH 3/6] PCI: Indicate that we want to force strict DMA for untrusted devices

2021-06-24 Thread Greg KH
On Mon, Jun 21, 2021 at 04:52:45PM -0700, Douglas Anderson wrote: > At the moment the generic IOMMU framework reaches into the PCIe device > to check the "untrusted" state and uses this information to figure out > if it should be running the IOMMU in strict or non-strict mode. Let's > instead set

Re: [PATCH v14 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing

2021-06-24 Thread Will Deacon
On Thu, Jun 24, 2021 at 12:14:39PM +0100, Robin Murphy wrote: > On 2021-06-24 07:05, Claire Chang wrote: > > On Thu, Jun 24, 2021 at 1:43 PM Christoph Hellwig wrote: > > > > > > On Wed, Jun 23, 2021 at 02:44:34PM -0400, Qian Cai wrote: > > > > is_swiotlb_force_bounce at > > > >

Re: Plan for /dev/ioasid RFC v2

2021-06-24 Thread Lu Baolu
On 2021/6/24 12:26, David Gibson wrote: On Fri, Jun 18, 2021 at 04:57:40PM +, Tian, Kevin wrote: From: Jason Gunthorpe Sent: Friday, June 18, 2021 8:20 AM On Thu, Jun 17, 2021 at 03:14:52PM -0600, Alex Williamson wrote: I've referred to this as a limitation of type1, that we can't put

Re: Plan for /dev/ioasid RFC v2

2021-06-24 Thread Lu Baolu
On 2021/6/24 12:03, David Gibson wrote: On Fri, Jun 18, 2021 at 01:21:47PM +0800, Lu Baolu wrote: Hi David, On 6/17/21 1:22 PM, David Gibson wrote: The iommu_group can guarantee the isolation among different physical devices (represented by RIDs). But when it comes to sub-devices (ex. mdev or

Re: [PATCH v14 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing

2021-06-24 Thread Qian Cai
On 6/24/2021 7:48 AM, Will Deacon wrote: > Ok, diff below which attempts to tackle the offset issue I mentioned as > well. Qian Cai -- please can you try with these changes? This works fine. > > Will > > --->8 > > diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h > index

Re: [PATCH v14 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing

2021-06-24 Thread Robin Murphy
On 2021-06-24 12:18, Will Deacon wrote: On Thu, Jun 24, 2021 at 12:14:39PM +0100, Robin Murphy wrote: On 2021-06-24 07:05, Claire Chang wrote: On Thu, Jun 24, 2021 at 1:43 PM Christoph Hellwig wrote: On Wed, Jun 23, 2021 at 02:44:34PM -0400, Qian Cai wrote: is_swiotlb_force_bounce at

Re: [PATCH 2/6] drivers: base: Add bits to struct device to control iommu strictness

2021-06-24 Thread Doug Anderson
Hi, On Thu, Jun 24, 2021 at 6:37 AM Greg KH wrote: > > On Mon, Jun 21, 2021 at 04:52:44PM -0700, Douglas Anderson wrote: > > How to control the "strictness" of an IOMMU is a bit of a mess right > > now. As far as I can tell, right now: > > * You can set the default to "non-strict" and some

Re: Plan for /dev/ioasid RFC v2

2021-06-24 Thread Jason Gunthorpe
On Thu, Jun 24, 2021 at 02:29:29PM +1000, David Gibson wrote: > But as I keep saying, some forms of grouping (and DMA aliasing as Alex > mentioned) mean that changing the domain of one device can change the > domain of another device, unavoidably. It may be rare with modern > hardware, but we

Re: [PATCH 1/6] drivers: base: Add the concept of "pre_probe" to drivers

2021-06-24 Thread Greg KH
On Mon, Jun 21, 2021 at 04:52:43PM -0700, Douglas Anderson wrote: > Right now things are a bit awkward if a driver would like a chance to > run before some of the more "automatic" things (pinctrl, DMA, IOMMUs, > ...) happen to a device. This patch aims to fix that problem by > introducing the

Re: [PATCH 3/6] PCI: Indicate that we want to force strict DMA for untrusted devices

2021-06-24 Thread Doug Anderson
Hi, On Thu, Jun 24, 2021 at 6:38 AM Greg KH wrote: > > On Mon, Jun 21, 2021 at 04:52:45PM -0700, Douglas Anderson wrote: > > At the moment the generic IOMMU framework reaches into the PCIe device > > to check the "untrusted" state and uses this information to figure out > > if it should be

Re: [PATCH 6/6] mmc: sdhci-msm: Request non-strict IOMMU mode

2021-06-24 Thread Doug Anderson
Hi, On Thu, Jun 24, 2021 at 6:43 AM Greg KH wrote: > > On Mon, Jun 21, 2021 at 04:52:48PM -0700, Douglas Anderson wrote: > > IOMMUs can be run in "strict" mode or in "non-strict" mode. The > > quick-summary difference between the two is that in "strict" mode we > > wait until everything is

Re: [PATCH v14 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing

2021-06-24 Thread Will Deacon
On Thu, Jun 24, 2021 at 12:34:09PM +0100, Robin Murphy wrote: > On 2021-06-24 12:18, Will Deacon wrote: > > On Thu, Jun 24, 2021 at 12:14:39PM +0100, Robin Murphy wrote: > > > On 2021-06-24 07:05, Claire Chang wrote: > > > > On Thu, Jun 24, 2021 at 1:43 PM Christoph Hellwig wrote: > > > > > > >

Re: Re: [PATCH v8 09/10] vduse: Introduce VDUSE - vDPA Device in Userspace

2021-06-24 Thread Yongji Xie
On Fri, Jun 25, 2021 at 11:09 AM Jason Wang wrote: > > > 在 2021/6/24 下午5:16, Yongji Xie 写道: > > On Thu, Jun 24, 2021 at 4:14 PM Jason Wang wrote: > >> > >> 在 2021/6/24 下午12:46, Yongji Xie 写道: > So we need to deal with both FEATURES_OK and reset, but probably not > DRIVER_OK. > >

Re: [PATCH v8 09/10] vduse: Introduce VDUSE - vDPA Device in Userspace

2021-06-24 Thread Jason Wang
在 2021/6/24 下午5:16, Yongji Xie 写道: On Thu, Jun 24, 2021 at 4:14 PM Jason Wang wrote: 在 2021/6/24 下午12:46, Yongji Xie 写道: So we need to deal with both FEATURES_OK and reset, but probably not DRIVER_OK. OK, I see. Thanks for the explanation. One more question is how about clearing the

Re: [PATCH v5 3/5] drm/msm: Improve the a6xx page fault handler

2021-06-24 Thread Bjorn Andersson
On Thu 10 Jun 16:44 CDT 2021, Rob Clark wrote: [..] > diff --git a/drivers/gpu/drm/msm/msm_iommu.c b/drivers/gpu/drm/msm/msm_iommu.c > index 50d881794758..6975b95c3c29 100644 > --- a/drivers/gpu/drm/msm/msm_iommu.c > +++ b/drivers/gpu/drm/msm/msm_iommu.c > @@ -211,8 +211,17 @@ static int

Re: [PATCH v2 3/3] mmc: sdhci-msm: Request non-strict IOMMU mode

2021-06-24 Thread Doug Anderson
Hi, On Thu, Jun 24, 2021 at 10:18 AM Douglas Anderson wrote: > > The concept of IOMMUs being in strict vs. non-strict mode is a > pre-existing Linux concept. I've included a rough summary here to help > evaluate this patch. > > IOMMUs can be run in "strict" mode or in "non-strict" mode. The >

Re: [PATCH v15 00/12] Restricted DMA

2021-06-24 Thread Claire Chang
On Fri, Jun 25, 2021 at 3:20 AM Konrad Rzeszutek Wilk wrote: > > On Thu, Jun 24, 2021 at 11:55:14PM +0800, Claire Chang wrote: > > This series implements mitigations for lack of DMA access control on > > systems without an IOMMU, which could result in the DMA accessing the > > system memory at

Re: [PATCH v8 09/10] vduse: Introduce VDUSE - vDPA Device in Userspace

2021-06-24 Thread Jason Wang
在 2021/6/24 下午12:46, Yongji Xie 写道: So we need to deal with both FEATURES_OK and reset, but probably not DRIVER_OK. OK, I see. Thanks for the explanation. One more question is how about clearing the corresponding status bit in get_status() rather than making set_status() fail. Since the spec

Re: [PATCH RFC 0/2] dma-pool: allow user to disable atomic pool

2021-06-24 Thread Baoquan He
On 06/24/21 at 08:40am, Christoph Hellwig wrote: > So reduce the amount allocated. But the pool is needed for proper > operation on systems with memory encryption. And please add the right > maintainer or at least mailing list for the code you're touching next > time. Oh, I thoutht it's memory

Re: Re: [PATCH v8 09/10] vduse: Introduce VDUSE - vDPA Device in Userspace

2021-06-24 Thread Yongji Xie
On Thu, Jun 24, 2021 at 4:14 PM Jason Wang wrote: > > > 在 2021/6/24 下午12:46, Yongji Xie 写道: > >> So we need to deal with both FEATURES_OK and reset, but probably not > >> DRIVER_OK. > >> > > OK, I see. Thanks for the explanation. One more question is how about > > clearing the corresponding

Re: [PATCH v14 06/12] swiotlb: Use is_swiotlb_force_bounce for swiotlb data bouncing

2021-06-24 Thread Claire Chang
On Thu, Jun 24, 2021 at 1:43 PM Christoph Hellwig wrote: > > On Wed, Jun 23, 2021 at 02:44:34PM -0400, Qian Cai wrote: > > is_swiotlb_force_bounce at /usr/src/linux-next/./include/linux/swiotlb.h:119 > > > > is_swiotlb_force_bounce() was the new function introduced in this patch > > here. > > >