mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
To: "Hansen, Dave" <dave.hansen@intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"yilun.xu@linux.intel.com" <yilun.xu@linux.intel.com>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"x86@kernel.org" <x86@kernel.org>
Cc: "Xu, Yilun" <yilun.xu@intel.com>,
	"linux-coco@lists.linux.dev" <linux-coco@lists.linux.dev>,
	"kas@kernel.org" <kas@kernel.org>,
	"nik.borisov@suse.com" <nik.borisov@suse.com>
Subject: Re: [PATCH v5] x86/virt/tdx: Formalize SEAMCALL leaf version encoding support
Date: Thu, 10 Sep 2026 20:14:00 +0000	[thread overview]
Message-ID: <9e59449810c33a41ff37a2babc322261c1d918e0.camel@intel.com> (raw)
In-Reply-To: <20260901105436.461823-1-yilun.xu@linux.intel.com>

On Tue, 2026-09-01 at 18:54 +0800, Xu Yilun wrote:
> The TDX architecture includes a syscall-like ABI for OSes to communicate
> with SEAM mode software. This ABI has the concept of a "leaf". Each leaf
> is roughly analogous to a Linux syscall: it has a set of register
> arguments and does one logical thing like adding a page of memory to a
> VM or running a VM. The TDX architecture refers to this interface
> function as a "SEAMCALL leaf".
> 
> Just like syscalls, the TDX architecture wants to evolve the ABI to
> extend functionality while keeping compatibility. But unlike syscalls,
> which do this by picking a totally new syscall number, the ABI encodes
> the "version" number directly into the bits of a register argument. So
> instead of openatN being whatever the next free number is, the SEAMCALL
> leaf number and version number are encoded into certain bits in how the
> RAX register is defined in the ABI.
> 
> In Linux, several seamcall*() wrappers have been introduced to invoke
> SEAMCALL leafs. They all take a u64 "fn" argument for the leaf number
> which eventually get set in the register. As above, the version number
> lives in the same register as the leaf number. So callers that want to
> select a specific version of the leaf, can jam it in the right place in
> the register by passing it in the "fn" argument. 
> 


> Today only the caller
> of TDH.VP.INIT does this hack, but future kernel changes will need to
> select versions for more SEAMCALL leafs, so a less hacky solution is
> needed.

Only nit is that this would probably read a little bit smoother as two
sentences. Everything else looks good.

Reviewed-by: Rick Edgecombe <rick.p.edgecombe@intel.com>

> 
> Explicitly define the arguments for seamcall*() wrappers:
> 
>   - Add a build-time assertion to ensure "fn" only contains valid
>     SEAMCALL leaf number bits. Note the P-SEAMLDR selector bit (bit 63)
>     is part of the leaf number for SEAM loader calls, so it is allowed.
>     This also means the "fn" can't be a narrower type, such as u16, to
>     exclude unrelated bits.
> 
>   - Add a "version" field in struct tdx_module_args [1], so most
>     existing callers get a default "version == 0" behavior without code
>     churn. Update the TDH.VP.INIT caller to specify the version
>     descriptively.
> 
> Encode the leaf number and tdx_module_args.version into RAX in assembly,
> because this is the place where the "fn" and struct tdx_module_args
> fields are marshaled into registers.
> 
> AI was used under supervision to review code and workshop logs. In
> particular, it helped evaluate the assembly changes.
> 
> Signed-off-by: Xu Yilun <yilun.xu@linux.intel.com>
> Reviewed-by: Kiryl Shutsemau (Meta) <kas@kernel.org>
> Reviewed-by: Nikolay Borisov <nik.borisov@suse.com>
> Link: https://lore.kernel.org/kvm/4f4b0f29-424b-45ed-8cfd-c77da2ea390f@intel.com/ # [1]


  parent reply	other threads:[~2026-09-10 20:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 10:54 Xu Yilun
2026-09-07 11:20 ` Tony Lindgren
2026-09-07 14:35   ` Dave Hansen
2026-09-08  2:06     ` Xu Yilun
2026-09-08  6:26 ` Binbin Wu
2026-09-08  9:43   ` Xu Yilun
2026-09-10  6:21     ` Binbin Wu
2026-09-10 20:14 ` Edgecombe, Rick P [this message]
2026-09-10 20:15   ` 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=9e59449810c33a41ff37a2babc322261c1d918e0.camel@intel.com \
    --to=rick.p.edgecombe@intel.com \
    --cc=dave.hansen@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=kas@kernel.org \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nik.borisov@suse.com \
    --cc=x86@kernel.org \
    --cc=yilun.xu@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®