From: Sean Christopherson <seanjc@google.com>
To: Yan Zhao <yan.y.zhao@intel.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: Tue, 25 Aug 2026 06:31:11 -0700 [thread overview]
Message-ID: <ao2ZH8dmkPfBDnGv@google.com> (raw)
In-Reply-To: <20260825025533.25663-1-yan.y.zhao@intel.com>
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.
diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
index 42df8ea464c4..1a83857eb7e6 100644
--- a/arch/x86/virt/vmx/tdx/tdx.c
+++ b/arch/x86/virt/vmx/tdx/tdx.c
@@ -1628,9 +1628,9 @@ static void tdx_clflush_page(struct page *page)
clflush_cache_range(page_to_virt(page), PAGE_SIZE);
}
-static void tdx_clflush_pfn(kvm_pfn_t pfn)
+static void tdx_clflush_pfn(kvm_pfn_t pfn, enum pg_level level)
{
- clflush_cache_range(__va(PFN_PHYS(pfn)), PAGE_SIZE);
+ clflush_cache_range(__va(PFN_PHYS(pfn)), page_level_size(level));
}
static int pg_level_to_tdx_sept_level(enum pg_level level)
@@ -1670,7 +1670,7 @@ u64 tdh_mem_page_add(struct tdx_td *td, u64 gpa, kvm_pfn_t pfn, struct page *sou
};
u64 ret;
- tdx_clflush_pfn(pfn);
+ tdx_clflush_pfn(pfn, PG_LEVEL_4K);
ret = seamcall_ret(TDH_MEM_PAGE_ADD, &args);
*ext_err1 = args.rcx;
@@ -1722,7 +1722,7 @@ u64 tdh_mem_page_aug(struct tdx_td *td, u64 gpa, enum pg_level level,
};
u64 ret;
- tdx_clflush_pfn(pfn);
+ tdx_clflush_pfn(pfn, level);
ret = seamcall_ret(TDH_MEM_PAGE_AUG, &args);
*ext_err1 = args.rcx;
next prev parent reply other threads:[~2026-08-25 13:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 2:55 [PATCH] x86/virt/tdx: Warn on !4K level in tdh_mem_page_aug() Yan Zhao
2026-08-25 13:31 ` Sean Christopherson [this message]
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=ao2ZH8dmkPfBDnGv@google.com \
--to=seanjc@google.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=tglx@kernel.org \
--cc=vannapurve@google.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