All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chao Gao <chao.gao@intel.com>
To: "Edgecombe, Rick P" <rick.p.edgecombe@intel.com>
Cc: "Xu, Yilun" <yilun.xu@intel.com>,
	"x86@kernel.org" <x86@kernel.org>,
	"kas@kernel.org" <kas@kernel.org>,
	"Peng, Chao P" <chao.p.peng@intel.com>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
	"Tian, Kevin" <kevin.tian@intel.com>,
	"linux-coco@lists.linux.dev" <linux-coco@lists.linux.dev>,
	"baolu.lu@linux.intel.com" <baolu.lu@linux.intel.com>
Subject: Re: [RFC PATCH 3/7] coco/tdx-host: Exchange SPDM messages through DOE
Date: Wed, 25 Nov 2026 20:12:20 +0800	[thread overview]
Message-ID: <awbQpM4QlKTVQ0f8@intel.com> (raw)
In-Reply-To: <00efbba7a1b2c6e61cc36bf709718da978eec85c.camel@intel.com>

On Wed, Nov 25, 2026 at 06:02:02AM +0800, Edgecombe, Rick P wrote:
>On Tue, 2026-11-24 at 19:57 +0800, Chao Gao wrote:
>> I am now leaning towards moving this code into PCI/DOE, even though
>> TDX would be its only user. Stripping and rebuilding the header is DOE
>> format handling, and the PCI/DOE core already has the definitions and
>> the code for it. A TSM driver should not need a second copy, no matter
>> how many users there are. That would also remove the duplicate
>> definitions above.
>
>Can you elaborate on your proposal? What exactly moves to DOE and how does it
>interop with the other DOE callers?

The header stripping and rebuilding moves to drivers/pci/doe.c, as a new
helper (e.g., pci_doe_raw()). struct pci_doe_header and struct
pci_doe_msg defined in this patch go away. This avoids a second definition
of the DOE format.

pci_doe_raw() is a wrapper around pci_doe(). The other callers still
use pci_doe() and are not affected.

I explored the idea with AI. It generated:

int pci_doe_raw(struct pci_doe_mb *doe_mb, const void *request,
		size_t request_sz, void *response, size_t response_sz)
{
	const __le32 *req_hdr = request;
	__le32 *resp_hdr = response;
	size_t hdr_sz = 2 * sizeof(__le32);
	size_t length;
	u32 hdr1;
	int rc;

	if (request_sz < hdr_sz || response_sz < hdr_sz)
		return -EINVAL;

	hdr1 = le32_to_cpu(req_hdr[0]);
	length = FIELD_GET(PCI_DOE_DATA_OBJECT_HEADER_2_LENGTH,
			   le32_to_cpu(req_hdr[1]));
	/* A value of 0x0 indicates max data object length */
	if (!length)
		length = PCI_DOE_MAX_LENGTH;
	if (length < 2 || length * sizeof(__le32) > request_sz)
		return -EINVAL;

	rc = pci_doe(doe_mb, FIELD_GET(PCI_DOE_DATA_OBJECT_HEADER_1_VID, hdr1),
		     FIELD_GET(PCI_DOE_DATA_OBJECT_HEADER_1_TYPE, hdr1),
		     request + hdr_sz, length * sizeof(__le32) - hdr_sz,
		     response + hdr_sz, response_sz - hdr_sz);
	if (rc < 0)
		return rc;

	/* pci_doe() has verified that the response has the same VID and Type */
	length = 2 + DIV_ROUND_UP(rc, sizeof(__le32));
	resp_hdr[0] = cpu_to_le32(hdr1 & (PCI_DOE_DATA_OBJECT_HEADER_1_VID |
					  PCI_DOE_DATA_OBJECT_HEADER_1_TYPE));
	resp_hdr[1] = cpu_to_le32(FIELD_PREP(PCI_DOE_DATA_OBJECT_HEADER_2_LENGTH,
					     length % PCI_DOE_MAX_LENGTH));

	return rc + hdr_sz;
}

tdx_spdm_msg_exchange() becomes:

static int tdx_spdm_msg_exchange(struct tdx_tsm_link *tlink)
{
	struct pci_dev *pdev = tlink->pci.base_tsm.pdev;
	int ret;

	ret = pci_doe_raw(tlink->pci.doe_mb,
			  page_address(tlink->out_msg), PAGE_SIZE,
			  page_address(tlink->in_msg), PAGE_SIZE);
	if (ret < 0) {
		pci_err(pdev, "spdm msg exchange fail %d\n", ret);
		return ret;
	}

	return 0;
}

  reply	other threads:[~2026-11-25 12:14 UTC|newest]

Thread overview: 34+ 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-30  2:50     ` Chao Gao
2026-11-30 22:08       ` Edgecombe, Rick P
2026-12-01  5:01         ` Chao Gao
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
2026-11-24 21:11       ` Edgecombe, Rick P
2026-11-28  9:25         ` Xu Yilun
2026-11-30 11:40           ` Chao Gao
2026-12-01  4:57             ` Chao Gao
2026-12-01 19:05               ` Edgecombe, Rick P
2026-11-28  9:35       ` Xu Yilun
2026-11-30 12:20         ` Chao Gao
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-24 22:02       ` Edgecombe, Rick P
2026-11-25 12:12         ` Chao Gao [this message]
2026-11-25 17:48           ` Edgecombe, Rick P
2026-11-28 12:42             ` Xu Yilun
2026-11-30 22:09               ` Edgecombe, Rick P
2026-11-28  9:47   ` Xu Yilun
2026-11-30 12:53     ` 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-28 13:17   ` Xu Yilun
2026-11-30 13:00     ` 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
2026-11-30 11:11   ` 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=awbQpM4QlKTVQ0f8@intel.com \
    --to=chao.gao@intel.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=chao.p.peng@intel.com \
    --cc=dave.hansen@linux.intel.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=rick.p.edgecombe@intel.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.