On Thu, Mar 05, 2026 at 01:36:40PM +0100, Jiri Pirko wrote:
From: Jiri Pirko jiri@nvidia.com
Current CC designs don't place a vIOMMU in front of untrusted devices. Instead, the DMA API forces all untrusted device DMA through swiotlb bounce buffers (is_swiotlb_force_bounce()) which copies data into decrypted memory on behalf of the device.
When a caller has already arranged for the memory to be decrypted via set_memory_decrypted(), the DMA API needs to know so it can map directly using the unencrypted physical address rather than bounce buffering. Following the pattern of DMA_ATTR_MMIO, add DMA_ATTR_CC_DECRYPTED for this purpose. Like the MMIO case, only the caller knows what kind of memory it has and must inform the DMA API for it to work correctly.
Signed-off-by: Jiri Pirko jiri@nvidia.com
v1->v2:
- rebased on top of recent dma-mapping-fixes
include/linux/dma-mapping.h | 6 ++++++ include/trace/events/dma.h | 3 ++- kernel/dma/direct.h | 14 +++++++++++--- 3 files changed, 19 insertions(+), 4 deletions(-)
diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 29973baa0581..ae3d85e494ec 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -85,6 +85,12 @@
- a cacheline must have this attribute for this to be considered safe.
*/ #define DMA_ATTR_CPU_CACHE_CLEAN (1UL << 11) +/*
- DMA_ATTR_CC_DECRYPTED: Indicates memory that has been explicitly decrypted
- (shared) for confidential computing guests. The caller must have
- called set_memory_decrypted(). A struct page is required.
- */
+#define DMA_ATTR_CC_DECRYPTED (1UL << 12)
While adding the new attribute is fine, I would expect additional checks in dma_map_phys() to ensure the attribute cannot be misused. For example, WARN_ON(attrs & (DMA_ATTR_CC_DECRYPTED | DMA_ATTR_MMIO)), along with a check that we are taking the direct path only.
Thanks
From Loss to Hope: My Path to Recovery
I want to share my story to help others who might be going through the same thing. I lost $360,870 in a crypto scam and thought I would never get my money back. I was overwhelmed, but then I found help from Trek Tech Corp. Thanks to their expertise, I recovered my stolen funds. This not only saved my finances but also gave me hope and confidence to move forward. My story shows that even after a big loss, with determination and the right help, recovery is possible. If you're struggling, don’t give up — support is available. Contact: shadowroot47 (@) outlook.com WhatsApp: +1 (530) 425-6052
On Sun, Mar 08, 2026 at 12:19:48PM +0200, Leon Romanovsky wrote:
+/*
- DMA_ATTR_CC_DECRYPTED: Indicates memory that has been explicitly decrypted
- (shared) for confidential computing guests. The caller must have
- called set_memory_decrypted(). A struct page is required.
- */
+#define DMA_ATTR_CC_DECRYPTED (1UL << 12)
While adding the new attribute is fine, I would expect additional checks in dma_map_phys() to ensure the attribute cannot be misused. For example, WARN_ON(attrs & (DMA_ATTR_CC_DECRYPTED | DMA_ATTR_MMIO)), along with a check that we are taking the direct path only.
DECRYPYED and MMIO is something that needs to work, VFIO (inside a TVM) should be using that combination.
Jason
On Mon, Mar 09, 2026 at 10:15:30AM -0300, Jason Gunthorpe wrote:
On Sun, Mar 08, 2026 at 12:19:48PM +0200, Leon Romanovsky wrote:
+/*
- DMA_ATTR_CC_DECRYPTED: Indicates memory that has been explicitly decrypted
- (shared) for confidential computing guests. The caller must have
- called set_memory_decrypted(). A struct page is required.
- */
+#define DMA_ATTR_CC_DECRYPTED (1UL << 12)
While adding the new attribute is fine, I would expect additional checks in dma_map_phys() to ensure the attribute cannot be misused. For example, WARN_ON(attrs & (DMA_ATTR_CC_DECRYPTED | DMA_ATTR_MMIO)), along with a check that we are taking the direct path only.
DECRYPYED and MMIO is something that needs to work, VFIO (inside a TVM) should be using that combination.
So this sentence "A struct page is required" from the comment above is not accurate.
Thanks
Jason
On Mon, Mar 09, 2026 at 04:02:33PM +0200, Leon Romanovsky wrote:
On Mon, Mar 09, 2026 at 10:15:30AM -0300, Jason Gunthorpe wrote:
On Sun, Mar 08, 2026 at 12:19:48PM +0200, Leon Romanovsky wrote:
+/*
- DMA_ATTR_CC_DECRYPTED: Indicates memory that has been explicitly decrypted
- (shared) for confidential computing guests. The caller must have
- called set_memory_decrypted(). A struct page is required.
- */
+#define DMA_ATTR_CC_DECRYPTED (1UL << 12)
While adding the new attribute is fine, I would expect additional checks in dma_map_phys() to ensure the attribute cannot be misused. For example, WARN_ON(attrs & (DMA_ATTR_CC_DECRYPTED | DMA_ATTR_MMIO)), along with a check that we are taking the direct path only.
DECRYPYED and MMIO is something that needs to work, VFIO (inside a TVM) should be using that combination.
So this sentence "A struct page is required" from the comment above is not accurate.
It would be clearer to say "Unless DMA_ATTR_MMIO is provided a struct page is required"
We need to audit if that works properly, IIRC it does, but I don't remember.. Jiri?
Jason
Looking for a fresh start after financial challenges? You’re not alone and rebuilding your credit is possible with the right support. Their service is designed to help you take control of your financial future by providing tools, guidance, and insights that empower you to make informed decisions and set realistic credit goals. With patience, the right strategy, and ongoing support, you can start moving toward financial independence one step at a time. Sometimes the first step is simply learning that help is available. For example, I once came across a discussion where someone mentioned how XAP Credit Solution helped improve their credit situation. Stories like that remind us that solutions exist and that people can rebuild and move forward after difficult financial moments. If you’re ready to begin your own credit journey, xapcreditsolution at gmail com Let XAP get you started with fixing your credit today.#CreditRecovery #NewBeginnings #CreditJourney #FinancialResetResults may vary based on individual credit history.
linaro-mm-sig@lists.linaro.org