Re: [RFC PATCH] mm/vmalloc: add vmalloc_decrypted() and vzalloc_decrypted()
From: Jason Gunthorpe
Date: Tue Jun 16 2026 - 14:45:21 EST
On Tue, Jun 16, 2026 at 07:17:33PM +0100, Catalin Marinas wrote:
> > The entry point is dma_alloc_noncontiguous() and you get a scatterlist
> > back.
>
> Yes but not scattered pages unless there's an iommu behind. Anyway,
> that's an implementation detail, something like
> dma_alloc_noncontiguous_vmap() could allocate scattered pages as a
> fallback.
Oh I never noticed it deliberately returns only a single dma entry. I
think that could be optionally weakened without alot of trouble
There is also dma_vmap_noncontiguous() already, so I think the main
framework is there, though it seems like it needs a a bit mmore features.
> Currently, something like netvsc_init_buf() just does a vzalloc() and
> passes it down to vmbus_establish_gpadl() which knows how to interpret
> the channel encryption status. I assume with the vzalloc_decrypted()
> API, that info needs to be interpreted at the netvsc_init_buf() level to
> know which allocation to call.
But it doesn't end at alloc does it? hyperv will still have to reach
into the vmap and convert it into an appropriate IPA to pass to the
hypervisor. That really needs to use the arch helpers the DMA API has
and those should not be called by any sort of driver environment like
hyperv.
> If we move towards a dma_alloc_noncontiguous_vmap() API we need vmbus to
> encode the encryption requirement in the hv_device::device somehow so
> that force_dma_unencrypted() knows what do return.
Yes, they would have to act like PCI and mark in-TEE and out of-TEE
struct devices properly so the DMA API knows what to do instead of
open coding a copy of all this logic in hyperv.
> We have the DMA_ATTR_CC_SHARED but that's not interpreted on the DMA
> alloc path,
It is to describe memory that was deliberately allocated as decrypted,
not to control allocation choices.
> so there's a bit more work needed on the DMA API I think (not sure
> whether Aneesh's series covers any of this).
I don't think it does directly. It largely sets the stage to properly
allow a struct device to opt out of force_dma_unencrypted() so we get
support a T=1 PCI device.
Jason