Thread (59 messages) 59 messages, 6 authors, 4h ago

Re: [PATCH v7 16/22] dma-direct: make dma_direct_map_phys() honor DMA_ATTR_CC_SHARED

From: Suzuki K Poulose <suzuki.poulose@arm.com>
Date: 2026-07-08 12:12:15
Also in: linux-arm-kernel, linux-coco, linux-iommu, linux-s390, lkml

On 01/07/2026 06:49, Aneesh Kumar K.V (Arm) wrote:
quoted hunk ↗ jump to hunk
Teach dma_direct_map_phys() to select the DMA address encoding based on
DMA_ATTR_CC_SHARED.

Use phys_to_dma_unencrypted() for decrypted mappings and
phys_to_dma_encrypted() otherwise. If a device requires unencrypted DMA
but the source physical address is still encrypted, force the mapping
through swiotlb so the DMA address and backing memory attributes remain
consistent.

Update the arm64, x86, s390 and powerpc secure-guest setup to not use
swiotlb force option

Tested-by: Jiri Pirko <redacted>
Tested-by: Michael Kelley <redacted>
Tested-by: Mostafa Saleh <smostafa@google.com>
Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
---
Changes from v3:
* Handle DMA_ATTR_MMIO
---
  arch/arm64/mm/init.c                 |  4 +--
  arch/powerpc/platforms/pseries/svm.c |  2 +-
  arch/s390/mm/init.c                  |  2 +-
  arch/x86/kernel/pci-dma.c            |  4 +--
  kernel/dma/direct.c                  |  4 ++-
  kernel/dma/direct.h                  | 45 +++++++++++++++-------------
  6 files changed, 31 insertions(+), 30 deletions(-)
diff --git a/arch/arm64/mm/init.c b/arch/arm64/mm/init.c
index 97987f850a33..acf67c7064db 100644
--- a/arch/arm64/mm/init.c
+++ b/arch/arm64/mm/init.c
@@ -338,10 +338,8 @@ void __init arch_mm_preinit(void)
  	unsigned int flags = SWIOTLB_VERBOSE;
  	bool swiotlb = max_pfn > PFN_DOWN(arm64_dma_phys_limit);
  
-	if (is_realm_world()) {
+	if (is_realm_world())
  		swiotlb = true;
-		flags |= SWIOTLB_FORCE;
-	}
  
  	if (IS_ENABLED(CONFIG_DMA_BOUNCE_UNALIGNED_KMALLOC) && !swiotlb) {
  		/*

For arm64 CCA bits:

Reviewed-by: Suzuki K Poulose <suzuki.poulose@arm.com>
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help