Re: [RFC PATCH v5 20/45] KVM: x86/mmu: Allocate/free S-EPT pages using tdx_{alloc,free}_control_page()
From: Sean Christopherson
Date: Tue Feb 03 2026 - 15:17:45 EST
On Tue, Feb 03, 2026, Kai Huang wrote:
> On Wed, 2026-01-28 at 17:14 -0800, Sean Christopherson wrote:
> > int (*set_external_spte)(struct kvm *kvm, gfn_t gfn, enum pg_level level,
> > u64 mirror_spte);
> > -
> > - /* Update external page tables for page table about to be freed. */
> > void (*reclaim_external_sp)(struct kvm *kvm, gfn_t gfn,
> > struct kvm_mmu_page *sp);
> > -
> > - /* Update external page table from spte getting removed, and flush TLB. */
>
> The above two comments are still useful to me.
>
> Not sure why do you want to remove them, especially in _this_ patch?
My intent was to replace the individual comments with a more generic comment for
all of the "external" hooks. For things like "and flush TLB", IMO those comments
belong at the call sites, not at this point. E.g. _KVM_ doesn't require a TLB
flush in all cases. And so for the definition of the hooks, I would prefer a more
generic comment, so that if there are details that matter to the usage, they are
documented there.
> > void (*remove_external_spte)(struct kvm *kvm, gfn_t gfn, enum pg_level level,
> > u64 mirror_spte);
> >
> > +
>
> Unintentional change?
Ya.
>
> > bool (*has_wbinvd_exit)(void);
> >
> > u64 (*get_l2_tsc_offset)(struct kvm_vcpu *vcpu);
> > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> > index 3911ac9bddfd..9b5a6861e2a4 100644
> > --- a/arch/x86/kvm/mmu/mmu.c
> > +++ b/arch/x86/kvm/mmu/mmu.c
> > @@ -6690,11 +6690,13 @@ int kvm_mmu_create(struct kvm_vcpu *vcpu)
> > vcpu->arch.mmu_page_header_cache.kmem_cache = mmu_page_header_cache;
> > vcpu->arch.mmu_page_header_cache.gfp_zero = __GFP_ZERO;
> >
> > - vcpu->arch.mmu_shadow_page_cache.init_value =
> > - SHADOW_NONPRESENT_VALUE;
> > + vcpu->arch.mmu_shadow_page_cache.init_value = SHADOW_NONPRESENT_VALUE;
> > if (!vcpu->arch.mmu_shadow_page_cache.init_value)
> > vcpu->arch.mmu_shadow_page_cache.gfp_zero = __GFP_ZERO;
>
> Ditto. Not sure this adjustment is intentional?
Heh, I'm pretty sure it was intentional, but yeah, doesn't belong here.