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

2021-06-15 Thread Christoph Hellwig
On Wed, Jun 16, 2021 at 01:10:02PM +0800, Claire Chang wrote: > On Wed, Jun 16, 2021 at 12:59 PM Christoph Hellwig wrote: > > > > On Wed, Jun 16, 2021 at 12:04:16PM +0800, Claire Chang wrote: > > > Just noticed that after propagating swiotlb_force setting into > > > io_tlb_default_mem->force, the

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

2021-06-15 Thread Claire Chang
On Wed, Jun 16, 2021 at 12:59 PM Christoph Hellwig wrote: > > On Wed, Jun 16, 2021 at 12:04:16PM +0800, Claire Chang wrote: > > Just noticed that after propagating swiotlb_force setting into > > io_tlb_default_mem->force, the memory allocation behavior for > > swiotlb_force will change (i.e.

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

2021-06-15 Thread Christoph Hellwig
On Wed, Jun 16, 2021 at 12:04:16PM +0800, Claire Chang wrote: > Just noticed that after propagating swiotlb_force setting into > io_tlb_default_mem->force, the memory allocation behavior for > swiotlb_force will change (i.e. always skipping arch_dma_alloc and > dma_direct_alloc_from_pool). Yes, I

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

2021-06-15 Thread Claire Chang
On Wed, Jun 16, 2021 at 11:54 AM Claire Chang wrote: > > Add the functions, swiotlb_{alloc,free} 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

Re: [PATCH v10 00/12] Restricted DMA

2021-06-15 Thread Claire Chang
v11 https://lore.kernel.org/patchwork/cover/1447216/ On Tue, Jun 15, 2021 at 9:27 PM 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

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

2021-06-15 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 --- drivers/of/address.c| 33 + drivers/of/device.c | 3 +++ drivers/of/of_private.h | 6

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

2021-06-15 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 --- .../reserved-memory/reserved-memory.txt | 36

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

2021-06-15 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 v11 09/12] swiotlb: Add restricted DMA alloc/free support

2021-06-15 Thread Claire Chang
Add the functions, swiotlb_{alloc,free} 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 use

[PATCH v11 08/12] swiotlb: Refactor swiotlb_tbl_unmap_single

2021-06-15 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 --- kernel/dma/swiotlb.c | 35 --- 1 file changed, 20 insertions(+), 15 deletions(-)

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

2021-06-15 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 --- kernel/dma/swiotlb.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git

[PATCH v11 06/12] swiotlb: Use is_dev_swiotlb_force for swiotlb data bouncing

2021-06-15 Thread Claire Chang
Propagate the swiotlb_force setting into io_tlb_default_mem->force 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 --- include/linux/swiotlb.h | 11 +++

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

2021-06-15 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 --- drivers/gpu/drm/i915/gem/i915_gem_internal.c | 2 +- drivers/gpu/drm/nouveau/nouveau_ttm.c| 2 +-

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

2021-06-15 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 --- drivers/iommu/dma-iommu.c | 12 ++-- drivers/xen/swiotlb-xen.c | 2 +- include/linux/swiotlb.h | 7

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

2021-06-15 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 --- drivers/base/core.c| 4 include/linux/device.h | 4 kernel/dma/swiotlb.c | 8 3 files

[PATCH v11 02/12] swiotlb: Refactor swiotlb_create_debugfs

2021-06-15 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 --- kernel/dma/swiotlb.c | 21 ++--- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/kernel/dma/swiotlb.c

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

2021-06-15 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 --- kernel/dma/swiotlb.c | 49 ++-- 1 file changed, 24 insertions(+), 25

[PATCH v11 00/12] Restricted DMA

2021-06-15 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

Re: [PATCH 1/1] iommu/arm-smmu-v3: remove unnecessary oom message

2021-06-15 Thread Leizhen (ThunderTown)
On 2021/6/15 19:55, Will Deacon wrote: > On Tue, Jun 15, 2021 at 12:51:38PM +0100, Robin Murphy wrote: >> On 2021-06-15 12:34, Will Deacon wrote: >>> On Tue, Jun 15, 2021 at 07:22:10PM +0800, Leizhen (ThunderTown) wrote: On 2021/6/11 18:32, Will Deacon wrote: > On Wed, Jun

RE: [RFC] /dev/ioasid uAPI proposal

