Linux Confidential Computing Development
 help / color / mirror / Atom feed
From: Chao Gao <chao.gao@intel.com>
To: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
Cc: "kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"linux-coco@lists.linux.dev" <linux-coco@lists.linux.dev>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Xu, Yilun" <yilun.xu@intel.com>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"baolu.lu@linux.intel.com" <baolu.lu@linux.intel.com>,
	"Peng, Chao P" <chao.p.peng@intel.com>,
	"bp@alien8.de" <bp@alien8.de>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"tglx@kernel.org" <tglx@kernel.org>,
	"Tian, Kevin" <kevin.tian@intel.com>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"kas@kernel.org" <kas@kernel.org>
Subject: Re: [RFC PATCH 2/7] coco/tdx-host: Establish an SPDM session with the device
Date: Tue, 24 Nov 2026 20:59:48 +0800	[thread overview]
Message-ID: <awWKRJQ3_rIgxJVC@intel.com> (raw)
In-Reply-To: <ac7befe5081a489172d87402e55355852a9e62ac.camel@intel.com>

On Tue, Nov 24, 2026 at 07:23:09AM +0800, Edgecombe, Rick P wrote:
>On Mon, 2026-11-16 at 03:10 -0800, Chao Gao wrote:
>> Setting up PCIe link encryption requires a secure channel to the device
>> to exchange keys. This channel is an SPDM session over the device's PCI
>> DOE mailbox.
>
>Probably SPDM and DOE mailbox need some 10,000ft summary.

Does this sound better?

  SPDM is an industry-standard protocol for establishing trust between
  components. For TDX trusted I/O, the TDX module uses it to
  authenticate the device, collect its measurements and exchange IDE
  keys with it.

  DOE is a mailbox in the device's configuration space, through which
  software exchanges messages with the device. DOE is only a transport
  and can carry different protocols. SPDM is one of them.

>> Whenever the TDX module has a message for the device, the SEAMCALL
>> returns with a dedicated status code. The host sends the message to the
>> device and calls the SEAMCALL again with the device's response, until
>> the SEAMCALL completes.
>
>SEAMCALL completes? Could mean the full extension operation or a single seamcall
>execution.

I meant the whole operation, i.e. setting up or tearing down the SPDM
session. Will reword to make this clear.

>> Call both SEAMCALLs in such a loop. The DOE transfer itself is a stub
>> for now.
>
>I'd put something higher up explaining this is laying the ground work, rather
>than announcing the gaps at the end.

OK. Will add one sentence right after the background to say that this
patch lays the groundwork.

>> Pass the messages through two pages per device, one for each direction.
>> One pair is enough because PCI/TSM serializes operations on a device.
>
>This probably needs more explanation.

Several functions of a device may want to talk to the TDX module at
the same time, and each of them may need SPDM message exchanges. But
PCI/TSM serializes all operations on a device, so the pages are
allocated once per device and not once per function.

@Yilun, let me know if this understanding is wrong.

>> +#define SPDM_CAP_HBEAT		BIT(13)
>> +#define SPDM_CAP_KEY_UPD	BIT(14)
>> +
>> +struct spdm_config_info_t {
>> +	u32 vmm_spdm_cap;
>> +	u8 spdm_session_policy;
>> +	u8 certificate_slot_mask;
>> +	u8 raw_bitstream_requested;
>> +	u8 reserved[4089];
>> +} __packed;
>
>This looks like more SPDM specific stuff in TDX. Do really know other vendors
>need it? We should at least group it in a header such that it is clear which
>things are SPDM spec and which are TDX.

This structure is not from the SPDM spec. It is an ABI structure
defined by the TDX module, and it is passed to TDH.SPDM.CONNECT.

But yes, there is some SPDM-specific stuff in this series. I will try
to separate it from the TDX stuff.

>> +	struct page *in_msg;
>> +	struct page *out_msg;
>
>SNP and TDX both have the DOE mailbox shuffling done by the host, right? So why
>doesn't TSM allocate and provide these buffers?
>
>Oh looking at the code I'm now very confused. The request for SNP is in private
>memory? The SNP commit has very little info to explain what is going on there.

