From: Jiri Pirko <jiri@resnulli.us>
To: Mostafa Saleh <smostafa@google.com>
Cc: dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org,
iommu@lists.linux.dev, linux-media@vger.kernel.org,
sumit.semwal@linaro.org, benjamin.gaignard@collabora.com,
Brian.Starkey@arm.com, jstultz@google.com, tjmercier@google.com,
christian.koenig@amd.com, m.szyprowski@samsung.com,
robin.murphy@arm.com, jgg@ziepe.ca, leon@kernel.org,
sean.anderson@linux.dev, ptesarik@suse.com,
catalin.marinas@arm.com, aneesh.kumar@kernel.org,
suzuki.poulose@arm.com, steven.price@arm.com,
thomas.lendacky@amd.com, john.allen@amd.com,
ashish.kalra@amd.com, suravee.suthikulpanit@amd.com,
linux-coco@lists.linux.dev
Subject: Re: [PATCH net-next v3 0/2] dma-buf: heaps: system: add an option to allocate explicitly decrypted memory
Date: Tue, 17 Mar 2026 14:37:02 +0100 [thread overview]
Message-ID: <xdy5anped2koy47cuxbbqocyypisl7lagwvpuokpzpggohk2dp@yilc5ihictph> (raw)
In-Reply-To: <ablV_f_l7wD2m63E@google.com>
Tue, Mar 17, 2026 at 02:24:13PM +0100, smostafa@google.com wrote:
>Hi Jiri,
>
>On Thu, Mar 05, 2026 at 01:36:39PM +0100, Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@nvidia.com>
>>
>> Confidential computing (CoCo) VMs/guests, such as AMD SEV and Intel TDX,
>> run with encrypted/protected memory which creates a challenge
>> for devices that do not support DMA to it (no TDISP support).
>>
>> For kernel-only DMA operations, swiotlb bounce buffering provides a
>> transparent solution by copying data through decrypted memory.
>> However, the only way to get this memory into userspace is via the DMA
>> API's dma_alloc_pages()/dma_mmap_pages() type interfaces which limits
>> the use of the memory to a single DMA device, and is incompatible with
>> pin_user_pages().
>>
>> These limitations are particularly problematic for the RDMA subsystem
>> which makes heavy use of pin_user_pages() and expects flexible memory
>> usage between many different DMA devices.
>>
>> This patch series enables userspace to explicitly request decrypted
>> (shared) memory allocations from the dma-buf system heap.
>> Userspace can mmap this memory and pass the dma-buf fd to other
>> existing importers such as RDMA or DRM devices to access the
>> memory. The DMA API is improved to allow the dma heap exporter to DMA
>> map the shared memory to each importing device.
>
>I have been looking into a similar problem with restricted-dma[1] and
>the inability of the DMA API to recognize that a block of memory is
>already decrypted.
>
>However, in your case, adding a new attr “DMA_ATTR_CC_DECRYPTED” works
>well as dma-buf owns the memory, and is both responsible for the
>set_memory_decrypted() and passing the DMA attrs.
>
>On the other hand, for restricted-dma, the memory decryption is deep
>in the DMA direct memory allocation and the DMA API callers (for ex
>virtio drivers) are clueless about it and can’t pass any attrs.
>My proposal was specific to restricted-dma and won’t work for your case.
>
>I am wondering if the kernel should have a more solid, unified method
>for identifying already-decrypted memory instead. Perhaps we need a
>way for the DMA API to natively recognize the encryption state of a
>physical page (working alongside force_dma_unencrypted(dev)), rather
>than relying on caller-provided attributes?
I actually had it originally implemented probably in the similar way you
suggest. I had a bit in page/folio struct to indicate the
"shared/decrypted" state. However I was told that adding such bit is
basically a no-go. Isn't that right?
>
>[1] https://lore.kernel.org/all/20260305170335.963568-1-smostafa@google.com/
>
>Thanks,
>Mostafa
>
>
>>
>> Jiri Pirko (2):
>> dma-mapping: introduce DMA_ATTR_CC_DECRYPTED for pre-decrypted memory
>> dma-buf: heaps: system: add system_cc_decrypted heap for explicitly
>> decrypted memory
>>
>> drivers/dma-buf/heaps/system_heap.c | 103 ++++++++++++++++++++++++++--
>> include/linux/dma-mapping.h | 6 ++
>> include/trace/events/dma.h | 3 +-
>> kernel/dma/direct.h | 14 +++-
>> 4 files changed, 117 insertions(+), 9 deletions(-)
>>
>> --
>> 2.51.1
>>
next prev parent reply other threads:[~2026-03-17 13:37 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-05 12:36 [PATCH net-next v3 0/2] dma-buf: heaps: system: add an option to allocate explicitly decrypted memory Jiri Pirko
2026-03-05 12:36 ` [PATCH net-next v3 1/2] dma-mapping: introduce DMA_ATTR_CC_DECRYPTED for pre-decrypted memory Jiri Pirko
2026-03-08 10:19 ` Leon Romanovsky
2026-03-09 8:57 ` Jiri Pirko
2026-03-09 13:15 ` Jason Gunthorpe
2026-03-09 14:02 ` Leon Romanovsky
2026-03-09 15:18 ` Jason Gunthorpe
2026-03-09 17:51 ` Jiri Pirko
2026-03-12 0:34 ` Jason Gunthorpe
2026-03-12 9:03 ` Jiri Pirko
2026-03-12 12:06 ` Jason Gunthorpe
2026-03-12 13:27 ` Jiri Pirko
2026-03-09 12:56 ` Petr Tesarik
2026-03-09 13:01 ` Jiri Pirko
2026-03-09 13:17 ` Jason Gunthorpe
2026-03-11 14:19 ` Jiri Pirko
2026-03-05 12:36 ` [PATCH net-next v3 2/2] dma-buf: heaps: system: add system_cc_decrypted heap for explicitly decrypted memory Jiri Pirko
2026-03-09 15:39 ` Peter Gonda
2026-03-09 15:50 ` Jason Gunthorpe
2026-03-05 12:40 ` [PATCH net-next v3 0/2] dma-buf: heaps: system: add an option to allocate " Jiri Pirko
2026-03-17 13:24 ` Mostafa Saleh
2026-03-17 13:37 ` Jiri Pirko [this message]
2026-03-17 15:40 ` Mostafa Saleh
2026-03-24 12:00 ` Jason Gunthorpe
2026-03-24 12:14 ` Mostafa Saleh
2026-03-24 12:24 ` Jason Gunthorpe
2026-03-24 17:36 ` Mostafa Saleh
2026-03-24 17:57 ` Jason Gunthorpe
2026-03-24 18:32 ` Mostafa Saleh
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=xdy5anped2koy47cuxbbqocyypisl7lagwvpuokpzpggohk2dp@yilc5ihictph \
--to=jiri@resnulli.us \
--cc=Brian.Starkey@arm.com \
--cc=aneesh.kumar@kernel.org \
--cc=ashish.kalra@amd.com \
--cc=benjamin.gaignard@collabora.com \
--cc=catalin.marinas@arm.com \
--cc=christian.koenig@amd.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=john.allen@amd.com \
--cc=jstultz@google.com \
--cc=leon@kernel.org \
--cc=linaro-mm-sig@lists.linaro.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-media@vger.kernel.org \
--cc=m.szyprowski@samsung.com \
--cc=ptesarik@suse.com \
--cc=robin.murphy@arm.com \
--cc=sean.anderson@linux.dev \
--cc=smostafa@google.com \
--cc=steven.price@arm.com \
--cc=sumit.semwal@linaro.org \
--cc=suravee.suthikulpanit@amd.com \
--cc=suzuki.poulose@arm.com \
--cc=thomas.lendacky@amd.com \
--cc=tjmercier@google.com \
/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