2021-06-15 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Wednesday, June 16, 2021 7:59 AM > > On Tue, Jun 15, 2021 at 11:56:28PM +, Tian, Kevin wrote: > > > From: Jason Gunthorpe > > > Sent: Wednesday, June 16, 2021 7:41 AM > > > > > > On Tue, Jun 15, 2021 at 11:09:37PM +, Tian, Kevin wrote: > > > > > > > which

Re: [RFC] /dev/ioasid uAPI proposal

2021-06-15 Thread Jason Gunthorpe
On Tue, Jun 15, 2021 at 11:56:28PM +, Tian, Kevin wrote: > > From: Jason Gunthorpe > > Sent: Wednesday, June 16, 2021 7:41 AM > > > > On Tue, Jun 15, 2021 at 11:09:37PM +, Tian, Kevin wrote: > > > > > which information can you elaborate? This is the area which I'm not > > > familiar

RE: [RFC] /dev/ioasid uAPI proposal

2021-06-15 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Wednesday, June 16, 2021 7:41 AM > > On Tue, Jun 15, 2021 at 11:09:37PM +, Tian, Kevin wrote: > > > which information can you elaborate? This is the area which I'm not > > familiar with thus would appreciate if you can help explain how this > > bus specific

Re: [RFC] /dev/ioasid uAPI proposal

2021-06-15 Thread Jason Gunthorpe
On Tue, Jun 15, 2021 at 11:09:37PM +, Tian, Kevin wrote: > which information can you elaborate? This is the area which I'm not > familiar with thus would appreciate if you can help explain how this > bus specific information is utilized within the attach function or > sometime later. This

RE: [RFC] /dev/ioasid uAPI proposal

2021-06-15 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Wednesday, June 16, 2021 7:02 AM > > On Tue, Jun 15, 2021 at 10:59:06PM +, Tian, Kevin wrote: > > > From: Jason Gunthorpe > > > Sent: Tuesday, June 15, 2021 11:07 PM > > > > > > On Tue, Jun 15, 2021 at 08:59:25AM +, Tian, Kevin wrote: > > > > Hi, Jason, >

Re: [RFC] /dev/ioasid uAPI proposal

2021-06-15 Thread Jason Gunthorpe
On Tue, Jun 15, 2021 at 10:59:06PM +, Tian, Kevin wrote: > > From: Jason Gunthorpe > > Sent: Tuesday, June 15, 2021 11:07 PM > > > > On Tue, Jun 15, 2021 at 08:59:25AM +, Tian, Kevin wrote: > > > Hi, Jason, > > > > > > > From: Jason Gunthorpe > > > > Sent: Thursday, June 3, 2021 9:05 PM

RE: [RFC] /dev/ioasid uAPI proposal

2021-06-15 Thread Tian, Kevin
> From: Jason Gunthorpe > Sent: Tuesday, June 15, 2021 11:07 PM > > On Tue, Jun 15, 2021 at 08:59:25AM +, Tian, Kevin wrote: > > Hi, Jason, > > > > > From: Jason Gunthorpe > > > Sent: Thursday, June 3, 2021 9:05 PM > > > > > > On Thu, Jun 03, 2021 at 06:39:30AM +, Tian, Kevin wrote: > >

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

2021-06-15 Thread Konrad Rzeszutek Wilk
On Tue, Jun 15, 2021 at 09:27:02PM +0800, Claire Chang wrote: > Always have the pointer to the swiotlb pool used in struct device. This > could help simplify the code for other pools. Applying: swiotlb: Set dev->dma_io_tlb_mem to the swiotlb pool used error: patch failed: kernel/dma/swiotlb.c:339

Re: [PATCH v3 3/9] iommu/arm-smmu: Implement ->probe_finalize()

