Re: [PATCH v3 1/3] dma: Fix encryption bit clearing for dma_to_phys

From: Gavin Shan
Date: Thu Feb 27 2025 - 21:09:30 EST


On 2/28/25 12:41 AM, Suzuki K Poulose wrote:
phys_to_dma() sets the encryption bit on the translated DMA address. But
dma_to_phys() clears the encryption bit after it has been translated back
to the physical address, which could fail if the device uses DMA ranges.

AMD SME doesn't use the DMA ranges and thus this is harmless. But as we
are about to add support for other architectures, let us fix this.

Reported-by: Aneesh Kumar K.V <aneesh.kumar@xxxxxxxxxx>
Link: https://lkml.kernel.org/r/yq5amsen9stc.fsf@xxxxxxxxxx
Cc: Will Deacon <will@xxxxxxxxxx>
Cc: Jean-Philippe Brucker <jean-philippe@xxxxxxxxxx>
Cc: Catalin Marinas <catalin.marinas@xxxxxxx>
Cc: Robin Murphy <robin.murphy@xxxxxxx>
Cc: Steven Price <steven.price@xxxxxxx>
Cc: Christoph Hellwig <hch@xxxxxx>
Cc: Marek Szyprowski <m.szyprowski@xxxxxxxxxxx>
Cc: Tom Lendacky <thomas.lendacky@xxxxxxx>
Reviewed-by: Robin Murphy <robin.murphy@xxxxxxx>
Acked-by: Tom Lendacky <thomas.lendacky@xxxxxxx>
Signed-off-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx>
---
include/linux/dma-direct.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Gavin Shan <gshan@xxxxxxxxxx>