[RFC PATCH v7 02/13] mm: Add an allocator for CoCo shared memory

Michael Kelley mhklinux at outlook.com
Wed Sep 23 11:36:46 PDT 2026


From: Kameron Carr <kameroncarr at linux.microsoft.com> Sent: Wednesday, September 23, 2026 9:29 AM
> 
> On 9/23/2026 8:21 AM, Jason Gunthorpe wrote:
> > On Wed, Sep 23, 2026 at 08:28:57PM +0530, Aneesh Kumar K.V wrote:
> >
> >> I'm also considering requiring the address passed to cc_make_shared() to
> >> be in the linear map. This is currently required by both TDX and CCA,
> >> while AMD SNP appears to support vmalloc addresses. The only user of
> >> that vmalloc support is Hyper-V VMBus GPADL setup
> >> (vmbus_establish_gpadl()). How should the generic CoCo shared-memory
> >> allocator handle this?
> >
> > vmbus_establish_gpadl() is the the same wrong abstraction as the arch
> > code. Get rid of it and use vmbus_establish_gpadl_caller_decrypted():
> >
> > 		pdata->recv_buf = vzalloc(RECV_BUFFER_SIZE);
> > 		if (!pdata->recv_buf) {
> > 			ret = -ENOMEM;
> > 			goto fail_free_ring;
> > 		}
> >
> > 		ret = vmbus_establish_gpadl(channel, pdata->recv_buf,
> > 					    RECV_BUFFER_SIZE, &pdata->recv_gpadl);
> >
> >
> > So you made an allocator that returns folios, now you just need to
> > use that allocator to implement a kvzalloc wrapper. ARM can call vmap
> > on decrypted memory with pgprot_decrypted(), right?
> >
> > Or maybe this can use vmbus_alloc_buffer(), it already does it.
> 
> Michael Kelley recently proposed [1] moving all ring buffer allocations
> to use vmbus_alloc_buffer(). If we move forward with this, it should
> remove the dependency on vmalloc support.

I think we're already there on removing the Hyper-V dependency on
vmalloc() support. The only vmalloc'ed buffers passed to
vmbus_establish_gpadl() were the send and receive buffers in netvsc,
and Kameron's accepted patch set already changes those to use the new
vmbus_alloc_buffer().

Today, the ring buffers are allocated by alloc_pages() and so are in the linear
map. The original [1] is a proposal to use vmalloc() when there's an
alloc_pages() failure for high-order requests due memory fragmentation.
That would have reinstated a dependency on vmalloc'ed buffers, which
is the wrong direction to go. I proposed that vmbus_alloc_buffer()
be used instead as the way to avoid high-order allocation failures.

Michael

> 
> 
> [1] https://lore.kernel.org/all/SN6PR02MB4157B71CAC1433B04B92B700D4832@SN6PR02MB4157.namprd02.prod.outlook.com/
> 
> Kameron



More information about the linux-arm-kernel mailing list