2021-06-15 Thread Will Deacon
On Tue, Jun 15, 2021 at 07:21:35PM +0100, Will Deacon wrote: > On Tue, Jun 15, 2021 at 06:12:13PM +, Krishna Reddy wrote: > > > if (smmu->impl->probe_finalize) > > > > The above is the issue. It should be updated as below similar to other > > instances impl callbacks. > > if (smmu->impl &&

Re: [PATCH v3 5/6] iommu/amd: Tailored gather logic for AMD

2021-06-15 Thread Nadav Amit
> On Jun 15, 2021, at 12:20 PM, Robin Murphy wrote: > > On 2021-06-15 19:14, Nadav Amit wrote: >>> On Jun 15, 2021, at 5:55 AM, Robin Murphy wrote: >>> >>> On 2021-06-07 19:25, Nadav Amit wrote: From: Nadav Amit AMD's IOMMU can flush efficiently (i.e., in a single flush) any

Re: [PATCH v3 2/6] iommu/amd: Do not use flush-queue when NpCache is on

2021-06-15 Thread Robin Murphy
On 2021-06-15 19:26, Nadav Amit wrote: On Jun 15, 2021, at 6:08 AM, Robin Murphy wrote: On 2021-06-07 19:25, Nadav Amit wrote: From: Nadav Amit Do not use flush-queue on virtualized environments, where the NpCache capability of the IOMMU is set. This is required to reduce virtualization

Re: [PATCH v3 5/6] iommu/amd: Tailored gather logic for AMD

2021-06-15 Thread Robin Murphy
On 2021-06-15 19:14, Nadav Amit wrote: On Jun 15, 2021, at 5:55 AM, Robin Murphy wrote: On 2021-06-07 19:25, Nadav Amit wrote: From: Nadav Amit AMD's IOMMU can flush efficiently (i.e., in a single flush) any range. This is in contrast, for instnace, to Intel IOMMUs that have a limit on

Re: [PATCH 1/1] iommu/arm-smmu-v3: remove unnecessary oom message

2021-06-15 Thread Will Deacon
On Wed, 9 Jun 2021 20:54:38 +0800, Zhen Lei wrote: > Fixes scripts/checkpatch.pl warning: > WARNING: Possible unnecessary 'out of memory' message > > Remove it can help us save a bit of memory. Applied to will (for-joerg/arm-smmu/updates), thanks! [1/1] iommu/arm-smmu-v3: Remove unnecessary oom

[PATCH] dt-bindings: Drop redundant minItems/maxItems

2021-06-15 Thread Rob Herring
If a property has an 'items' list, then a 'minItems' or 'maxItems' with the same size as the list is redundant and can be dropped. Note that is DT schema specific behavior and not standard json-schema behavior. The tooling will fixup the final schema adding any unspecified minItems/maxItems. This

Re: [PATCH v3 3/6] iommu: Improve iommu_iotlb_gather helpers

2021-06-15 Thread Nadav Amit
> On Jun 15, 2021, at 12:05 PM, Nadav Amit wrote: > > > >> On Jun 15, 2021, at 3:42 AM, Robin Murphy wrote: >> >> On 2021-06-07 19:25, Nadav Amit wrote: >>> From: Robin Murphy >>> The Mediatek driver is not the only one which might want a basic >>> address-based gathering behaviour, so

Re: [PATCH v3 3/6] iommu: Improve iommu_iotlb_gather helpers

2021-06-15 Thread Nadav Amit
> On Jun 15, 2021, at 3:42 AM, Robin Murphy wrote: > > On 2021-06-07 19:25, Nadav Amit wrote: >> From: Robin Murphy >> The Mediatek driver is not the only one which might want a basic >> address-based gathering behaviour, so although it's arguably simple >> enough to open-code, let's factor

Re: [PATCH v3 4/6] iommu: Factor iommu_iotlb_gather_is_disjoint() out

2021-06-15 Thread Nadav Amit
> On Jun 15, 2021, at 3:29 AM, Will Deacon wrote: > > On Fri, Jun 11, 2021 at 09:50:31AM -0700, Nadav Amit wrote: >> >> >>> On Jun 11, 2021, at 6:57 AM, Will Deacon wrote: >>> >>> On Mon, Jun 07, 2021 at 11:25:39AM -0700, Nadav Amit wrote: From: Nadav Amit Refactor

Re: [PATCH v3 6/6] iommu/amd: Sync once for scatter-gather operations

2021-06-15 Thread Nadav Amit
> On Jun 15, 2021, at 4:25 AM, Robin Murphy wrote: > > On 2021-06-07 19:25, Nadav Amit wrote: >> From: Nadav Amit >> On virtual machines, software must flush the IOTLB after each page table >> entry update. >> The iommu_map_sg() code iterates through the given scatter-gather list >> and

Re: [PATCH v3 2/6] iommu/amd: Do not use flush-queue when NpCache is on

2021-06-15 Thread Nadav Amit
> On Jun 15, 2021, at 6:08 AM, Robin Murphy wrote: > > On 2021-06-07 19:25, Nadav Amit wrote: >> From: Nadav Amit >> Do not use flush-queue on virtualized environments, where the NpCache >> capability of the IOMMU is set. This is required to reduce >> virtualization overheads. >> This change

Re: [PATCH v3 3/9] iommu/arm-smmu: Implement ->probe_finalize()

2021-06-15 Thread Will Deacon
On Tue, Jun 15, 2021 at 06:12:13PM +, Krishna Reddy wrote: > > if (smmu->impl->probe_finalize) > > The above is the issue. It should be updated as below similar to other > instances impl callbacks. > if (smmu->impl && smmu->impl->probe_finalize) I'll push a patch on top shortly... Will

Re: [PATCH v3 5/6] iommu/amd: Tailored gather logic for AMD

2021-06-15 Thread Nadav Amit
> On Jun 15, 2021, at 5:55 AM, Robin Murphy wrote: > > On 2021-06-07 19:25, Nadav Amit wrote: >> From: Nadav Amit >> AMD's IOMMU can flush efficiently (i.e., in a single flush) any range. >> This is in contrast, for instnace, to Intel IOMMUs that have a limit on >> the number of pages that

RE: [PATCH v3 3/9] iommu/arm-smmu: Implement ->probe_finalize()

2021-06-15 Thread Krishna Reddy
> if (smmu->impl->probe_finalize) The above is the issue. It should be updated as below similar to other instances impl callbacks. if (smmu->impl && smmu->impl->probe_finalize) -KR ___ iommu mailing list iommu@lists.linux-foundation.org

Re: [PATCH v3 3/9] iommu/arm-smmu: Implement ->probe_finalize()

2021-06-15 Thread Robin Murphy
On 2021-06-15 19:01, Marek Szyprowski wrote: Hi, On 03.06.2021 18:46, Thierry Reding wrote: From: Thierry Reding Implement a ->probe_finalize() callback that can be used by vendor implementations to perform extra programming necessary after devices have been attached to the SMMU.

Re: [PATCH v3 3/9] iommu/arm-smmu: Implement ->probe_finalize()

2021-06-15 Thread Marek Szyprowski
Hi, On 03.06.2021 18:46, Thierry Reding wrote: > From: Thierry Reding > > Implement a ->probe_finalize() callback that can be used by vendor > implementations to perform extra programming necessary after devices > have been attached to the SMMU. > > Signed-off-by: Thierry Reding This patch

[PATCH v6 06/15] iommu: Split 'addr_merge' argument to iommu_pgsize() into separate parts

2021-06-15 Thread Georgi Djakov
From: Will Deacon The 'addr_merge' parameter to iommu_pgsize() is a fabricated address intended to describe the alignment requirements to consider when choosing an appropriate page size. On the iommu_map() path, this address is the logical OR of the virtual and physical addresses. Subsequent

[PATCH v6 04/15] iommu: Add a map_pages() op for IOMMU drivers

2021-06-15 Thread Georgi Djakov
From: "Isaac J. Manjarres" Add a callback for IOMMU drivers to provide a path for the IOMMU framework to call into an IOMMU driver, which can call into the io-pgtable code, to map a physically contiguous rnage of pages of the same size. For IOMMU drivers that do not specify a map_pages()

[PATCH v6 12/15] iommu/io-pgtable-arm-v7s: Implement arm_v7s_unmap_pages()

2021-06-15 Thread Georgi Djakov
From: "Isaac J. Manjarres" Implement the unmap_pages() callback for the ARM v7s io-pgtable format. Signed-off-by: Isaac J. Manjarres Signed-off-by: Georgi Djakov --- drivers/iommu/io-pgtable-arm-v7s.c | 24 +--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git

[PATCH v6 00/15] Optimizing iommu_[map/unmap] performance

2021-06-15 Thread Georgi Djakov
When unmapping a buffer from an IOMMU domain, the IOMMU framework unmaps the buffer at a granule of the largest page size that is supported by the IOMMU hardware and fits within the buffer. For every block that is unmapped, the IOMMU framework will call into the IOMMU driver, and then the

[PATCH v6 07/15] iommu: Hook up '->unmap_pages' driver callback

2021-06-15 Thread Georgi Djakov
From: Will Deacon Extend iommu_pgsize() to populate an optional 'count' parameter so that we can direct unmapping operation to the ->unmap_pages callback if it has been provided by the driver. Signed-off-by: Will Deacon Signed-off-by: Isaac J. Manjarres Signed-off-by: Georgi Djakov ---

[PATCH v6 08/15] iommu: Add support for the map_pages() callback

2021-06-15 Thread Georgi Djakov
From: "Isaac J. Manjarres" Since iommu_pgsize can calculate how many pages of the same size can be mapped/unmapped before the next largest page size boundary, add support for invoking an IOMMU driver's map_pages() callback, if it provides one. Signed-off-by: Isaac J. Manjarres Suggested-by:

[PATCH v6 14/15] iommu/arm-smmu: Implement the unmap_pages() IOMMU driver callback

2021-06-15 Thread Georgi Djakov
From: "Isaac J. Manjarres" Implement the unmap_pages() callback for the ARM SMMU driver to allow calls from iommu_unmap to unmap multiple pages of the same size in one call. Also, remove the unmap() callback for the SMMU driver, as it will no longer be used. Signed-off-by: Isaac J. Manjarres

[PATCH v6 13/15] iommu/io-pgtable-arm-v7s: Implement arm_v7s_map_pages()

2021-06-15 Thread Georgi Djakov
From: "Isaac J. Manjarres" Implement the map_pages() callback for the ARM v7s io-pgtable format. Signed-off-by: Isaac J. Manjarres Signed-off-by: Georgi Djakov --- drivers/iommu/io-pgtable-arm-v7s.c | 26 ++ 1 file changed, 22 insertions(+), 4 deletions(-) diff --git

[PATCH v6 01/15] iommu/io-pgtable: Introduce unmap_pages() as a page table op

2021-06-15 Thread Georgi Djakov
From: "Isaac J. Manjarres" The io-pgtable code expects to operate on a single block or granule of memory that is supported by the IOMMU hardware when unmapping memory. This means that when a large buffer that consists of multiple such blocks is unmapped, the io-pgtable code will walk the page

[PATCH v6 10/15] iommu/io-pgtable-arm: Implement arm_lpae_unmap_pages()

2021-06-15 Thread Georgi Djakov
From: "Isaac J. Manjarres" Implement the unmap_pages() callback for the ARM LPAE io-pgtable format. Signed-off-by: Isaac J. Manjarres Suggested-by: Will Deacon Signed-off-by: Georgi Djakov --- drivers/iommu/io-pgtable-arm.c | 75 +++--- 1 file changed, 49

[PATCH v6 11/15] iommu/io-pgtable-arm: Implement arm_lpae_map_pages()

2021-06-15 Thread Georgi Djakov
From: "Isaac J. Manjarres" Implement the map_pages() callback for the ARM LPAE io-pgtable format. Signed-off-by: Isaac J. Manjarres Signed-off-by: Georgi Djakov --- drivers/iommu/io-pgtable-arm.c | 41 +++-- 1 file changed, 31 insertions(+), 10

[PATCH v6 02/15] iommu: Add an unmap_pages() op for IOMMU drivers

2021-06-15 Thread Georgi Djakov
From: "Isaac J. Manjarres" Add a callback for IOMMU drivers to provide a path for the IOMMU framework to call into an IOMMU driver, which can call into the io-pgtable code, to unmap a virtually contiguous range of pages of the same size. For IOMMU drivers that do not specify an unmap_pages()

[PATCH v6 15/15] iommu/arm-smmu: Implement the map_pages() IOMMU driver callback

2021-06-15 Thread Georgi Djakov
From: "Isaac J. Manjarres" Implement the map_pages() callback for the ARM SMMU driver to allow calls from iommu_map to map multiple pages of the same size in one call. Also, remove the map() callback for the ARM SMMU driver, as it will no longer be used. Signed-off-by: Isaac J. Manjarres

[PATCH v6 05/15] iommu: Use bitmap to calculate page size in iommu_pgsize()

2021-06-15 Thread Georgi Djakov
From: Will Deacon Avoid the potential for shifting values by amounts greater than the width of their type by using a bitmap to compute page size in iommu_pgsize(). Signed-off-by: Will Deacon Signed-off-by: Isaac J. Manjarres Signed-off-by: Georgi Djakov --- drivers/iommu/iommu.c | 31

[PATCH v6 09/15] iommu/io-pgtable-arm: Prepare PTE methods for handling multiple entries

2021-06-15 Thread Georgi Djakov
From: "Isaac J. Manjarres" The PTE methods currently operate on a single entry. In preparation for manipulating multiple PTEs in one map or unmap call, allow them to handle multiple PTEs. Signed-off-by: Isaac J. Manjarres Suggested-by: Robin Murphy Signed-off-by: Georgi Djakov ---

[PATCH v6 03/15] iommu/io-pgtable: Introduce map_pages() as a page table op

2021-06-15 Thread Georgi Djakov
From: "Isaac J. Manjarres" Mapping memory into io-pgtables follows the same semantics that unmapping memory used to follow (i.e. a buffer will be mapped one page block per call to the io-pgtable code). This means that it can be optimized in the same way that unmapping memory was, so add a

Re: Plan for /dev/ioasid RFC v2

2021-06-15 Thread Alex Williamson
On Tue, 15 Jun 2021 01:21:35 + "Tian, Kevin" wrote: > > From: Jason Gunthorpe > > Sent: Monday, June 14, 2021 9:38 PM > > > > On Mon, Jun 14, 2021 at 03:09:31AM +, Tian, Kevin wrote: > > > > > If a device can be always blocked from accessing memory in the IOMMU > > > before it's

Re: Plan for /dev/ioasid RFC v2

2021-06-15 Thread Alex Williamson
On Tue, 15 Jun 2021 02:31:39 + "Tian, Kevin" wrote: > > From: Alex Williamson > > Sent: Tuesday, June 15, 2021 12:28 AM > > > [...] > > > IOASID. Today the group fd requires an IOASID before it hands out a > > > device_fd. With iommu_fd the device_fd will not allow IOCTLs until it > > >

Re: [RFC PATCH V3 08/11] swiotlb: Add bounce buffer remap address setting function

2021-06-15 Thread Tianyu Lan
On 6/14/2021 11:32 PM, Christoph Hellwig wrote: On Mon, Jun 14, 2021 at 02:49:51PM +0100, Robin Murphy wrote: FWIW, I think a better generalisation for this would be allowing set_memory_decrypted() to return an address rather than implicitly operating in-place, and hide all the various

Re: [RFC] /dev/ioasid uAPI proposal

2021-06-15 Thread Jason Gunthorpe
On Tue, Jun 15, 2021 at 08:59:25AM +, Tian, Kevin wrote: > Hi, Jason, > > > From: Jason Gunthorpe > > Sent: Thursday, June 3, 2021 9:05 PM > > > > On Thu, Jun 03, 2021 at 06:39:30AM +, Tian, Kevin wrote: > > > > > Two helper functions are provided to support VFIO_ATTACH_IOASID: > > > > >

Re: [RFC PATCH V3 10/11] HV/Netvsc: Add Isolation VM support for netvsc driver

2021-06-15 Thread Tianyu Lan
On 6/14/2021 11:33 PM, Christoph Hellwig wrote: On Mon, Jun 14, 2021 at 10:04:06PM +0800, Tianyu Lan wrote: The pages in the hv_page_buffer array here are in the kernel linear mapping. The packet sent to host will contain an array which contains transaction data. In the isolation VM, data in

[PATCH v8 10/10] Documentation: Add documentation for VDUSE

2021-06-15 Thread Xie Yongji
VDUSE (vDPA Device in Userspace) is a framework to support implementing software-emulated vDPA devices in userspace. This document is intended to clarify the VDUSE design and usage. Signed-off-by: Xie Yongji --- Documentation/userspace-api/index.rst | 1 +

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

2021-06-15 Thread Xie Yongji
This VDUSE driver enables implementing vDPA devices in userspace. The vDPA device's control path is handled in kernel and the data path is handled in userspace. A message mechnism is used by VDUSE driver to forward some control messages such as starting/stopping datapath to userspace. Userspace

[PATCH v8 08/10] vduse: Implement an MMU-based IOMMU driver

2021-06-15 Thread Xie Yongji
This implements an MMU-based IOMMU driver to support mapping kernel dma buffer into userspace. The basic idea behind it is treating MMU (VA->PA) as IOMMU (IOVA->PA). The driver will set up MMU mapping instead of IOMMU mapping for the DMA transfer so that the userspace process is able to use its

[PATCH v8 07/10] vdpa: Support transferring virtual addressing during DMA mapping

2021-06-15 Thread Xie Yongji
This patch introduces an attribute for vDPA device to indicate whether virtual address can be used. If vDPA device driver set it, vhost-vdpa bus driver will not pin user page and transfer userspace virtual address instead of physical address during DMA mapping. And corresponding vma->vm_file and

[PATCH v8 06/10] vdpa: factor out vhost_vdpa_pa_map() and vhost_vdpa_pa_unmap()

2021-06-15 Thread Xie Yongji
The upcoming patch is going to support VA mapping/unmapping. So let's factor out the logic of PA mapping/unmapping firstly to make the code more readable. Suggested-by: Jason Wang Signed-off-by: Xie Yongji Acked-by: Jason Wang --- drivers/vhost/vdpa.c | 53

[PATCH v8 05/10] vdpa: Add an opaque pointer for vdpa_config_ops.dma_map()

2021-06-15 Thread Xie Yongji
Add an opaque pointer for DMA mapping. Suggested-by: Jason Wang Signed-off-by: Xie Yongji Acked-by: Jason Wang --- drivers/vdpa/vdpa_sim/vdpa_sim.c | 6 +++--- drivers/vhost/vdpa.c | 2 +- include/linux/vdpa.h | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-)

