Linux Confidential Computing Development
 help / color / mirror / Atom feed
From: <dan.j.williams@intel.com>
To: Alexey Kardashevskiy <aik@amd.com>, <dan.j.williams@intel.com>,
	<linux-pci@vger.kernel.org>, <linux-coco@lists.linux.dev>
Cc: <gregkh@linuxfoundation.org>, <bhelgaas@google.com>,
	<lukas@wunner.de>, Samuel Ortiz <sameo@rivosinc.com>,
	Xu Yilun <yilun.xu@linux.intel.com>
Subject: Re: [PATCH resend v6 04/10] PCI/TSM: Authenticate devices via platform TSM
Date: Thu, 25 Sep 2025 16:00:47 -0700	[thread overview]
Message-ID: <68d5c99fbb056_1c7910082@dwillia2-mobl4.notmuch> (raw)
In-Reply-To: <b99b2951-9f09-4f9d-a132-f05ab1f8928f@amd.com>

Alexey Kardashevskiy wrote:
[..]
> >> It is still a rather global thing. May I suggest this?
> > 
> > I am not too keen on this.
> > 
> > Yes, it is global, but less often used compared to @ops, and I do not
> > want both @ops and @tsm_dev in @pci_tsm.
> 
> Why exactly?

...because it complicates the data structure merely for code convenience
which is often the wrong tradeoff.

Here are the current options:

1/ Current:
struct pci_tsm {
        struct pci_dev *pdev;
        struct pci_dev *dsm_dev;
        const struct pci_tsm_ops *ops;
};

2/ Alternative:
struct pci_tsm {
        struct pci_dev *pdev;
        struct pci_dev *dsm_dev;
        struct tsm_dev *tsm_dev;
};

2/ Proposed:
struct pci_tsm {
        struct pci_dev *pdev;
        struct pci_dev *dsm_dev;
        struct tsm_dev *tsm_dev;
        const struct pci_tsm_ops *ops;
};

I rank 3 last because it implies that @tsm_dev and @ops may have
different lifetimes or otherwise may not be related to the same object
until you read the code.

I rank 2 after 1 because most of 'struct pci_tsm_ops' do not need the
tsm_dev parameter.

Now, I would maybe go with 2 if 'struct tsm_dev' could be defined as:

diff --git a/include/linux/tsm.h b/include/linux/tsm.h
index 376139585797..3619ffa8f8c1 100644
--- a/include/linux/tsm.h
+++ b/include/linux/tsm.h
@@ -112,7 +112,7 @@ struct pci_tsm_ops;
 struct tsm_dev {
        struct device dev;
        int id;
-       const struct pci_tsm_ops *pci_ops;
+       const struct pci_tsm_ops pci_ops;
 };
 
...i.e. a container_of() relationship, but that makes pci_ops mandatory.
It is already the case that TDX has as a few host-services in mind that
may end up sharing common infrastructure at a TSM device level, so 1
remains the preference.

> > So the options are lookup @ops
> > from @tsm_dev or lookup @tsm_dev from @ops. Given @ops is used more
> > often that is how I came up with the current arrangement.
> 
> I am looking at:
> https://github.com/AMDESE/linux-kvm/commit/9e3caf921ad6ddd6bd860ec307b986649322a618
> and not really sure "more often" applies here.
> 
> And do we have to check now if tsm_dev passed in probe() is the same
> as the owner?

@ops are not passed passed back in probe so ->probe() can not verify.
Also ->probe() sets the operations to use via pci_tsm_link_constructor()
so at that point it does not matter how ->probe() got invoked the result
is still the TSM driver returning the ops associated with @tsm_dev.

> I struggle to find any other _ops doing the same owner
> caching easily.

struct file_operations::owner looks like one example.

> Or merge struct pci_tsm_ops into struct tsm_dev to stop pretending
> that pci_tsm_ops is an interface, and then we won't even need that
> @owner. Dunno. Aneesh? :)

Not sure what you mean by "pretending that pci_tsm_ops is an interface"?

  reply	other threads:[~2025-09-25 23:00 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-11 23:56 [PATCH resend v6 00/10] PCI/TSM: Core infrastructure for PCI device security (TDISP) Dan Williams
2025-09-11 23:56 ` [PATCH resend v6 01/10] coco/tsm: Introduce a core device for TEE Security Managers Dan Williams
2025-09-11 23:56 ` [PATCH resend v6 02/10] PCI/IDE: Enumerate Selective Stream IDE capabilities Dan Williams
2025-09-15 16:32   ` Jonathan Cameron
2025-09-11 23:56 ` [PATCH resend v6 03/10] PCI: Introduce pci_walk_bus_reverse(), for_each_pci_dev_reverse() Dan Williams
2025-09-11 23:56 ` [PATCH resend v6 04/10] PCI/TSM: Authenticate devices via platform TSM Dan Williams
2025-09-15 11:27   ` Alexey Kardashevskiy
2025-09-19 20:15     ` dan.j.williams
2025-09-22 12:26       ` Alexey Kardashevskiy
2025-09-25 23:00         ` dan.j.williams [this message]
2025-09-26  1:14           ` Alexey Kardashevskiy
2025-09-15 11:37   ` Alexey Kardashevskiy
2025-09-19 20:29     ` dan.j.williams
2025-09-11 23:56 ` [PATCH resend v6 05/10] samples/devsec: Introduce a PCI device-security bus + endpoint sample Dan Williams
2025-09-11 23:56 ` [PATCH resend v6 06/10] PCI: Add PCIe Device 3 Extended Capability enumeration Dan Williams
2025-09-11 23:56 ` [PATCH resend v6 07/10] PCI/IDE: Add IDE establishment helpers Dan Williams
2025-09-16  0:14   ` Alexey Kardashevskiy
2025-09-25 19:54     ` dan.j.williams
2025-09-11 23:56 ` [PATCH resend v6 08/10] PCI/IDE: Report available IDE streams Dan Williams
2025-09-11 23:56 ` [PATCH resend v6 09/10] PCI/TSM: Report active " Dan Williams
2025-09-11 23:56 ` [PATCH resend v6 10/10] samples/devsec: Add sample IDE establishment Dan Williams
2025-09-16 12:18 ` [PATCH resend v6 00/10] PCI/TSM: Core infrastructure for PCI device security (TDISP) Aneesh Kumar K.V
2025-09-19  4:17   ` Alexey Kardashevskiy
2025-09-19 12:17     ` Jason Gunthorpe

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=68d5c99fbb056_1c7910082@dwillia2-mobl4.notmuch \
    --to=dan.j.williams@intel.com \
    --cc=aik@amd.com \
    --cc=bhelgaas@google.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-pci@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=sameo@rivosinc.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