Kernel KVM virtualization development
 help / color / mirror / Atom feed
From: Yan Zhao <yan.y.zhao@intel.com>
To: kas@kernel.org, dave.hansen@linux.intel.com
Cc: x86@kernel.org, linux-kernel@vger.kernel.org,
	kvm@vger.kernel.org, linux-coco@lists.linux.dev,
	rick.p.edgecombe@intel.com, seanjc@google.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,
	yan.y.zhao@intel.com, Dave Hansen <dave.hansen@intel.com>
Subject: [PATCH] x86/virt/tdx: Warn on !4K level in tdh_mem_page_aug()
Date: Tue, 25 Aug 2026 10:55:33 +0800	[thread overview]
Message-ID: <20260825025533.25663-1-yan.y.zhao@intel.com> (raw)

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 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.

Reported-by: Kiryl Shutsemau <kas@kernel.org>
Closes: https://lore.kernel.org/all/abvxiuJfK2eM_1UX@thinkstation
Suggested-by: Dave Hansen <dave.hansen@intel.com>
Suggested-by: Rick Edgecombe <rick.p.edgecombe@intel.com>
Signed-off-by: Yan Zhao <yan.y.zhao@intel.com>
---
 arch/x86/virt/vmx/tdx/tdx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/x86/virt/vmx/tdx/tdx.c b/arch/x86/virt/vmx/tdx/tdx.c
index 42df8ea464c4..5c0e91b4aa4f 100644
--- a/arch/x86/virt/vmx/tdx/tdx.c
+++ b/arch/x86/virt/vmx/tdx/tdx.c
@@ -1722,6 +1722,8 @@ u64 tdh_mem_page_aug(struct tdx_td *td, u64 gpa, enum pg_level level,
 	};
 	u64 ret;
 
+	/* TODO: handle large pages. */
+	WARN_ON_ONCE(level != PG_LEVEL_4K);
 	tdx_clflush_pfn(pfn);
 	ret = seamcall_ret(TDH_MEM_PAGE_AUG, &args);
 

base-commit: 1b731e5ded480bd1e5546aed35584238661ce72e
-- 
2.43.2


             reply	other threads:[~2026-08-25  2:55 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-25  2:55 Yan Zhao [this message]
2026-08-25 17:15 ` [PATCH] x86/virt/tdx: Warn on !4K level in tdh_mem_page_aug() Edgecombe, Rick P
2026-08-25 17:48   ` Sean Christopherson
2026-08-25 18:19     ` Edgecombe, Rick P
     [not found] ` <ao2ZH8dmkPfBDnGv@google.com>
2026-08-26  7:23   ` Yan Zhao
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

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=20260825025533.25663-1-yan.y.zhao@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