[PATCH v8 04/10] vhost-iotlb: Add an opaque pointer for vhost IOTLB

2021-06-15 Thread Xie Yongji
Add an opaque pointer for vhost IOTLB. And introduce vhost_iotlb_add_range_ctx() to accept it. Suggested-by: Jason Wang Signed-off-by: Xie Yongji Acked-by: Jason Wang --- drivers/vhost/iotlb.c | 20 include/linux/vhost_iotlb.h | 3 +++ 2 files changed, 19

[PATCH v8 03/10] eventfd: Increase the recursion depth of eventfd_signal()

2021-06-15 Thread Xie Yongji
Increase the recursion depth of eventfd_signal() to 1. This is the maximum recursion depth we have found so far, which can be triggered with the following call chain: kvm_io_bus_write[kvm] --> ioeventfd_write [kvm] --> eventfd_signal

[PATCH v8 02/10] file: Export receive_fd() to modules

2021-06-15 Thread Xie Yongji
Export receive_fd() so that some modules can use it to pass file descriptor between processes without missing any security stuffs. Signed-off-by: Xie Yongji --- fs/file.c| 6 ++ include/linux/file.h | 7 +++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git

[PATCH v8 01/10] iova: Export alloc_iova_fast() and free_iova_fast();

2021-06-15 Thread Xie Yongji
Export alloc_iova_fast() and free_iova_fast() so that some modules can use it to improve iova allocation efficiency. Signed-off-by: Xie Yongji --- drivers/iommu/iova.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/iommu/iova.c b/drivers/iommu/iova.c index

