On Wed, Jun 17, 2026 at 10:50:39AM +1000, Alexey Kardashevskiy wrote:
> > @@ -193,16 +193,31 @@ void *dma_direct_alloc(struct device *dev, size_t
> > size,
> > dma_addr_t *dma_handle, gfp_t gfp, unsigned long attrs)
> > {
> > bool remap = false, set_uncached = false;
> > - bool mark_mem_decrypt = true;
> > + bool mark_mem_decrypt = false;
> > struct page *page;
> > void *ret;
> > + /*
> > + * DMA_ATTR_CC_SHARED is not a caller-visible dma_alloc_*()
> > + * attribute. The direct allocator uses it internally after it has
> > + * decided that the backing pages must be shared/decrypted, so the
> > + * rest of the allocation path can consistently select DMA addresses,
> > + * choose compatible pools and restore encryption on free.
>
> Why this limit?
>
> Context: I am looking for a memory pool for a few shared pages (to
> do some guest<->host communication), SWIOTLB seems like the right
> fit but swiotlb_alloc() is not exported and
> dma_direct_alloc(DMA_ATTR_CC_SHARED) is not allowed. Thanks,
Then setup your struct device so that the DMA API knows the
guest<->host channel requires unecrypted and it will work correctly.
I think this is a reasonable API to use for that, and I was just
advocating that hyperv should be using it too.
But it all relies on a properly setup struct device.
Jason