Re: [PATCH 1/2] mm/cma: accept memory of multi-range CMA areas
From: Mike Rapoport
Date: Thu Oct 29 2026 - 08:22:33 EST
On Thu, Oct 29, 2026 at 11:52:53AM +0100, Gupta, Pankaj wrote:
>
> > On systems with unaccepted memory, memblock allocations accept the
> > allocated range, but when cma_declare_contiguous_multi() uses open coded
> > allocation of multiple ranges, it reserves them with memblock_reserve()
> > and they are never accepted.
> >
> > These pages are released to the buddy allocator by cma_activate_area()
> > with __free_pages() that does not check for unaccepted memory, so the
> > first access to such a page in a TDX or SEV-SNP guest is fatal.
> >
> > Accept the memory of each range when it is reserved.
>
> Fix looks correct to me.
>
> Any easy way to reproduce and test on SEV SNP?
I think running a VM with 16G or ram on a single node and with
hugetlb_cma=8G memmap=2M\$0x2ffe00000 init_on_free=1
in the kernel command line will do the trick.
> Thanks,
>
> Pankaj
>
> >
> > Fixes: c009da4258f9 ("mm, cma: support multiple contiguous ranges, if requested")
> > Cc: stable@xxxxxxxxxxxxxxx
> > Signed-off-by: Mike Rapoport (Microsoft) <rppt@xxxxxxxxxx>
> > ---
> > mm/cma.c | 2 ++
> > 1 file changed, 2 insertions(+)
> >
> > diff --git a/mm/cma.c b/mm/cma.c
> > index a10ea37a261da..0035efb1130a5 100644
> > --- a/mm/cma.c
> > +++ b/mm/cma.c
> > @@ -678,6 +678,8 @@ int __init cma_declare_contiguous_multi(phys_addr_t total_size,
> > break;
> > }
> > + accept_memory(mlp->base, size);
> > +
> > pr_debug("created region %d: %016llx - %016llx\n",
> > nr, (u64)mlp->base, (u64)mlp->base + size);
> > cmrp = &cma->ranges[nr++];
> >
--
Sincerely yours,
Mike.