Re: [RFC PATCH 3/7] coco/tdx-host: Exchange SPDM messages through DOE

From: Edgecombe, Rick P

Date: Mon Nov 23 2026 - 19:02:24 EST


On Mon, 2026-11-16 at 03:10 -0800, Chao Gao wrote:
> +struct pci_doe_header {
> + u16 vendor;
> + u8 type;
> + u8 rsvd0;
> + u32 length: 18; /* in DWORDs */
> + u32 rsvd1: 14;
> +} __packed;
> +
> +struct pci_doe_msg {
> + struct pci_doe_header header;
> + u8 payload[];
> +} __packed;

You mentioned DOE rebuilds the header. It looks like it doesn't have structs
like these because it uses FIELD_PREP with masks. So then we just have duplicate
definitions of the format. Ugh.

> +
> +/*
> + * The TDX module produces and consumes complete DOE data objects, but
> + * pci_doe() takes only the payload and builds the header itself. Strip
> + * the header from the request and rebuild it for the response.
> + */
>  static int tdx_spdm_msg_exchange(struct tdx_tsm_link *tlink)
>  {
> - /* TODO: implement the PCI DOE transfer */
> + struct pci_dev *pdev = tlink->pci.base_tsm.pdev;
> + struct pci_doe_msg *req  = page_address(tlink->out_msg);
> + struct pci_doe_msg *resp = page_address(tlink->in_msg);
> +
> + size_t req_sz = req->header.length * sizeof(u32);
> + size_t resp_sz = PAGE_SIZE;
> +
> + size_t req_payload_sz = req_sz  - sizeof(struct pci_doe_header);
> + size_t resp_payload_sz = resp_sz - sizeof(struct pci_doe_header);
> +
> + void *resp_payload_addr = resp->payload;
> + void *req_payload_addr = req->payload;
> +
> + u8 type = req->header.type;
> +
> + int ret;

Yea, this is just really unfortunate like you pointed in the coverletter. We
unwrap the header using all of this gunk to pass it through and then rebuild the
header on the other side.

resp_payload_addr, and req_payload_addr seem unnecessary. It's not any shorter
in the function over casing to (void *).

> +
> + ret = pci_tsm_doe_transfer(pdev, type,
> +    req_payload_addr, req_payload_sz,
> +    resp_payload_addr, resp_payload_sz);
> + if (ret < 0) {
> + pci_err(pdev, "spdm msg exchange fail %d\n", ret);
> + return ret;
> + }
> +
> + resp->header.vendor = PCI_VENDOR_ID_PCI_SIG;
> + resp->header.type = type;
> + resp->header.length = (ret + sizeof(struct pci_doe_header)) / sizeof(u32);
> +
>   return 0;
>  }
>