TDX and SNP have different requirements for the buffers. TDX needs no
special handling, and both pages are normal host memory. As far as I
can tell from the code, SNP makes its request buffer a firmware-owned
page. So it is not guest private memory, but it is not a normal host
page either. I guess that is part of the reason why each TSM driver
allocates its own buffers.

>> +	spdm_conf->certificate_slot_mask = 0xff;
>
>Can we not have the magic number? I guess it means any?

Sure, will remove the magic number. 0xff means getting the
certificates in all slots (0-7) of the device.

As a heads-up, this code will go away anyway when we switch to the new
CTLV attestation framework.

>> +	do {
>> +		mutex_lock(&tdx_spdm_lock);
>
>The fact that TSM protects us from the buffers getting clobbered by another
>request, but we still need the mutex only around the call is a bit hidden. I'd
>think it at least needs a comment. But since the tdx_spdm_lock is really a TDX
>module specific limitation, why not put it inside the SEAMCALL wrappers? It
>seems more related to core TDX module setup type things.

I like this idea. The concurrency limit is on the SEAMCALLs
themselves, not on the SPDM setup/teardown flow, so the lock fits
better in the SEAMCALL wrappers.

>> +	ret = -ENOMEM;
>> +	in_msg_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
>> +	if (!in_msg_page)
>> +		return ret;
>> +
>> +	out_msg_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
>> +	if (!out_msg_page)
>> +		goto out_free_in_msg;
>
>Maybe dumb question, but why do we need two buffers for this? After we post the
>request can't we just read it back the response to the same buffer? It doesn't
>seem DOE code is setup for that though.

pci_doe() takes separate buffers for the request and the response, and
so does TDH.SPDM.CONNECT.

>> +out_spdm_delete:
>> +	tdx_spdm_delete(tlink);
>
>We might some basics explanation of the SPDM operations are. create, disconnect,
>delete, etc. What about adding some comments across the patches that make it
>clear when and where each needs to be called?

Yes. Will add a high-level description of the SPDM operations to the
changelog, and comments above the functions where needed.

  reply	other threads:[~2026-11-24 13:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16 11:10 [RFC PATCH 0/7] TDX: Enable PCIe link encryption for trusted I/O Chao Gao
2026-11-16 11:10 ` [RFC PATCH 1/7] coco/tdx-host: Create metadata for an SPDM session Chao Gao
2026-11-21  2:05   ` Edgecombe, Rick P
2026-11-16 11:10 ` [RFC PATCH 2/7] coco/tdx-host: Establish an SPDM session with the device Chao Gao
2026-11-23 23:23   ` Edgecombe, Rick P
2026-11-24 12:59     ` Chao Gao [this message]
2026-11-16 11:10 ` [RFC PATCH 3/7] coco/tdx-host: Exchange SPDM messages through DOE Chao Gao
2026-11-24  0:02   ` Edgecombe, Rick P
2026-11-24 11:57     ` Chao Gao
2026-11-16 11:10 ` [RFC PATCH 4/7] coco/tdx-host: Pass a device info buffer to tdh_spdm_connect() Chao Gao
2026-11-16 11:10 ` [RFC PATCH 5/7] coco/tdx-host: Configure an IDE stream Chao Gao
2026-11-16 11:10 ` [RFC PATCH 6/7] coco/tdx-host: Program IDE keys and enable the " Chao Gao
2026-11-16 11:10 ` [RFC PATCH 7/7] x86/virt/tdx: Enable PCIe link encryption Chao Gao
2026-11-21  1:35 ` [RFC PATCH 0/7] TDX: Enable PCIe link encryption for trusted I/O 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=awWKRJQ3_rIgxJVC@intel.com \
    --to=chao.gao@intel.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=bp@alien8.de \
    --cc=chao.p.peng@intel.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=kas@kernel.org \
    --cc=kevin.tian@intel.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rick.p.edgecombe@intel.com \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    --cc=yilun.xu@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