Re: [PATCH v3 11/16] KVM: TDX: Add x86 ops for external spt cache

Edgecombe, Rick P
2025-09-30T17:54:42Z

On Tue, 2025-09-30 at 09:02 +0800, Yan Zhao wrote:
> On Thu, Sep 18, 2025 at 04:22:19PM -0700, Rick Edgecombe wrote:
> >    if (kvm_has_mirrored_tdp(vcpu->kvm)) {
> > - r = kvm_mmu_topup_memory_cache(&vcpu->arch.mmu_external_spt_cache,
> > -        PT64_ROOT_MAX_LEVEL);
> > + r = kvm_x86_call(topup_external_fault_cache)(vcpu);
> Another concern about the topup op is that it entirely hides the page count from
> KVM mmu core and assumes the page table level KVM requests is always
> PT64_ROOT_MAX_LEVEL.

That's a good point. Core MMU *does* care about the number of times it calls
alloc_external_fault_cache(). It should take a count with respect to that, and
internally TDX code can adjust it up to include DPAMT pages if needed.

>
> This assumption will not hold true for split cache for huge pages, where only
> a single level is needed and memory for sp, sp->spt, and sp->external_spt does
> not need to be allocated from the split cache. [1].