[PATCH v8 00/10] Introduce VDUSE - vDPA Device in Userspace

2021-06-15 Thread Xie Yongji
This series introduces a framework that makes it possible to implement software-emulated vDPA devices in userspace. And to make it simple, the emulated vDPA device's control path is handled in the kernel and only the data path is implemented in the userspace. Since the emuldated vDPA device's

Re: [PATCH] iommu/io-pgtable-arm: Optimize partial walk flush for large scatter-gather list

2021-06-15 Thread Robin Murphy
On 2021-06-15 12:51, Sai Prakash Ranjan wrote: Hi Krishna, On 2021-06-14 23:18, Krishna Reddy wrote: Right but we won't know until we profile the specific usecases or try them in generic workload to see if they affect the performance. Sure, over invalidation is a concern where multiple

Re: [PATCH v10 10/12] swiotlb: Add restricted DMA alloc/free support

2021-06-15 Thread Christoph Hellwig
On Tue, Jun 15, 2021 at 09:27:09PM +0800, Claire Chang wrote: > Add the functions, swiotlb_{alloc,free} 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 >

Re: [PATCH v10 09/12] swiotlb: Add restricted DMA pool initialization

2021-06-15 Thread Christoph Hellwig
On Tue, Jun 15, 2021 at 09:27:08PM +0800, Claire Chang wrote: > 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

