Re: [PATCH v3 12/16] x86/virt/tdx: Add helpers to allow for pre-allocating pages
From: Yan Zhao
Date: Sat Sep 27 2025 - 21:42:08 EST
On Sat, Sep 27, 2025 at 06:05:12AM +0800, Edgecombe, Rick P wrote:
> On Fri, 2025-09-26 at 09:44 +0800, Yan Zhao wrote:
> > > - return kvm_mmu_topup_memory_cache(&tdx-
> > > >mmu_external_spt_cache,
> > > - PT64_ROOT_MAX_LEVEL);
> > > + /* External page tables */
> > > + min_fault_cache_size = PT64_ROOT_MAX_LEVEL;
> >
> > min_fault_cache_size = PT64_ROOT_MAX_LEVEL - 1?
> > We don't need to allocate page for the root page.
>
> Why change it in this patch?
The previous size determined by TDP MMU core was just unnecessarily 1 more than
required (I guess it's due to historical reasons).
But since now the size is determined by TDX itself, I think it can be accurate.
> > > + /* Dynamic PAMT pages (if enabled) */
> > > + min_fault_cache_size += tdx_dpamt_entry_pages() *
> > > PT64_ROOT_MAX_LEVEL;
> > > +
> > What about commenting that it's
> > tdx_dpamt_entry_pages() * ((PT64_ROOT_MAX_LEVEL - 1) + 1) ?
> > i.e.,
> > (PT64_ROOT_MAX_LEVEL - 1) for page table pages, and 1 for guest
> > private page.
>
> Yes the comment could be improved. I'll enhance it. Thanks.