All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: alistair23@gmail.com
Cc: linux-pci@vger.kernel.org, Jonathan.Cameron@huawei.com,
	djbw@kernel.org, rust-for-linux@vger.kernel.org, lukas@wunner.de,
	alistair@alistair23.me, linux-cxl@vger.kernel.org,
	bhelgaas@google.com, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org, gary@garyguo.net, ojeda@kernel.org,
	benno.lossin@proton.me, a.hindborg@kernel.org,
	wilfred.mallawa@wdc.com, tmgross@umich.edu, boqun.feng@gmail.com,
	bjorn3_gh@protonmail.com, alex.gaynor@gmail.com,
	aliceryhl@google.com, Alistair Francis <alistair.francis@wdc.com>
Subject: Re: [PATCH v3 12/21] PCI/CMA: Add a PCI TSM CMA driver using SPDM
Date: Wed, 9 Sep 2026 00:21:42 +0100	[thread overview]
Message-ID: <20260909002142.2d863d2a@jic23-huawei> (raw)
In-Reply-To: <20260901010347.2614656-13-alistair.francis@wdc.com>

On Tue,  1 Sep 2026 11:03:38 +1000
alistair23@gmail.com wrote:

> From: Alistair Francis <alistair.francis@wdc.com>
> 
> Component Measurement and Authentication (CMA, PCIe r6.2 sec 6.31)
> allows for measurement and authentication of PCIe devices.  It is
> based on the Security Protocol and Data Model specification (SPDM,
> https://www.dmtf.org/dsp/DSP0274).
> 
> CMA-SPDM in turn forms the basis for Integrity and Data Encryption
> (IDE, PCIe r6.2 sec 6.33) because the key material used by IDE is
> transmitted over a CMA-SPDM session.
> 
> As a first step, add support for authentication via a CMA TSM driver.
> 
> This was previously discusd here:
> http://lore.kernel.org/69976d7d39c60_2f4a1009@dwillia2-mobl4.notmuch
> 
> By utilising a TSM driver we get a lot of the TSM driver probe policies
> "for free". Currently there is no mechanism to provide evidence to
> userspace, as the TSM system doesn't support that at the moment. That
> can be added later when support by TSM.
> 
> Credits: Jonathan wrote the original proof-of-concept for a CMA implementation.
> Lukas reworked that for upstream. Wilfred contributed fixes for issues
> discovered during testing. Alistair reworked it as a TSM driver.
> 
> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Co-developed-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
> Signed-off-by: Wilfred Mallawa <wilfred.mallawa@wdc.com>
> Co-developed-by: Lukas Wunner <lukas@wunner.de>
> Signed-off-by: Lukas Wunner <lukas@wunner.de>
> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

A few things inline.  I have no idea if I'm poking holes in 
my own code or if none of that is left :)

>  
> diff --git a/drivers/pci/cma.c b/drivers/pci/cma.c
> new file mode 100644
> index 000000000000..9f2cc0b2ec8a
> --- /dev/null
> +++ b/drivers/pci/cma.c

...



> +static int pci_cma_tsm_connect(struct pci_dev *pdev)
> +{
> +	struct pci_cma_tsm *cma = cma_tsm_from_tsm(pdev->tsm);
> +	int rc;
> +
> +	/*
> +	 * The DOE mailbox lives in the device's config space, so the
> +	 * device must be runtime-resumed for the duration of the SPDM
> +	 * exchange.

Oddly short wrap. Comments go to 80
	/*
	 * The DOE mailbox lives in the device's config space, so the device
	 * must be runtime-resumed for the duration of the SPDM exchange.

> +	 */
> +	rc = pm_runtime_get_sync(&pdev->dev);
	rc = pm_runtime_resume_and_get(&pdev->dev)
	if (rc < 0)
		return rc;

See comments in docs for pm_runtime_get_sync() for info on this.
Basically it doesn't mess up reference counting so you don't need
to fix it in the error path.

Mind you, I haven't looked ahead but we have ACQUIRE macros for
runtime PM that might apply nicely here and remove need to release anything
at all.

	PM_RUNTIME_ACQUIRE(&pdev->dev, pm);
	if (PM_RUNTIME_ACQUIRE_ERR(&pm))
		return -ENXIO;

	

> +	if (rc < 0) {
> +		pm_runtime_put_noidle(&pdev->dev);
> +		return rc;
> +	}
> +
> +	rc = spdm_authenticate(cma->spdm);

If you can use ACQUIRE stuff
	return spdm_authenticate(cma->spdm);

> +
> +	pm_runtime_put_sync(&pdev->dev);
> +	return rc;
> +}

