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

Edgecombe, Rick P
2025-09-26T22:10:55Z

On Tue, 2025-09-23 at 15:03 +0800, Yan Zhao wrote:
> > @@ -625,7 +624,6 @@ static void mmu_free_memory_caches(struct
> > kvm_vcpu *vcpu)
> >    kvm_mmu_free_memory_cache(&vcpu-
> > >arch.mmu_pte_list_desc_cache);
> >    kvm_mmu_free_memory_cache(&vcpu-
> > >arch.mmu_shadow_page_cache);
> >    kvm_mmu_free_memory_cache(&vcpu-
> > >arch.mmu_shadowed_info_cache);
> > - kvm_mmu_free_memory_cache(&vcpu-
> > >arch.mmu_external_spt_cache);
> Though pre-allocated pages are eventually freed in tdx_vcpu_free() in
> patch 13,
> looks they are leaked in this patch.
>
> BTW, why not invoke kvm_x86_call(free_external_fault_cache)(vcpu)
> here?

The thought was to reduce the number of TDX callbacks in core MMU code.

> It looks more natural to free the remaining pre-allocated pages in
> mmu_free_memory_caches(), which is invoked after kvm_mmu_unload(vcpu)
> while tdx_vcpu_free() is before it.

Hmm, that is not so tidy. But on balance I think it would still be
better to leave it more contained in TDX code. Any strong objection?