Re: [PATCH 2/2] x86/virt/tdx: Drop tdh_phymem_page_wbinvd_*()
From: Edgecombe, Rick P
Date: Wed Sep 23 2026 - 14:46:45 EST
On Wed, 2026-09-23 at 15:09 +0800, Xu Yilun wrote:
> Since private KeyID virtual mappings are reserved for TDX use, the TDX
> > module has to do the clflush itself.
>
> This paragraph is a little confusing to me. Here reads like the TDX
> module does the clflush internally and the host doesn't have to opt-in.
>
> > The TDH.PHYMEM.PAGE.WBINVD SEAMCALL
> > leaf was created for this purpose.
>
> But the SEAMCALL leaf shows host should opt-in.
>
> Ah, you want to say host can't directly do clflush because of some
> reason, so we need a SEAMCALL, is it?
The host can't map things with private keyids. So it calls into the TDX module
to do it. That was my understanding. On "alloc" you are transitioning from KeyID
0 to some private key, so flush at the KeyID 0 from the host. On reclain it goes
from some private KeyID to 0, so the TDX module needs to flush at the source
alias.
>
> [...]
>
> > @@ -578,15 +577,6 @@ static void tdx_reclaim_td_control_pages(struct kvm
> > *kvm)
> > if (__tdx_reclaim_page(kvm_tdx->td.tdr_page))
> > return;
> >
> > - /*
> > - * Use a SEAMCALL to ask the TDX module to flush the cache based on
> > the
> > - * KeyID. TDX module may access TDR while operating on TD
> > (Especially
> > - * when it is reclaiming TDCS).
> > - */
> > - err = tdh_phymem_page_wbinvd_tdr(&kvm_tdx->td);
> > - if (TDX_BUG_ON(err, TDH_PHYMEM_PAGE_WBINVD, kvm))
> > - return;
> > -
> > tdx_quirk_reset_paddr(page_to_phys(kvm_tdx->td.tdr_page),
> > PAGE_SIZE);
> >
> > __free_page(kvm_tdx->td.tdr_page);
>
> After removing the wbinvd, we don't need open code to reclaim tdr
> anymore, is it? tdx_reclaim_control_page(kvm_tdx->td.tdr_page)?
>
> This may not be relevant to the topic, not sure if we are good to clean
> up it in this series.
Good point. Hmm, I think it is ok to have for this patch. Let me try.
>
>
> Another thing. There are also 2 wbinvd_on_all_cpus() on PAMT
> adding/reclaiming. Remove them?
Ohhh. By the comment, maybe yes. Good point. Let me investigate this one. I
might leave it for future work.