> +
> +static const struct pci_tsm_ops pci_cma_tsm_ops = {
> +	.link_ops = {
> +		.probe		= pci_cma_tsm_probe,
> +		.remove		= pci_cma_tsm_remove,
> +		.connect	= pci_cma_tsm_connect,
> +		.disconnect	= pci_cma_tsm_disconnect,
> +		.bind		= pci_cma_tsm_bind,
> +		.unbind		= pci_cma_tsm_unbind,
> +		.guest_req	= pci_cma_tsm_guest_req,
> +	},
> +};
> +
> +static struct tsm_dev *pci_cma_tsm_dev;
> +
> +static int __init pci_cma_tsm_init(void)
> +{
> +	struct tsm_dev *tsm_dev;
> +
> +	tsm_dev = tsm_register(NULL, (struct pci_tsm_ops *)&pci_cma_tsm_ops);

So this is casting away the const.   Why does tsm_register not take a const?
Can we change that as seems unlikely it will actually modify it?
If there is any chance of a modification in future then we need to drop
the const marking on the structure above.


> +	if (IS_ERR(tsm_dev))
> +		return PTR_ERR(tsm_dev);
> +
> +	pci_cma_tsm_dev = tsm_dev;
> +	return 0;
> +}
> +late_initcall(pci_cma_tsm_init);

  parent reply	other threads:[~2026-09-08 23:21 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01  1:03 [PATCH v3 00/21] lib: Rust implementation of SPDM alistair23
2026-09-01  1:03 ` [PATCH v3 01/21] rust: transmute: add `cast_slice[_mut]` functions alistair23
2026-09-01  1:11   ` sashiko-bot
2026-09-01  1:03 ` [PATCH v3 02/21] rust: create basic untrusted data API alistair23
2026-09-01  1:19   ` sashiko-bot
2026-09-01  1:03 ` [PATCH v3 03/21] rust: validate: add `Validate` trait alistair23
2026-09-01  1:16   ` sashiko-bot
2026-09-01  1:03 ` [PATCH v3 04/21] X.509: Make certificate parser public alistair23
2026-09-01  1:12   ` sashiko-bot
2026-09-01  1:03 ` [PATCH v3 05/21] X.509: Parse Subject Alternative Name in certificates alistair23
2026-09-01  1:12   ` sashiko-bot
2026-09-01  1:03 ` [PATCH v3 06/21] X.509: Move certificate length retrieval into new helper alistair23
2026-09-01  1:10   ` sashiko-bot
2026-09-01  1:03 ` [PATCH v3 07/21] rust: add bindings for hash.h alistair23
2026-09-01  1:10   ` sashiko-bot
2026-09-01  1:03 ` [PATCH v3 08/21] rust: error: impl From<FromBytesWithNulError> for Kernel Error alistair23
2026-09-01  1:10   ` sashiko-bot
2026-09-01  1:03 ` [PATCH v3 09/21] lib: rspdm: Initial commit of Rust SPDM alistair23
2026-09-01  1:17   ` sashiko-bot
2026-09-08 22:57   ` Jonathan Cameron
2026-09-01  1:03 ` [PATCH v3 10/21] PCI/TSM: Rename pf0 to host alistair23
2026-09-01  1:16   ` sashiko-bot
2026-09-08 23:01   ` Jonathan Cameron
2026-09-11  5:00     ` Alistair
2026-09-01  1:03 ` [PATCH v3 11/21] PCI/TSM: Support connecting to PCIe CMA devices alistair23
2026-09-01  1:25   ` sashiko-bot
2026-09-01  1:03 ` [PATCH v3 12/21] PCI/CMA: Add a PCI TSM CMA driver using SPDM alistair23
2026-09-01  1:20   ` sashiko-bot
2026-09-08 23:21   ` Jonathan Cameron [this message]
2026-09-01  1:03 ` [PATCH v3 13/21] PCI/CMA: Validate Subject Alternative Name in certificates alistair23
2026-09-01  1:15   ` sashiko-bot
2026-09-01  1:03 ` [PATCH v3 14/21] lib: rspdm: Support SPDM get_version alistair23
2026-09-01  1:17   ` sashiko-bot
2026-09-08 23:40   ` Jonathan Cameron
2026-09-01  1:03 ` [PATCH v3 15/21] lib: rspdm: Support SPDM get_capabilities alistair23
2026-09-01  1:15   ` sashiko-bot
2026-09-08 23:47   ` Jonathan Cameron
2026-09-01  1:03 ` [PATCH v3 16/21] lib: rspdm: Support SPDM negotiate_algorithms alistair23
2026-09-01  1:30   ` sashiko-bot
2026-09-04  5:01   ` Aksh Garg
2026-09-09  0:17   ` Jonathan Cameron
2026-09-11  4:53     ` Alistair
2026-09-01  1:03 ` [PATCH v3 17/21] lib: rspdm: Support SPDM get_digests alistair23
2026-09-01  1:20   ` sashiko-bot
2026-09-09  0:36     ` Jonathan Cameron
2026-09-09  0:31   ` Jonathan Cameron
2026-09-01  1:03 ` [PATCH v3 18/21] lib: rspdm: Support SPDM get_certificate alistair23
2026-09-01  1:21   ` sashiko-bot
2026-09-01  1:03 ` [PATCH v3 19/21] lib: rspdm: Support SPDM certificate validation alistair23
2026-09-01  1:22   ` sashiko-bot
2026-09-09  0:46   ` Jonathan Cameron
2026-09-01  1:03 ` [PATCH v3 20/21] rust: allow extracting the buffer from a CString alistair23
2026-09-01  1:19   ` sashiko-bot
2026-09-01  1:03 ` [PATCH v3 21/21] lib: rspdm: Support SPDM challenge alistair23
2026-09-01  1:31   ` sashiko-bot
2026-09-09  1:37   ` Jonathan Cameron
2026-09-11  3:46     ` Alistair

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=20260909002142.2d863d2a@jic23-huawei \
    --to=jic23@kernel.org \
    --cc=Jonathan.Cameron@huawei.com \
    --cc=a.hindborg@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=alistair.francis@wdc.com \
    --cc=alistair23@gmail.com \
    --cc=alistair@alistair23.me \
    --cc=benno.lossin@proton.me \
    --cc=bhelgaas@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=djbw@kernel.org \
    --cc=gary@garyguo.net \
    --cc=linux-cxl@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tmgross@umich.edu \
    --cc=wilfred.mallawa@wdc.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.