Re: [PATCH v10 08/12] swiotlb: Refactor swiotlb_tbl_unmap_single

2021-06-15 Thread Christoph Hellwig
Looks good, Reviewed-by: Christoph Hellwig ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

2021-06-15 Thread Christoph Hellwig
On Tue, Jun 15, 2021 at 09:27:06PM +0800, Claire Chang wrote: > 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 Looks good, Reviewed-by: Christoph Hellwig

Re: [PATCH v10 06/12] swiotlb: Use is_dev_swiotlb_force for swiotlb data bouncing

2021-06-15 Thread Christoph Hellwig
On Tue, Jun 15, 2021 at 09:27:05PM +0800, Claire Chang wrote: > Propagate the swiotlb_force setting into io_tlb_default_mem->force 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 Looks good,

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

2021-06-15 Thread Christoph Hellwig
On Tue, Jun 15, 2021 at 09:27:04PM +0800, Claire Chang wrote: > 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 Looks good, Reviewed-by: Christoph Hellwig

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

2021-06-15 Thread Christoph Hellwig
On Tue, Jun 15, 2021 at 09:27:03PM +0800, Claire Chang wrote: > 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 Looks good, Reviewed-by: Christoph Hellwig

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

2021-06-15 Thread Christoph Hellwig
Looks good, Reviewed-by: Christoph Hellwig ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

