Re: [PATCH v4 12/16] x86/virt/tdx: Add helpers to allow for pre-allocating pages

From: Sean Christopherson

Date: Tue Jan 20 2026 - 19:52:19 EST


On Thu, Nov 20, 2025, Rick Edgecombe wrote:
> static int tdx_topup_external_fault_cache(struct kvm_vcpu *vcpu, unsigned int cnt)
> {
> - struct vcpu_tdx *tdx = to_tdx(vcpu);
> + struct tdx_prealloc *prealloc = &to_tdx(vcpu)->prealloc;
> + int min_fault_cache_size;
>
> - return kvm_mmu_topup_memory_cache(&tdx->mmu_external_spt_cache, cnt);
> + /* External page tables */
> + min_fault_cache_size = cnt;
> + /* Dynamic PAMT pages (if enabled) */
> + min_fault_cache_size += tdx_dpamt_entry_pages() * PT64_ROOT_MAX_LEVEL;

The caller passed in number of pages to be added as @cnt, don't hardcode what
could be conflicting information. If the caller wants to add 50 pages, then this
code damn well needs to prepare for adding 50 pages, not 5.