The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: Suzuki K Poulose <suzuki.poulose@arm.com>,
	will@kernel.org, robin.murphy@arm.com, catalin.marinas@arm.com
Cc: maz@kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org,
	aneesh.kumar@kernel.org, steven.price@arm.com,
	Jean-Philippe Brucker <jean-philippe@linaro.org>,
	Christoph Hellwig <hch@lst.de>
Subject: Re: [PATCH v2 1/3] dma: Fix encryption bit clearing for dma_to_phys
Date: Tue, 25 Feb 2025 09:26:12 -0600	[thread overview]
Message-ID: <1de357f1-1f5e-5442-b2b5-ff562ce450ed@amd.com> (raw)
In-Reply-To: <20250219220751.1276854-2-suzuki.poulose@arm.com>

On 2/19/25 16:07, 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.
> 
> Hopefully, AMD SME doesn't use it. Anyways, let us fix it, before cleanup
> the infrastructure for supporting other architectures.

I'm not aware of anything using DMA ranges on SME capable hardware. And
as you stated, this would have failed if there was.

Acked-by: Tom Lendacky <thomas.lendacky@amd.com>

> 
> Reported-by: Aneesh Kumar K.V <aneesh.kumar@kernel.org>
> Link: https://lkml.kernel.org/r/yq5amsen9stc.fsf@kernel.org
> Cc: Will Deacon <will@kernel.org>
> Cc: Jean-Philippe Brucker <jean-philippe@linaro.org>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Robin Murphy <robin.murphy@arm.com>
> Cc: Steven Price <steven.price@arm.com>
> Cc: Christoph Hellwig <hch@lst.de>
> Cc: Tom Lendacky <thomas.lendacky@amd.com>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com>
> ---
>  include/linux/dma-direct.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/dma-direct.h b/include/linux/dma-direct.h
> index d7e30d4f7503..d20ecc24cb0f 100644
> --- a/include/linux/dma-direct.h
> +++ b/include/linux/dma-direct.h
> @@ -101,12 +101,13 @@ static inline phys_addr_t dma_to_phys(struct device *dev, dma_addr_t dma_addr)
>  {
>  	phys_addr_t paddr;
>  
> +	dma_addr = __sme_clr(dma_addr);
>  	if (dev->dma_range_map)
>  		paddr = translate_dma_to_phys(dev, dma_addr);
>  	else
>  		paddr = dma_addr;
>  
> -	return __sme_clr(paddr);
> +	return paddr;
>  }
>  #endif /* !CONFIG_ARCH_HAS_PHYS_TO_DMA */
>  

  parent reply	other threads:[~2025-02-25 15:26 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-19 22:07 [PATCH v2 0/3] arm64: realm: Fix DMA address for devices Suzuki K Poulose
2025-02-19 22:07 ` [PATCH v2 1/3] dma: Fix encryption bit clearing for dma_to_phys Suzuki K Poulose
2025-02-25 11:25   ` Robin Murphy
2025-02-25 14:04     ` Suzuki K Poulose
2025-02-25 15:26   ` Tom Lendacky [this message]
2025-02-19 22:07 ` [PATCH v2 2/3] dma: Introduce generic dma_decrypted/dma_encrypted helpers Suzuki K Poulose
2025-02-25 12:49   ` Robin Murphy
2025-02-25 16:30     ` Suzuki K Poulose
2025-02-19 22:07 ` [PATCH v2 3/3] arm64: realm: Use aliased addresses for device DMA to shared buffers Suzuki K Poulose
2025-02-25  5:24   ` Gavin Shan
2025-02-25  5:28     ` Gavin Shan
2025-02-25 16:31       ` Suzuki K Poulose
2025-02-25 13:04   ` Robin Murphy
2025-02-25 16:14     ` Suzuki K Poulose
2025-02-26 10:00     ` Suzuki K Poulose

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1de357f1-1f5e-5442-b2b5-ff562ce450ed@amd.com \
    --to=thomas.lendacky@amd.com \
    --cc=aneesh.kumar@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hch@lst.de \
    --cc=jean-philippe@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=steven.price@arm.com \
    --cc=suzuki.poulose@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox