* Re: [RFC PATCH v3 3/5] dma-mapping: Decrypt memory on remap [not found] ` <yq5atstdanx8.fsf@kernel.org> @ 2026-05-07 17:18 ` Catalin Marinas 2026-05-08 4:03 ` Aneesh Kumar K.V 0 siblings, 1 reply; 4+ messages in thread From: Catalin Marinas @ 2026-05-07 17:18 UTC (permalink / raw) To: Aneesh Kumar K.V Cc: Mostafa Saleh, iommu, linux-kernel, robin.murphy, m.szyprowski, will, maz, suzuki.poulose, jiri, jgg On Tue, Apr 14, 2026 at 03:01:15PM +0530, Aneesh Kumar K.V wrote: > Mostafa Saleh <smostafa@google.com> writes: > > In case memory needs to be remapped on systems with > > force_dma_unencrypted(), where this memory is not allocated > > from a restricted-dma pool, this was currently ignored, while only > > setting the decrypted pgprot in the remapped alias. > > > > The memory still needs to be decrypted in that case. > > For ARM CCA, we cannot mark a vmap address as decrypted. I don’t expect > non-coherent DMA devices to be used in an ARM CCA configuration, but we > may need a way to document this in the code. I think you clarified what you meant later. The vmap here is just fine, we pass pgprot_decrypted(). The key is the dma_set_decrypted() on the page address before being remapped. On arm64 we probably don't care but if we want to enforce it for all architectures, dma_direct_alloc() could return NULL if force_dma_unencrypted() && remap (maybe together with a WARN_ON_ONCE). However, the proposed patch is small enough to cover this case as well. -- Catalin ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH v3 3/5] dma-mapping: Decrypt memory on remap 2026-05-07 17:18 ` [RFC PATCH v3 3/5] dma-mapping: Decrypt memory on remap Catalin Marinas @ 2026-05-08 4:03 ` Aneesh Kumar K.V 0 siblings, 0 replies; 4+ messages in thread From: Aneesh Kumar K.V @ 2026-05-08 4:03 UTC (permalink / raw) To: Catalin Marinas Cc: Mostafa Saleh, iommu, linux-kernel, robin.murphy, m.szyprowski, will, maz, suzuki.poulose, jiri, jgg Catalin Marinas <catalin.marinas@arm.com> writes: > On Tue, Apr 14, 2026 at 03:01:15PM +0530, Aneesh Kumar K.V wrote: >> Mostafa Saleh <smostafa@google.com> writes: >> > In case memory needs to be remapped on systems with >> > force_dma_unencrypted(), where this memory is not allocated >> > from a restricted-dma pool, this was currently ignored, while only >> > setting the decrypted pgprot in the remapped alias. >> > >> > The memory still needs to be decrypted in that case. >> >> For ARM CCA, we cannot mark a vmap address as decrypted. I don’t expect >> non-coherent DMA devices to be used in an ARM CCA configuration, but we >> may need a way to document this in the code. > > I think you clarified what you meant later. The vmap here is just fine, > we pass pgprot_decrypted(). The key is the dma_set_decrypted() on the > page address before being remapped. > > On arm64 we probably don't care but if we want to enforce it for all > architectures, dma_direct_alloc() could return NULL if > force_dma_unencrypted() && remap (maybe together with a WARN_ON_ONCE). > However, the proposed patch is small enough to cover this case as well. > I have posted a new series clarifying the commit message and adding further changes here https://lore.kernel.org/all/20260427055509.898190-1-aneesh.kumar@kernel.org -aneesh ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <20260408194750.2280873-5-smostafa@google.com>]
[parent not found: <20260410180504.GE2551565@ziepe.ca>]
[parent not found: <aeJVh5VbkzxHDBEK@google.com>]
* Re: [RFC PATCH v3 4/5] dma-mapping: Encapsulate memory state during allocation [not found] ` <aeJVh5VbkzxHDBEK@google.com> @ 2026-05-07 17:36 ` Catalin Marinas 2026-05-11 10:48 ` Mostafa Saleh 0 siblings, 1 reply; 4+ messages in thread From: Catalin Marinas @ 2026-05-07 17:36 UTC (permalink / raw) To: Mostafa Saleh Cc: Jason Gunthorpe, iommu, linux-kernel, robin.murphy, m.szyprowski, will, maz, suzuki.poulose, jiri, aneesh.kumar On Fri, Apr 17, 2026 at 03:45:11PM +0000, Mostafa Saleh wrote: > On Fri, Apr 10, 2026 at 03:05:04PM -0300, Jason Gunthorpe wrote: > > On Wed, Apr 08, 2026 at 07:47:41PM +0000, Mostafa Saleh wrote: > > > Introduce a new dma-direct internal type dma_page which is > > > "struct page" and a bit indicate whether the memory has been decrypted > > > or not. > > > This is useful to pass such information encapsulated through > > > allocation functions, which is currently set from swiotlb_alloc(). > > > > > > No functional changes. > > > > > > Signed-off-by: Mostafa Saleh <smostafa@google.com> > > > --- > > > kernel/dma/direct.c | 58 +++++++++++++++++++++++++++++++++++---------- > > > 1 file changed, 46 insertions(+), 12 deletions(-) > > > > > > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c > > > index de63e0449700..204bc566480c 100644 > > > --- a/kernel/dma/direct.c > > > +++ b/kernel/dma/direct.c > > > @@ -16,6 +16,33 @@ > > > #include <linux/pci-p2pdma.h> > > > #include "direct.h" > > > > > > +/* > > > + * Represent DMA allocation and 1 bit flag for it's state > > > + */ > > > > I'd explain this wrappers a pointer and uses the low PAGE_SHIFT bits > > for flags.. > > > > > +struct dma_page { > > > + unsigned long val; > > > > unintptr_t ? > > I thought about that, but I don’t see unintptr_t anywhere in the > kernel, it seems similar cases use “unsigned long” as in xarray.h Jason meant uintptr_t. However, we have a similar pattern with struct encoded_page as an incomplete type and encode_page() adds the bits directly to the pointer. I'd use something similar as there's precedent already. -- Catalin ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [RFC PATCH v3 4/5] dma-mapping: Encapsulate memory state during allocation 2026-05-07 17:36 ` [RFC PATCH v3 4/5] dma-mapping: Encapsulate memory state during allocation Catalin Marinas @ 2026-05-11 10:48 ` Mostafa Saleh 0 siblings, 0 replies; 4+ messages in thread From: Mostafa Saleh @ 2026-05-11 10:48 UTC (permalink / raw) To: Catalin Marinas Cc: Jason Gunthorpe, iommu, linux-kernel, robin.murphy, m.szyprowski, will, maz, suzuki.poulose, jiri, aneesh.kumar On Thu, May 07, 2026 at 06:36:27PM +0100, Catalin Marinas wrote: > On Fri, Apr 17, 2026 at 03:45:11PM +0000, Mostafa Saleh wrote: > > On Fri, Apr 10, 2026 at 03:05:04PM -0300, Jason Gunthorpe wrote: > > > On Wed, Apr 08, 2026 at 07:47:41PM +0000, Mostafa Saleh wrote: > > > > Introduce a new dma-direct internal type dma_page which is > > > > "struct page" and a bit indicate whether the memory has been decrypted > > > > or not. > > > > This is useful to pass such information encapsulated through > > > > allocation functions, which is currently set from swiotlb_alloc(). > > > > > > > > No functional changes. > > > > > > > > Signed-off-by: Mostafa Saleh <smostafa@google.com> > > > > --- > > > > kernel/dma/direct.c | 58 +++++++++++++++++++++++++++++++++++---------- > > > > 1 file changed, 46 insertions(+), 12 deletions(-) > > > > > > > > diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c > > > > index de63e0449700..204bc566480c 100644 > > > > --- a/kernel/dma/direct.c > > > > +++ b/kernel/dma/direct.c > > > > @@ -16,6 +16,33 @@ > > > > #include <linux/pci-p2pdma.h> > > > > #include "direct.h" > > > > > > > > +/* > > > > + * Represent DMA allocation and 1 bit flag for it's state > > > > + */ > > > > > > I'd explain this wrappers a pointer and uses the low PAGE_SHIFT bits > > > for flags.. > > > > > > > +struct dma_page { > > > > + unsigned long val; > > > > > > unintptr_t ? > > > > I thought about that, but I don’t see unintptr_t anywhere in the > > kernel, it seems similar cases use “unsigned long” as in xarray.h > > Jason meant uintptr_t. However, we have a similar pattern with struct > encoded_page as an incomplete type and encode_page() adds the bits > directly to the pointer. I'd use something similar as there's precedent > already. I see, makes sense, I will do that. Thanks, Mostafa > > -- > Catalin ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-05-11 10:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260408194750.2280873-1-smostafa@google.com>
[not found] ` <20260408194750.2280873-4-smostafa@google.com>
[not found] ` <yq5atstdanx8.fsf@kernel.org>
2026-05-07 17:18 ` [RFC PATCH v3 3/5] dma-mapping: Decrypt memory on remap Catalin Marinas
2026-05-08 4:03 ` Aneesh Kumar K.V
[not found] ` <20260408194750.2280873-5-smostafa@google.com>
[not found] ` <20260410180504.GE2551565@ziepe.ca>
[not found] ` <aeJVh5VbkzxHDBEK@google.com>
2026-05-07 17:36 ` [RFC PATCH v3 4/5] dma-mapping: Encapsulate memory state during allocation Catalin Marinas
2026-05-11 10:48 ` Mostafa Saleh
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox