Re: [PATCH v2 4/5] x86/virt/tdx: Add extra memory to TDX module for the extensions
From: Kiryl Shutsemau
Date: Thu Oct 01 2026 - 08:22:55 EST
On Tue, Sep 15, 2026 at 09:19:14PM +0000, Edgecombe, Rick P wrote:
> Hey Kiryl,
>
> On Tue, 2026-09-15 at 18:26 +0800, Xu Yilun wrote:
> > An alternative solution is to use a loop that gives memory on a memory
> > error code - TDX_EXT_MEMORY_POOL_REQUIRED, add one page per iteration
> > until TDH.EXT.INIT succeeds. Something like:
> >
> > do {
> > ret = tdh_sys_init();
> > if (ret == TDX_EXT_MEMORY_POOL_REQUIRED)
> > tdh_ext_mem_add(); //single page
> > } while (ret == TDX_EXT_MEMORY_POOL_REQUIRED);
> >
> > This approach is slightly simpler as we don't have to query the module
> > for the total memory, no memory pre-allocation or segmentation math.
> > But allocating a single 4K page per iteration may cause permanent memory
> > fragmentation.
>
> So this is definitely a bad thing to do? Even if this is running at boot before
> much fragmentation could have happened? Don't early boot allocations tend to be
> more physically contiguous?
Not necessarily. See CONFIG_SHUFFLE_PAGE_ALLOCATOR, which default Y.
But even with shuffling, page allocator shouldn't claim new non-movable
page block just to keep shuffling satisfied.
It is better to check what happens in practice.
--
Kiryl Shutsemau / Kirill A. Shutemov