From: Suzuki K Poulose <suzuki.poulose@arm.com>
To: Robin Murphy <robin.murphy@arm.com>,
will@kernel.org, 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>,
Tom Lendacky <thomas.lendacky@amd.com>
Subject: Re: [PATCH v2 1/3] dma: Fix encryption bit clearing for dma_to_phys
Date: Tue, 25 Feb 2025 14:04:29 +0000 [thread overview]
Message-ID: <34a0b098-d9c5-4605-8ce7-abd6fa59d38b@arm.com> (raw)
In-Reply-To: <68405608-564c-4e79-9cbc-545626e736f1@arm.com>
On 25/02/2025 11:25, Robin Murphy wrote:
> On 2025-02-19 10:07 pm, 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.
>
> ...by which you mean we don't think any AMD systems are using the ACPI
> _DMA method to constrain physical DMA ranges, otherwise SME with dma-
> direct would presumably already be broken by this lookup going wrong.
Yep, that AMD systems aren't using DMA ranges.
>
>> Anyways, let us fix it, before cleanup
>> the infrastructure for supporting other architectures.
>
> Reviewed-by: Robin Murphy <robin.murphy@arm.com>
Thanks
Suzuki
>
>> 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 */
>
next prev parent reply other threads:[~2025-02-25 16:39 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 [this message]
2025-02-25 15:26 ` Tom Lendacky
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=34a0b098-d9c5-4605-8ce7-abd6fa59d38b@arm.com \
--to=suzuki.poulose@arm.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=thomas.lendacky@amd.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