From: Claude Code Review Bot <claude-review@example.com>
To: dri-devel-reviews@example.com
Subject: Claude review: dma-mapping: introduce DMA_ATTR_CC_DECRYPTED for pre-decrypted memory
Date: Tue, 24 Feb 2026 10:16:38 +1000 [thread overview]
Message-ID: <review-patch1-20260223095136.225277-2-jiri@resnulli.us> (raw)
In-Reply-To: <20260223095136.225277-2-jiri@resnulli.us>
Patch Review
The new attribute definition and trace event addition are straightforward.
> + if (is_swiotlb_force_bounce(dev)) {
> + if (!(attrs & DMA_ATTR_CC_DECRYPTED)) {
> + if (attrs & DMA_ATTR_MMIO)
> + return DMA_MAPPING_ERROR;
> +
> + return swiotlb_map(dev, phys, size, dir, attrs);
> + }
> + } else if (attrs & DMA_ATTR_CC_DECRYPTED) {
> + return DMA_MAPPING_ERROR;
> }
The logic here is correct: CC_DECRYPTED bypasses bounce buffering when force-bounce is active (the CoCo case), and returns an error when force-bounce is not active (CC_DECRYPTED makes no sense outside CoCo). The existing MMIO and swiotlb paths are unchanged when CC_DECRYPTED is not set.
> + } else if (attrs & DMA_ATTR_CC_DECRYPTED) {
> + dma_addr = phys_to_dma_unencrypted(dev, phys);
> + if (unlikely(!dma_capable(dev, dma_addr, size, false)))
> + goto err_overflow;
Using `phys_to_dma_unencrypted()` here is correct -- it produces a DMA address without the encryption bit, matching how swiotlb buffers are mapped. Passing `false` to `dma_capable` (no need to check against the encryption-adjusted mask) follows the same pattern as MMIO.
One thing worth discussing: `dma_direct_unmap_phys` is not updated to handle `DMA_ATTR_CC_DECRYPTED`. The unmap path calls `dma_to_phys(dev, addr)` on the unencrypted DMA address and then calls `swiotlb_tbl_unmap_single()`. This works because `dma_addr_canonical()` correctly strips encryption bits and `swiotlb_tbl_unmap_single` will find no matching pool and return. But it is slightly different from MMIO which gets an early return. Is there a reason not to add a similar early return for CC_DECRYPTED, or should the CPU sync still run for these pages (which are cacheable, unlike MMIO)?
Similarly, the `arch_sync_dma_for_device` call after the mapping succeeds does not exclude CC_DECRYPTED:
> if (!dev_is_dma_coherent(dev) &&
> !(attrs & (DMA_ATTR_SKIP_CPU_SYNC | DMA_ATTR_MMIO)))
> arch_sync_dma_for_device(phys, size, dir);
Since CC_DECRYPTED pages are normal cacheable memory, including them in the sync is the right behavior. This is fine.
---
Generated by Claude Code Patch Reviewer
next prev parent reply other threads:[~2026-02-24 0:16 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-23 9:51 [PATCH v2 0/2] dma-buf: heaps: system: add an option to allocate explicitly decrypted memory Jiri Pirko
2026-02-23 9:51 ` [PATCH v2 1/2] dma-mapping: introduce DMA_ATTR_CC_DECRYPTED for pre-decrypted memory Jiri Pirko
2026-02-24 0:16 ` Claude Code Review Bot [this message]
2026-02-23 9:51 ` [PATCH v2 2/2] dma-buf: heaps: system: add system_cc_decrypted heap for explicitly decrypted memory Jiri Pirko
2026-02-23 18:33 ` John Stultz
2026-02-24 0:16 ` Claude review: " Claude Code Review Bot
2026-02-24 0:16 ` Claude review: dma-buf: heaps: system: add an option to allocate " Claude Code Review Bot
-- strict thread matches above, loose matches on Subject: below --
2026-02-09 15:38 [PATCH 0/5] " Jiri Pirko
2026-02-09 15:38 ` [PATCH 2/5] dma-mapping: introduce DMA_ATTR_CC_DECRYPTED for pre-decrypted memory Jiri Pirko
2026-02-11 6:59 ` Claude review: " Claude Code Review Bot
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=review-patch1-20260223095136.225277-2-jiri@resnulli.us \
--to=claude-review@example.com \
--cc=dri-devel-reviews@example.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