Re: [PATCH v2 01/15] KVM: TDX: Drop kvm_x86_ops.link_external_spt()
From: Sean Christopherson
Date: Wed May 27 2026 - 14:32:30 EST
On Sat, May 09, 2026, Yan Zhao wrote:
> From: Sean Christopherson <seanjc@xxxxxxxxxx>
>
> Drop the dedicated .link_external_spt() for linking S-EPT pages, and
> instead funnel everything through .set_external_spte() for mapping S-EPT
> entries. Using separate hooks doesn't help prevent TDP MMU details from
> bleeding into TDX, and vice versa; to the contrary, dedicated callbacks
> will result in _more_ pollution when hugepage support is added, e.g. will
> require the TDP MMU to know details about the splitting rules for TDX that
> aren't all that relevant to the TDP MMU.
>
> Ideally, KVM would provide a single pair of hooks to set S-EPT entries,
> one hook for setting SPTEs under write-lock and another for setting SPTEs
> under read-lock (e.g. to ensure the entire operation is "atomic", to allow
> for failure, etc.). Sadly, TDX's requirement that all child S-EPT entries
> are removed before the parent makes that impractical: the TDP MMU
> deliberately prunes non-leaf SPTEs and _then_ processes its children, thus
> making it quite important for the TDP MMU to differentiate between zapping
> leaf and non-leaf S-EPT entries.
>
> However, that's the _only_ case that's truly special, and even that case
> could be shoehorned into a single hook; it just wouldn't be a net positive.
>
> Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
> [Rick: add in trivial feedback]
> Signed-off-by: Rick Edgecombe <rick.p.edgecombe@xxxxxxxxx>
> Signed-off-by: Yan Zhao <yan.y.zhao@xxxxxxxxx>
> ---
> MMU_refactors v2:
> - Moved this patch to the very beginning of the series so that when
> warnings like "KVM_BUG_ON(!is_shadow_present_pte(new_spte), kvm)" are
> removed from __tdp_mmu_set_spte_atomic() in TDP MMU in a later patch, the
> atomic zap change can be propagated via the .set_external_spte() op.
> (Yan).
>
> MMU_refactors v1:
> - rename external_spt->sept_pt (Rick, Yan)
Put the versioning info below the "---" that delineates the diff, otherwise
`git am` adds it to the changelog.
> ---
I.e. put it here.
> arch/x86/include/asm/kvm-x86-ops.h | 1 -
> arch/x86/include/asm/kvm_host.h | 3 --
> arch/x86/kvm/mmu/tdp_mmu.c | 29 +-------------
> arch/x86/kvm/vmx/tdx.c | 63 ++++++++++++++++++++----------
> 4 files changed, 44 insertions(+), 52 deletions(-)