linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] dma/pool: Ensure DMA_DIRECT_REMAP allocations are decrypted
@ 2025-08-11 18:17 ` Shanker Donthineni
  2025-08-12 10:25   ` Catalin Marinas
  2025-08-13  9:24   ` Marek Szyprowski
  0 siblings, 2 replies; 3+ messages in thread
From: Shanker Donthineni @ 2025-08-11 18:17 UTC (permalink / raw)
  To: Catalin Marinas, Will Deacon, Marek Szyprowski, Suzuki K Poulose,
	Steven Price, linux-arm-kernel
  Cc: Robin Murphy, Gavin Shan, Mike Rapoport, Shanker Donthineni,
	Vikram Sethi, Jason Sequeira, Dev Jain, David Rientjes,
	linux-kernel, iommu, stable

When CONFIG_DMA_DIRECT_REMAP is enabled, atomic pool pages are
remapped via dma_common_contiguous_remap() using the supplied
pgprot. Currently, the mapping uses
pgprot_dmacoherent(PAGE_KERNEL), which leaves the memory encrypted
on systems with memory encryption enabled (e.g., ARM CCA Realms).

This can cause the DMA layer to fail or crash when accessing the
memory, as the underlying physical pages are not configured as
expected.

Fix this by requesting a decrypted mapping in the vmap() call:
pgprot_decrypted(pgprot_dmacoherent(PAGE_KERNEL))

This ensures that atomic pool memory is consistently mapped
unencrypted.

Cc: stable@vger.kernel.org
Signed-off-by: Shanker Donthineni <sdonthineni@nvidia.com>
---
 kernel/dma/pool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/dma/pool.c b/kernel/dma/pool.c
index 7b04f7575796b..ee45dee33d491 100644
--- a/kernel/dma/pool.c
+++ b/kernel/dma/pool.c
@@ -102,8 +102,8 @@ static int atomic_pool_expand(struct gen_pool *pool, size_t pool_size,
 
 #ifdef CONFIG_DMA_DIRECT_REMAP
 	addr = dma_common_contiguous_remap(page, pool_size,
-					   pgprot_dmacoherent(PAGE_KERNEL),
-					   __builtin_return_address(0));
+			pgprot_decrypted(pgprot_dmacoherent(PAGE_KERNEL)),
+			__builtin_return_address(0));
 	if (!addr)
 		goto free_page;
 #else
-- 
2.25.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] dma/pool: Ensure DMA_DIRECT_REMAP allocations are decrypted
  2025-08-11 18:17 ` [PATCH v2] dma/pool: Ensure DMA_DIRECT_REMAP allocations are decrypted Shanker Donthineni
@ 2025-08-12 10:25   ` Catalin Marinas
  2025-08-13  9:24   ` Marek Szyprowski
  1 sibling, 0 replies; 3+ messages in thread
From: Catalin Marinas @ 2025-08-12 10:25 UTC (permalink / raw)
  To: Shanker Donthineni
  Cc: Will Deacon, Marek Szyprowski, Suzuki K Poulose, Steven Price,
	linux-arm-kernel, Robin Murphy, Gavin Shan, Mike Rapoport,
	Vikram Sethi, Jason Sequeira, Dev Jain, David Rientjes,
	linux-kernel, iommu, stable

On Mon, Aug 11, 2025 at 01:17:59PM -0500, Shanker Donthineni wrote:
> When CONFIG_DMA_DIRECT_REMAP is enabled, atomic pool pages are
> remapped via dma_common_contiguous_remap() using the supplied
> pgprot. Currently, the mapping uses
> pgprot_dmacoherent(PAGE_KERNEL), which leaves the memory encrypted
> on systems with memory encryption enabled (e.g., ARM CCA Realms).
> 
> This can cause the DMA layer to fail or crash when accessing the
> memory, as the underlying physical pages are not configured as
> expected.
> 
> Fix this by requesting a decrypted mapping in the vmap() call:
> pgprot_decrypted(pgprot_dmacoherent(PAGE_KERNEL))
> 
> This ensures that atomic pool memory is consistently mapped
> unencrypted.
> 
> Cc: stable@vger.kernel.org
> Signed-off-by: Shanker Donthineni <sdonthineni@nvidia.com>

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] dma/pool: Ensure DMA_DIRECT_REMAP allocations are decrypted
  2025-08-11 18:17 ` [PATCH v2] dma/pool: Ensure DMA_DIRECT_REMAP allocations are decrypted Shanker Donthineni
  2025-08-12 10:25   ` Catalin Marinas
@ 2025-08-13  9:24   ` Marek Szyprowski
  1 sibling, 0 replies; 3+ messages in thread
From: Marek Szyprowski @ 2025-08-13  9:24 UTC (permalink / raw)
  To: Shanker Donthineni, Catalin Marinas, Will Deacon,
	Suzuki K Poulose, Steven Price, linux-arm-kernel
  Cc: Robin Murphy, Gavin Shan, Mike Rapoport, Vikram Sethi,
	Jason Sequeira, Dev Jain, David Rientjes, linux-kernel, iommu,
	stable

On 11.08.2025 20:17, Shanker Donthineni wrote:
> When CONFIG_DMA_DIRECT_REMAP is enabled, atomic pool pages are
> remapped via dma_common_contiguous_remap() using the supplied
> pgprot. Currently, the mapping uses
> pgprot_dmacoherent(PAGE_KERNEL), which leaves the memory encrypted
> on systems with memory encryption enabled (e.g., ARM CCA Realms).
>
> This can cause the DMA layer to fail or crash when accessing the
> memory, as the underlying physical pages are not configured as
> expected.
>
> Fix this by requesting a decrypted mapping in the vmap() call:
> pgprot_decrypted(pgprot_dmacoherent(PAGE_KERNEL))
>
> This ensures that atomic pool memory is consistently mapped
> unencrypted.
>
> Cc: stable@vger.kernel.org
> Signed-off-by: Shanker Donthineni <sdonthineni@nvidia.com>

Thanks, applied to dma-mapping-fixes branch.

Best regards
-- 
Marek Szyprowski, PhD
Samsung R&D Institute Poland



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-08-13  9:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20250811181833eucas1p2632002b6854b082632247829ea0a944c@eucas1p2.samsung.com>
2025-08-11 18:17 ` [PATCH v2] dma/pool: Ensure DMA_DIRECT_REMAP allocations are decrypted Shanker Donthineni
2025-08-12 10:25   ` Catalin Marinas
2025-08-13  9:24   ` Marek Szyprowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).