On 01/07/2026 06:49, Aneesh Kumar K.V (Arm) wrote:
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 <[email protected]>
Tested-by: Michael Kelley <[email protected]>
Tested-by: Mostafa Saleh <[email protected]>
Signed-off-by: Aneesh Kumar K.V (Arm) <[email protected]>
---
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 <[email protected]>

Reply via email to