From: Yan Zhao <yan.y.zhao@intel.com>
To: Sean Christopherson <seanjc@google.com>
Cc: <kas@kernel.org>, <dave.hansen@linux.intel.com>, <x86@kernel.org>,
<linux-kernel@vger.kernel.org>, <kvm@vger.kernel.org>,
<linux-coco@lists.linux.dev>, <rick.p.edgecombe@intel.com>,
<pbonzini@redhat.com>, <tglx@kernel.org>, <mingo@redhat.com>,
<bp@alien8.de>, <kai.huang@intel.com>, <yilun.xu@linux.intel.com>,
<vannapurve@google.com>, <ackerleytng@google.com>,
<sagis@google.com>, <binbin.wu@linux.intel.com>,
<xiaoyao.li@intel.com>, Dave Hansen <dave.hansen@intel.com>
Subject: Re: [PATCH] x86/virt/tdx: Warn on !4K level in tdh_mem_page_aug()
Date: Wed, 26 Aug 2026 15:23:01 +0800 [thread overview]
Message-ID: <ao6UVdWNbhQaAFsm@yzhao56-desk.sh.intel.com> (raw)
In-Reply-To: <ao2ZH8dmkPfBDnGv@google.com>
On Tue, Aug 25, 2026 at 06:31:11AM -0700, Sean Christopherson wrote:
> On Tue, Aug 25, 2026, Yan Zhao wrote:
> > Add a warning on a !4K level to loudly flag the unexpected condition when
> > callers pass in a level > 4K before tdh_mem_page_aug() supports huge pages.
> >
> > The warning makes the unexpected condition more obvious since the SEAMCALL
> > TDH_MEM_PAGE_AUG does not necessarily fail when the level is above 4K,
> > while tdh_mem_page_aug() only flushes the cache for a 4K page before huge
> > page support is added.
>
> If the only problem is the lack of CLFLUSH coverage, why not simply fix the
> bug? The changelog spends more effort justifying not fixing a bug than it would
> take to fix the bug.
Yes, the only missing piece for tdh_mem_page_aug() to work with huge pages
is the CLFLUSH coverage, which is exactly what's done in patch 1 [1] of the
TDX huge pages series.
(Note: [1]'s changelog is not well written. I've updated it in the internal
verion of TDX huge page v4 like this:
The SEAMCALL TDH_MEM_PAGE_AUG currently supports adding physical memory to
the S-EPT up to 2MB in size. The wrapper already accepts and passes "level"
to the SEAMCALL. The only missing piece for the wrapper to work with huge
pages correctly is to invoke CLFLUSH on the full huge page range, which
conservatively ensures that any dirty cache lines don't write back later
and clobber TD memory.
).
I should have inluded the justification for why not extending the CLFLUSH
coverage in this changelog.
So, would the following version look better?
Add a warning on a !4K level to loudly flag the unexpected condition when
callers pass in a level > 4K before tdh_mem_page_aug() supports huge pages.
The warning makes the unexpected condition more obvious since the SEAMCALL
TDH_MEM_PAGE_AUG does not necessarily fail when the level is above 4K,
while tdh_mem_page_aug() only flushes the cache for a 4K page before huge
page support is added.
Do not extend the CLFLUSH coverage to make tdh_mem_page_aug() work with
huge pages. Not only would this scatter huge page related changes across
multiple series, but it also makes little sense to have tdh_mem_page_aug()
alone work for huge pages without implementing its counterparts in the
unmapping and splitting paths.
Do not drop the "level" parameter instead, as it will be needed once huge
page support is added.
Do not use a stronger BUG_ON() because the cache flush is only needed when
the TDX module exposes a CLFLUSH_BEFORE_ALLOC bit, which has not yet been
observed in any TDX modules.
[1] https://lore.kernel.org/all/20260129011517.3545883-27-seanjc@google.com
next prev parent reply other threads:[~2026-08-26 7:23 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 2:55 Yan Zhao
2026-08-25 13:31 ` Sean Christopherson
2026-08-26 7:23 ` Yan Zhao [this message]
2026-08-26 13:13 ` Dave Hansen
2026-08-26 13:36 ` Edgecombe, Rick P
2026-08-26 16:23 ` Edgecombe, Rick P
2026-08-27 3:02 ` Yan Zhao
2026-08-25 17:15 ` Edgecombe, Rick P
2026-08-25 17:48 ` Sean Christopherson
2026-08-25 18:19 ` Edgecombe, Rick P
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=ao6UVdWNbhQaAFsm@yzhao56-desk.sh.intel.com \
--to=yan.y.zhao@intel.com \
--cc=ackerleytng@google.com \
--cc=binbin.wu@linux.intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=kai.huang@intel.com \
--cc=kas@kernel.org \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rick.p.edgecombe@intel.com \
--cc=sagis@google.com \
--cc=seanjc@google.com \
--cc=tglx@kernel.org \
--cc=vannapurve@google.com \
--cc=x86@kernel.org \
--cc=xiaoyao.li@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®