Re: [PATCH v10 02/12] swiotlb: Refactor swiotlb_create_debugfs

2021-06-15 Thread Christoph Hellwig
On Tue, Jun 15, 2021 at 09:27:01PM +0800, Claire Chang wrote: > Split the debugfs creation to make the code reusable for supporting > different bounce buffer pools. > > Signed-off-by: Claire Chang Looks good, Reviewed-by: Christoph Hellwig ___ iommu

Re: [PATCH v10 01/12] swiotlb: Refactor swiotlb init functions

2021-06-15 Thread Christoph Hellwig
On Tue, Jun 15, 2021 at 09:27:00PM +0800, Claire Chang wrote: > Add a new function, swiotlb_init_io_tlb_mem, for the io_tlb_mem struct > initialization to make the code reusable. Looks good, Reviewed-by: Christoph Hellwig ___ iommu mailing list

Re: [PATCH v9 00/14] Restricted DMA

2021-06-15 Thread Claire Chang
v10 here: https://lore.kernel.org/patchwork/cover/1446882/ ___ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

2021-06-15 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 --- drivers/of/address.c| 33 + drivers/of/device.c | 3 +++ drivers/of/of_private.h | 6

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

2021-06-15 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 --- .../reserved-memory/reserved-memory.txt | 36

[PATCH v10 10/12] swiotlb: Add restricted DMA alloc/free support

