From: Binbin Wu <binbin.wu@linux.intel.com>
To: Rick Edgecombe <rick.p.edgecombe@intel.com>
Cc: pbonzini@redhat.com, dave.hansen@intel.com, seanjc@google.com,
x86@kernel.org, kas@kernel.org, adrian.hunter@intel.com,
yan.y.zhao@intel.com, binbin.wu@intel.com, xiaoyao.li@intel.com,
chao.gao@intel.com, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org, nik.borisov@suse.com,
yilun.xu@linux.intel.com, tony.lindgren@linux.intel.com
Subject: Re: [PATCH v2 2/2] x86/virt/tdx: Drop tdh_phymem_page_wbinvd_*()
Date: Tue, 20 Oct 2026 16:55:53 +0800 [thread overview]
Message-ID: <d872b0f0-9992-455f-9f04-4313fd185cf2@linux.intel.com> (raw)
In-Reply-To: <20261015191710.3632302-3-rick.p.edgecombe@intel.com>
On 10/16/2026 3:17 AM, Rick Edgecombe wrote:
> In the early days of TDX it was expected that pages being reclaimed from
> the TDX module would need any cacheline from their private KeyID alias
> flushed. The TDX docs describe doing this in a couple narrow cases, for
> example reclaiming the TDR memory or guest private memory.
>
> Similar to how the CLFLUSH_BEFORE_ALLOC features0 bit was never actually
> set in any TDX module, the flush of the private KeyID cachelines turned
> out to not be needed by the final TDX HW either. However, the TDX docs
> were never updated to reflect that.
>
> CLFLUSH_BEFORE_ALLOC handles flushing when giving memory to the TDX
> module, where the alias that needs flushing is the default, normal KeyID
> 0. This was done with a clflush of the kernel's KeyID 0 mapping of the
> memory. For the reclaim path, instead it is the TDX KeyID aliases that
> need to be flushed. Since virtual mappings for these aliases are
> restricted to the TDX module, the module is the only thing that can map
> the page to do the clflush. The TDH.PHYMEM.PAGE.WBINVD SEAMCALL leaf was
> created to facilitate this.
>
> The docs are being updated to clarify that calling TDH.PHYMEM.PAGE.WBINVD
> is not needed. So drop the kernel code that calls this SEAMCALL and the
> helpers that facilitate it. With the removal of
> tdh_phymem_page_wbinvd_tdr(), tdx_global_keyid no longer needs to be kept
> around as a global variable. It just needs to be selected and provided to
> the TDX module during initial setup.
>
> However, don't churn the code to remove the global variable because
> it fits neatly with the other KeyID partitioning global data. It is also
> foreseeable that this would be used in the future for other SEAMCALLs that
> require passing the global KeyID.
>
> KVM previously needed to call different types of tdh_phymem_page_wbinvd_*()
> helpers for different types of reclaim. So it had a stack of helpers and
> some open coded logic to use them in the rarer TDR reclaim case. Now that
> the wbinvd is gone, the steps for each operation are logically equivalent.
> So collapse the helpers and just call tdx_reclaim_control_page() from the
> TDR reclaim path.
>
> This unification brings TDR reclaim in line with the behavior of the other
> reclaim paths, by handling TDH.PHYMEM.PAGE.RECLAIM failure by leaking the
> page and setting the TDR page pointer to NULL. This results in reclaim not
> being tried a second time, which is reasonable because the first reclaim
> failing suggests a problem with the TDX module.
>
> AI was used to review the change.
>
> Signed-off-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Reviewed-by: Binbin Wu <binbin.wu@linux.intel.com>
next prev parent reply other threads:[~2026-10-20 8:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 19:17 [PATCH v2 0/2] Drop unneeded cache flushing Rick Edgecombe
2026-10-15 19:17 ` [PATCH v2 1/2] x86/virt/tdx: Drop tdx_clflush_*() Rick Edgecombe
2026-10-15 19:17 ` [PATCH v2 2/2] x86/virt/tdx: Drop tdh_phymem_page_wbinvd_*() Rick Edgecombe
2026-10-20 8:55 ` Binbin Wu [this message]
2026-10-19 8:36 ` [PATCH v2 0/2] Drop unneeded cache flushing Nikolay Borisov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d872b0f0-9992-455f-9f04-4313fd185cf2@linux.intel.com \
--to=binbin.wu@linux.intel.com \
--cc=adrian.hunter@intel.com \
--cc=binbin.wu@intel.com \
--cc=chao.gao@intel.com \
--cc=dave.hansen@intel.com \
--cc=kas@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nik.borisov@suse.com \
--cc=pbonzini@redhat.com \
--cc=rick.p.edgecombe@intel.com \
--cc=seanjc@google.com \
--cc=tony.lindgren@linux.intel.com \
--cc=x86@kernel.org \
--cc=xiaoyao.li@intel.com \
--cc=yan.y.zhao@intel.com \
--cc=yilun.xu@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®