From: Chao Gao <chao.gao@intel.com>
To: Dave Hansen <dave.hansen@intel.com>
Cc: <linux-coco@lists.linux.dev>, <linux-kernel@vger.kernel.org>,
<kvm@vger.kernel.org>, <x86@kernel.org>,
<reinette.chatre@intel.com>, <ira.weiny@intel.com>,
<kai.huang@intel.com>, <dan.j.williams@intel.com>,
<yilun.xu@linux.intel.com>, <sagis@google.com>,
<vannapurve@google.com>, <paulmck@kernel.org>,
<nik.borisov@suse.com>, <zhenzhong.duan@intel.com>,
<seanjc@google.com>, <rick.p.edgecombe@intel.com>,
<kas@kernel.org>, <dave.hansen@linux.intel.com>,
<vishal.l.verma@intel.com>, Farrah Chen <farrah.chen@intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H. Peter Anvin" <hpa@zytor.com>
Subject: Re: [PATCH v3 06/26] x86/virt/tdx: Prepare to support P-SEAMLDR SEAMCALLs
Date: Thu, 29 Jan 2026 22:55:54 +0800 [thread overview]
Message-ID: <aXt0+lRvpvf5knKP@intel.com> (raw)
In-Reply-To: <e2245231-ee39-40aa-bfdc-e43419fa30f4@intel.com>
On Wed, Jan 28, 2026 at 03:03:14PM -0800, Dave Hansen wrote:
>On 1/23/26 06:55, Chao Gao wrote:
>> P-SEAMLDR is another component alongside the TDX module within the
>> protected SEAM range. P-SEAMLDR can update the TDX module at runtime.
>> Software can talk with P-SEAMLDR via SEAMCALLs with the bit 63 of RAX
>> (leaf number) set to 1 (a.k.a P-SEAMLDR SEAMCALLs).
>
>This text kinda bugs me. It's OK, but needs improvement.
>
>First, don't explain the ABI in the changelog. Nobody cares that it's
>bit 63.
>
>
>Background:
>
> The TDX architecture uses the "SEAMCALL" instruction to
> communicate with SEAM mode software. Right now, the only SEAM
> mode software that the kernel communicates with is the TDX
> module. But, there are actually some components that run in SEAM
> mode but that are separate from the TDX module: that SEAM
> loaders. Right now, the only component that communicates with
> them is the BIOS which loads the TDX module itself at boot. But,
> to support updating the TDX module, the kernel now needs to be
> able to talk to one of the the SEAM loaders: the Persistent
> loader or "P-SEAMLDR".
Thanks. This is much clearer than my version.
One tiny nit: NP-SEAMLDR isn't SEAM mode software. It is an authenticated code
module (ACM).
>
>Then do this part:
>
>> P-SEAMLDR SEAMCALLs differ from SEAMCALLs of the TDX module in terms of
>> error codes and the handling of the current VMCS.
>Except I don't even know how the TDX module handles the current VMCS.
>That probably needs to be in there. Or, it should be brought up in the
>patch itself that implements this. Or, uplifted to the cover letter.
My logic was:
1. The kernel communicates with P-SEAMLDR via SEAMCALL, just like with the TDX
Module.
2. But P-SEAMLDR SEAMCALLs and TDX Module SEAMCALLs are slightly different.
So we need some tweaks to the low-level helpers to add separate wrappers for
P-SEAMLDR SEAMCALLs.
To me, without mentioning #2, these tweaks in this patch (for separate wrappers
in the next patch) aren't justified.
<snip>
>> static __always_inline u64 sc_retry(sc_func_t func, u64 fn,
>> struct tdx_module_args *args)
>> {
>> + u64 retry_code = TDX_RND_NO_ENTROPY;
>> int retry = RDRAND_RETRY_LOOPS;
>> u64 ret;
>>
>> + if (unlikely(is_seamldr_call(fn)))
>> + retry_code = SEAMLDR_RND_NO_ENTROPY;
>
>(un)likey() has two uses:
>
>1. It's in performance critical code and compilers have been
> demonstrated to be generating bad code.
>2. It's in code where it's not obvious what the fast path is
> and (un)likey() makes the code more readable.
>
>Which one is this?
I think #2 although I am happy to drop "unlikely".
>
>Second, this is nitpicky, but I'd rather this be:
>
> if (is_seamldr_call(fn))
> retry_code = SEAMLDR_RND_NO_ENTROPY;
> else
> retry_code = TDX_RND_NO_ENTROPY;
Will do.
<snip>
>> +static inline void seamldr_err(u64 fn, u64 err, struct tdx_module_args *args)
>> +{
>> + /*
>> + * Note: P-SEAMLDR leaf numbers are printed in hex as they have
>> + * bit 63 set, making them hard to read and understand if printed
>> + * in decimal
>> + */
>> + pr_err("P-SEAMLDR (%llx) failed: %#016llx\n", fn, err);
>> +}
>
>Oh, lovely.
>
>Didn't you just propose changing the module SEAMCALL leaf numbers in
>decimal? Isn't it a little crazy to do one in decimal and the other in hex?
Yes, that's crazy. I'll just reuse seamcall_err(), so leaf numbers will be
printed in hex for both the TDX Module and P-SEAMLDR
>
>I'd really rather just see the TDX documentation changed.
I'll submit a request for TDX documentation to display leaf numbers in both hex
and decimal.
>
>But, honestly, I'd probably just leave the thing in hex, drop this hunk,
>and go thwack someone that writes TDX module documentation instead.
>
>> static __always_inline int sc_retry_prerr(sc_func_t func,
>> sc_err_func_t err_func,
>> u64 fn, struct tdx_module_args *args)
>> @@ -96,4 +119,7 @@ static __always_inline int sc_retry_prerr(sc_func_t func,
>> #define seamcall_prerr_ret(__fn, __args) \
>> sc_retry_prerr(__seamcall_ret, seamcall_err_ret, (__fn), (__args))
>>
>> +#define seamldr_prerr(__fn, __args) \
>> + sc_retry_prerr(__seamcall, seamldr_err, (__fn), (__args))
This can be dropped if we don't need to add seamldr_err().
next prev parent reply other threads:[~2026-01-29 14:56 UTC|newest]
Thread overview: 132+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-23 14:55 [PATCH v3 00/26] Runtime TDX Module update support Chao Gao
2026-01-23 14:55 ` [PATCH v3 01/26] x86/virt/tdx: Print SEAMCALL leaf numbers in decimal Chao Gao
2026-01-26 10:01 ` Tony Lindgren
2026-01-28 1:28 ` Binbin Wu
2026-01-28 16:26 ` Dave Hansen
2026-01-29 5:44 ` Chao Gao
2026-01-23 14:55 ` [PATCH v3 02/26] x86/virt/tdx: Use %# prefix for hex values in SEAMCALL error messages Chao Gao
2026-01-26 10:02 ` Tony Lindgren
2026-01-28 1:34 ` Binbin Wu
2026-01-28 12:16 ` Chao Gao
2026-01-28 15:18 ` Dave Hansen
2026-01-23 14:55 ` [PATCH v3 03/26] x86/virt/tdx: Move low level SEAMCALL helpers out of <asm/tdx.h> Chao Gao
2026-01-26 10:02 ` Tony Lindgren
2026-01-28 1:37 ` Binbin Wu
2026-01-28 12:42 ` Chao Gao
2026-01-28 16:31 ` Dave Hansen
2026-01-29 14:02 ` Chao Gao
2026-01-29 16:03 ` Dave Hansen
2026-01-28 16:37 ` Dave Hansen
2026-01-29 8:04 ` Chao Gao
2026-01-23 14:55 ` [PATCH v3 04/26] coco/tdx-host: Introduce a "tdx_host" device Chao Gao
2026-01-26 9:52 ` Tony Lindgren
2026-01-28 16:53 ` Dave Hansen
2026-01-28 3:24 ` Binbin Wu
2026-01-29 7:26 ` Xu Yilun
2026-01-23 14:55 ` [PATCH v3 05/26] coco/tdx-host: Expose TDX Module version Chao Gao
2026-01-26 9:54 ` Tony Lindgren
2026-01-28 3:48 ` Binbin Wu
2026-01-28 17:01 ` Dave Hansen
2026-01-29 14:07 ` Chao Gao
2026-01-29 7:38 ` Xu Yilun
2026-01-23 14:55 ` [PATCH v3 06/26] x86/virt/tdx: Prepare to support P-SEAMLDR SEAMCALLs Chao Gao
2026-01-26 10:05 ` Tony Lindgren
2026-01-28 5:58 ` Binbin Wu
2026-01-28 23:03 ` Dave Hansen
2026-01-29 9:46 ` Xu Yilun
2026-01-29 16:08 ` Dave Hansen
2026-01-29 14:55 ` Chao Gao [this message]
2026-01-29 16:59 ` Dave Hansen
2026-01-23 14:55 ` [PATCH v3 07/26] x86/virt/seamldr: Introduce a wrapper for " Chao Gao
2026-01-26 10:12 ` Tony Lindgren
2026-01-28 6:38 ` Binbin Wu
2026-01-28 23:04 ` Dave Hansen
2026-01-30 8:08 ` Chao Gao
2026-01-30 16:23 ` Dave Hansen
2026-01-28 23:36 ` Dave Hansen
2026-01-30 13:21 ` Chao Gao
2026-01-30 16:18 ` Dave Hansen
2026-02-03 12:15 ` Chao Gao
2026-02-03 15:41 ` Sean Christopherson
2026-02-03 16:12 ` Dave Hansen
2026-02-03 23:54 ` Chao Gao
2026-02-05 16:29 ` Sean Christopherson
2026-02-05 16:37 ` Dave Hansen
2026-01-23 14:55 ` [PATCH v3 08/26] x86/virt/seamldr: Retrieve P-SEAMLDR information Chao Gao
2026-01-26 10:15 ` Tony Lindgren
2026-01-28 6:50 ` Binbin Wu
2026-01-28 23:54 ` Dave Hansen
2026-01-30 4:01 ` Xu Yilun
2026-01-30 16:35 ` Dave Hansen
2026-02-02 0:16 ` Xu Yilun
2026-01-30 13:55 ` Chao Gao
2026-01-30 16:06 ` Dave Hansen
2026-01-28 23:57 ` Dave Hansen
2026-01-30 13:30 ` Chao Gao
2026-01-23 14:55 ` [PATCH v3 09/26] coco/tdx-host: Expose P-SEAMLDR information via sysfs Chao Gao
2026-01-26 9:56 ` Tony Lindgren
2026-01-28 3:07 ` Huang, Kai
2026-01-29 0:08 ` Dave Hansen
2026-01-30 14:44 ` Chao Gao
2026-01-30 16:02 ` Dave Hansen
2026-01-23 14:55 ` [PATCH v3 10/26] coco/tdx-host: Implement FW_UPLOAD sysfs ABI for TDX Module updates Chao Gao
2026-01-26 10:00 ` Tony Lindgren
2026-01-28 3:30 ` Huang, Kai
2026-01-30 14:07 ` Xu Yilun
2026-02-06 17:15 ` Xing, Cedric
2026-01-23 14:55 ` [PATCH v3 11/26] x86/virt/seamldr: Block TDX Module updates if any CPU is offline Chao Gao
2026-01-26 10:16 ` Tony Lindgren
2026-02-02 0:31 ` Xu Yilun
2026-01-23 14:55 ` [PATCH v3 12/26] x86/virt/seamldr: Verify availability of slots for TDX Module updates Chao Gao
2026-01-26 10:17 ` Tony Lindgren
2026-01-23 14:55 ` [PATCH v3 13/26] x86/virt/seamldr: Allocate and populate a module update request Chao Gao
2026-01-26 10:23 ` Tony Lindgren
2026-01-27 3:21 ` Huang, Kai
2026-01-28 11:28 ` Chao Gao
2026-01-28 22:33 ` Huang, Kai
2026-01-28 4:03 ` Huang, Kai
2026-01-30 14:56 ` Chao Gao
2026-02-02 3:08 ` Xu Yilun
2026-01-23 14:55 ` [PATCH v3 14/26] x86/virt/seamldr: Introduce skeleton for TDX Module updates Chao Gao
2026-01-26 10:28 ` Tony Lindgren
2026-02-02 6:01 ` Xu Yilun
2026-01-23 14:55 ` [PATCH v3 15/26] x86/virt/seamldr: Abort updates if errors occurred midway Chao Gao
2026-01-26 10:31 ` Tony Lindgren
2026-02-02 6:08 ` Xu Yilun
2026-01-23 14:55 ` [PATCH v3 16/26] x86/virt/seamldr: Shut down the current TDX module Chao Gao
2026-01-26 10:42 ` Tony Lindgren
2026-02-02 6:31 ` Xu Yilun
2026-01-23 14:55 ` [PATCH v3 17/26] x86/virt/tdx: Reset software states after TDX module shutdown Chao Gao
2026-01-26 10:43 ` Tony Lindgren
2026-01-23 14:55 ` [PATCH v3 18/26] x86/virt/seamldr: Log TDX Module update failures Chao Gao
2026-01-26 10:45 ` Tony Lindgren
2026-02-02 7:11 ` Xu Yilun
2026-01-23 14:55 ` [PATCH v3 19/26] x86/virt/seamldr: Install a new TDX Module Chao Gao
2026-01-26 10:52 ` Tony Lindgren
2026-01-23 14:55 ` [PATCH v3 20/26] x86/virt/seamldr: Do TDX per-CPU initialization after updates Chao Gao
2026-01-26 10:53 ` Tony Lindgren
2026-02-02 7:32 ` Xu Yilun
2026-01-23 14:55 ` [PATCH v3 21/26] x86/virt/tdx: Establish contexts for the new TDX Module Chao Gao
2026-01-26 10:54 ` Tony Lindgren
2026-01-23 14:55 ` [PATCH v3 22/26] x86/virt/tdx: Update tdx_sysinfo and check features post-update Chao Gao
2026-01-26 11:07 ` Tony Lindgren
2026-02-02 7:33 ` Xu Yilun
2026-01-23 14:55 ` [PATCH v3 23/26] x86/virt/tdx: Enable TDX Module runtime updates Chao Gao
2026-01-26 11:14 ` Tony Lindgren
2026-02-04 10:03 ` Tony Lindgren
2026-02-02 7:41 ` Xu Yilun
2026-01-23 14:55 ` [PATCH v3 24/26] x86/virt/seamldr: Extend sigstruct to 16KB Chao Gao
2026-01-26 11:15 ` Tony Lindgren
2026-01-27 3:58 ` Huang, Kai
2026-01-28 23:01 ` Huang, Kai
2026-01-30 14:25 ` Chao Gao
2026-02-02 11:57 ` Huang, Kai
2026-01-23 14:55 ` [PATCH v3 25/26] x86/virt/tdx: Avoid updates during update-sensitive operations Chao Gao
2026-01-26 11:23 ` Tony Lindgren
2026-01-23 14:55 ` [PATCH v3 26/26] coco/tdx-host: Set and document TDX Module update expectations Chao Gao
2026-01-26 11:28 ` Tony Lindgren
2026-01-26 22:14 ` dan.j.williams
2026-01-27 12:17 ` Chao Gao
2026-01-27 17:23 ` dan.j.williams
2026-01-28 17:52 ` [PATCH v3 00/26] Runtime TDX Module update support Sagi Shahar
2026-01-29 1:51 ` Chao Gao
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=aXt0+lRvpvf5knKP@intel.com \
--to=chao.gao@intel.com \
--cc=bp@alien8.de \
--cc=dan.j.williams@intel.com \
--cc=dave.hansen@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=farrah.chen@intel.com \
--cc=hpa@zytor.com \
--cc=ira.weiny@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=nik.borisov@suse.com \
--cc=paulmck@kernel.org \
--cc=reinette.chatre@intel.com \
--cc=rick.p.edgecombe@intel.com \
--cc=sagis@google.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=vannapurve@google.com \
--cc=vishal.l.verma@intel.com \
--cc=x86@kernel.org \
--cc=yilun.xu@linux.intel.com \
--cc=zhenzhong.duan@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