2021-06-15 Thread Claire Chang
Add the functions, swiotlb_{alloc,free} 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 use

[PATCH v10 09/12] swiotlb: Add restricted DMA pool initialization

2021-06-15 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 v10 08/12] swiotlb: Refactor swiotlb_tbl_unmap_single

2021-06-15 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 --- kernel/dma/swiotlb.c | 35 --- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/kernel/dma/swiotlb.c

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

2021-06-15 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 --- kernel/dma/swiotlb.c | 16 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kernel/dma/swiotlb.c

[PATCH v10 06/12] swiotlb: Use is_dev_swiotlb_force for swiotlb data bouncing

2021-06-15 Thread Claire Chang
Propagate the swiotlb_force setting into io_tlb_default_mem->force 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 --- include/linux/swiotlb.h | 11 +++ kernel/dma/direct.c | 2 +-

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

2021-06-15 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 --- drivers/gpu/drm/i915/gem/i915_gem_internal.c | 2 +- drivers/gpu/drm/nouveau/nouveau_ttm.c| 2 +- drivers/pci/xen-pcifront.c

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

2021-06-15 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 --- drivers/iommu/dma-iommu.c | 12 ++-- drivers/xen/swiotlb-xen.c | 2 +- include/linux/swiotlb.h | 7 --- kernel/dma/direct.c |

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

2021-06-15 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 --- drivers/base/core.c| 4 include/linux/device.h | 4 kernel/dma/swiotlb.c | 8 3 files changed, 12 insertions(+), 4

[PATCH v10 02/12] swiotlb: Refactor swiotlb_create_debugfs

2021-06-15 Thread Claire Chang
Split the debugfs creation to make the code reusable for supporting different bounce buffer pools. Signed-off-by: Claire Chang --- kernel/dma/swiotlb.c | 21 ++--- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index

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

2021-06-15 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 --- kernel/dma/swiotlb.c | 49 ++-- 1 file changed, 24 insertions(+), 25 deletions(-) diff --git

[PATCH v10 00/12] Restricted DMA

2021-06-15 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

  1   2   >