Re: [PATCH v4 03/17] KVM: TDX: Reset private huge pages after S-EPT page removal
From: Yan Zhao
Date: Sat Oct 10 2026 - 05:23:39 EST
On Wed, Oct 07, 2026 at 08:06:29AM +0800, Edgecombe, Rick P wrote:
> On Mon, 2026-09-28 at 17:08 +0800, Yan Zhao wrote:
> > "Resetting" TDX pages is a workaround for the TDX_PW_MCE erratum. Once a
> > leaf SPTE can map to a huge page in the S-EPT, the entire huge physical
> > range, rather than just the first 4KB, needs to be reset before the host
> > can reuse it.
>
> Code looks good and simple enough, but the log is a tiny bit rough. Probably add
> about TDX_PW_MCE needing to reset any private memory in a special way, and make
> it clearer that TDX huge pages will be enabled in upcoming changes. And is not
> supported today (so this is not a bug fix).
Thanks for the suggestion.
What about:
"
On TDX_PW_MCE erratum platforms, a partial write (with KeyID 0) to a TDX
private memory cacheline will silently "poison" the line. A subsequent read
triggers a machine check.
On such platforms, "resetting" TDX private pages by invoking MOVDIR64B on
the previous TDX private memory before returning them to the host is
required to avoid potential machine checks.
Before introducing huge page support, the reset size is forced to 4KB when
removing a private leaf mapping. To prepare for the upcoming changes to
allow mapping and unmapping private memory as a huge page, update the reset
size to the actual mapping size to support resetting the entire huge page
range.
"
> > Signed-off-by: Yan Zhao <yan.y.zhao@xxxxxxxxx>
> > ---
> > arch/x86/kvm/vmx/tdx.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/arch/x86/kvm/vmx/tdx.c b/arch/x86/kvm/vmx/tdx.c
> > index 410c149bf776..11792a490330 100644
> > --- a/arch/x86/kvm/vmx/tdx.c
> > +++ b/arch/x86/kvm/vmx/tdx.c
> > @@ -1865,7 +1865,7 @@ static int tdx_sept_remove_leaf_spte(struct kvm *kvm, gfn_t gfn,
> > if (TDX_BUG_ON_2(err, TDH_MEM_PAGE_REMOVE, entry, level_state, kvm))
> > return -EIO;
> >
> > - tdx_quirk_reset_paddr(PFN_PHYS(pfn), PAGE_SIZE);
> > + tdx_quirk_reset_paddr(PFN_PHYS(pfn), KVM_HPAGE_SIZE(level));
> > tdx_pamt_put(pfn, level);
> > return 0;
> > }
>