From: "Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org>
To: linux-coco@lists.linux.dev
Cc: "Aneesh Kumar K.V (Arm)" <aneesh.kumar@kernel.org>,
Alex Williamson <alex@shazbot.org>,
Alexey Kardashevskiy <aik@amd.com>,
Bjorn Helgaas <bhelgaas@google.com>,
Catalin Marinas <catalin.marinas@arm.com>,
Jacob Pan <jacob.pan@linux.microsoft.com>,
Jason Gunthorpe <jgg@ziepe.ca>, Joerg Roedel <joro@8bytes.org>,
Jonathan Cameron <jic23@kernel.org>,
Jonathan Hunter <jonathanh@nvidia.com>,
Kevin Tian <kevin.tian@intel.com>,
Krishna Reddy <vdumpa@nvidia.com>, Lukas Wunner <lukas@wunner.de>,
Nicolin Chen <nicolinc@nvidia.com>,
Robin Murphy <robin.murphy@arm.com>,
Samuel Ortiz <sameo@rivosinc.com>,
Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>,
Steven Price <steven.price@arm.com>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Suzuki K Poulose <suzuki.poulose@arm.com>,
Thierry Reding <thierry.reding@kernel.org>,
Vasant Hegde <vasant.hegde@amd.com>,
Will Deacon <will@kernel.org>,
Xu Yilun <yilun.xu@linux.intel.com>,
Ashish Kalra <ashish.kalra@amd.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
Jonathan Cameron <jonathan.cameron@huawei.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
kvm@vger.kernel.org, iommu@lists.linux.dev,
linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org,
linux-tegra@vger.kernel.org, patches@lists.linux.dev
Subject: [PATCH v10 11/18] PCI/TSM: Remove the legacy bind and unbind interface
Date: Wed, 25 Nov 2026 13:41:14 +0530 [thread overview]
Message-ID: <20261125081121.379481-12-aneesh.kumar@kernel.org> (raw)
In-Reply-To: <20261125081121.379481-1-aneesh.kumar@kernel.org>
Remove pci_tsm_bind(), pci_tsm_unbind(), their callbacks and the pci_tdi
structure. Device security state will be managed through vIOMMU
operations.
Remove the bound sysfs attribute and its ABI documentation, since they
report state maintained by the removed interface.
Signed-off-by: Aneesh Kumar K.V (Arm) <aneesh.kumar@kernel.org>
---
Documentation/ABI/testing/sysfs-bus-pci | 14 ---
drivers/pci/tsm.c | 150 +-----------------------
include/linux/pci-tsm.h | 34 +-----
3 files changed, 2 insertions(+), 196 deletions(-)
diff --git a/Documentation/ABI/testing/sysfs-bus-pci b/Documentation/ABI/testing/sysfs-bus-pci
index 2906257eb610..ab9083f3b0d3 100644
--- a/Documentation/ABI/testing/sysfs-bus-pci
+++ b/Documentation/ABI/testing/sysfs-bus-pci
@@ -678,20 +678,6 @@ Description: (RO) Return PCI device name of this device's DSM (Device
PCIe switch port. This is a "link" TSM attribute, see
Documentation/ABI/testing/sysfs-class-tsm.
-What: /sys/bus/pci/devices/.../tsm/bound
-Contact: linux-coco@lists.linux.dev
-Description: (RO) Return the device name of the TSM when the device is in a
- TDISP (TEE Device Interface Security Protocol) operational state
- (LOCKED, RUN, or ERROR, not UNLOCKED). Bound devices consume
- platform TSM resources and depend on the device's configuration
- (e.g. BME (Bus Master Enable) and MSE (Memory Space Enable)
- among other settings) to remain stable for the duration of the
- bound state. This attribute is only visible for devices that
- support TDISP operation, and it is only populated after
- successful connect and TSM bind. The TSM bind operation is
- initiated by VFIO/IOMMUFD. This is a "link" TSM attribute, see
- Documentation/ABI/testing/sysfs-class-tsm.
-
What: /sys/bus/pci/devices/.../authenticated
Contact: linux-pci@vger.kernel.org
Description:
diff --git a/drivers/pci/tsm.c b/drivers/pci/tsm.c
index 73f16a9a78ef..ddff81554372 100644
--- a/drivers/pci/tsm.c
+++ b/drivers/pci/tsm.c
@@ -337,95 +337,6 @@ void pci_tsm_context_put(struct pci_dev *pdev)
}
EXPORT_SYMBOL_GPL(pci_tsm_context_put);
-/*
- * Note, this helper only returns an error code and takes an argument for
- * compatibility with the pci_walk_bus() callback prototype. pci_tsm_unbind()
- * always succeeds.
- */
-static int __pci_tsm_unbind(struct pci_dev *pdev, void *data)
-{
- struct pci_tdi *tdi;
- struct pci_tsm_pf0 *tsm_pf0;
-
- lockdep_assert_held(&pci_tsm_rwsem);
-
- if (!pdev->tsm)
- return 0;
-
- tsm_pf0 = to_pci_tsm_pf0(pdev->tsm);
- guard(mutex)(&tsm_pf0->lock);
-
- tdi = pdev->tsm->tdi;
- if (!tdi)
- return 0;
-
- to_pci_tsm_ops(pdev->tsm)->unbind(tdi);
- pdev->tsm->tdi = NULL;
-
- return 0;
-}
-
-void pci_tsm_unbind(struct pci_dev *pdev)
-{
- guard(rwsem_read)(&pci_tsm_rwsem);
- __pci_tsm_unbind(pdev, NULL);
-}
-EXPORT_SYMBOL_GPL(pci_tsm_unbind);
-
-/**
- * pci_tsm_bind() - Bind @pdev as a TDI for @kvm
- * @pdev: PCI device function to bind
- * @kvm: Private memory attach context
- * @tdi_id: Identifier (virtual BDF) for the TDI as referenced by the TSM and DSM
- *
- * Returns 0 on success, or a negative error code on failure.
- *
- * Context: Caller is responsible for constraining the bind lifetime to the
- * registered state of the device. For example, pci_tsm_bind() /
- * pci_tsm_unbind() limited to the VFIO driver bound state of the device.
- */
-int pci_tsm_bind(struct pci_dev *pdev, struct kvm *kvm, u32 tdi_id)
-{
- struct pci_tsm_pf0 *tsm_pf0;
- struct pci_tdi *tdi;
-
- if (!kvm)
- return -EINVAL;
-
- guard(rwsem_read)(&pci_tsm_rwsem);
-
- if (!pdev->tsm)
- return -EINVAL;
-
- if (!is_link_tsm(pdev->tsm->tsm_dev))
- return -ENXIO;
-
- tsm_pf0 = to_pci_tsm_pf0(pdev->tsm);
- guard(mutex)(&tsm_pf0->lock);
-
- /* Resolve races to bind a TDI */
- if (pdev->tsm->tdi) {
- if (pdev->tsm->tdi->kvm != kvm)
- return -EBUSY;
- return 0;
- }
-
- tdi = to_pci_tsm_ops(pdev->tsm)->bind(pdev, kvm, tdi_id);
- if (IS_ERR(tdi))
- return PTR_ERR(tdi);
-
- pdev->tsm->tdi = tdi;
-
- return 0;
-}
-EXPORT_SYMBOL_GPL(pci_tsm_bind);
-
-static void pci_tsm_unbind_all(struct pci_dev *pdev)
-{
- pci_tsm_walk_fns_reverse(pdev, __pci_tsm_unbind, NULL);
- __pci_tsm_unbind(pdev, NULL);
-}
-
static int __pci_tsm_disconnect(struct pci_dev *pdev)
{
struct pci_tsm_pf0 *tsm_pf0 = to_pci_tsm_pf0(pdev->tsm);
@@ -434,8 +345,6 @@ static int __pci_tsm_disconnect(struct pci_dev *pdev)
/* disconnect() mutually exclusive with subfunction pci_tsm_init() */
lockdep_assert_held_write(&pci_tsm_rwsem);
- pci_tsm_unbind_all(pdev);
-
/*
* Refuse to disconnect the link until all contexts have been released.
*
@@ -489,33 +398,6 @@ static ssize_t disconnect_store(struct device *dev,
}
static DEVICE_ATTR_WO(disconnect);
-static ssize_t bound_show(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- struct pci_dev *pdev = to_pci_dev(dev);
- struct pci_tsm_pf0 *tsm_pf0;
- struct pci_tsm *tsm;
- int rc;
-
- ACQUIRE(rwsem_read_intr, lock)(&pci_tsm_rwsem);
- if ((rc = ACQUIRE_ERR(rwsem_read_intr, &lock)))
- return rc;
-
- tsm = pdev->tsm;
- if (!tsm)
- return sysfs_emit(buf, "\n");
- tsm_pf0 = to_pci_tsm_pf0(tsm);
-
- ACQUIRE(mutex_intr, ops_lock)(&tsm_pf0->lock);
- if ((rc = ACQUIRE_ERR(mutex_intr, &ops_lock)))
- return rc;
-
- if (!tsm->tdi)
- return sysfs_emit(buf, "\n");
- return sysfs_emit(buf, "%s\n", dev_name(&tsm->tsm_dev->dev));
-}
-static DEVICE_ATTR_RO(bound);
-
static ssize_t dsm_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
@@ -570,13 +452,6 @@ static umode_t pci_tsm_attr_visible(struct kobject *kobj,
if (pci_tsm_link_group_visible(kobj)) {
struct pci_dev *pdev = to_pci_dev(kobj_to_dev(kobj));
- if (attr == &dev_attr_bound.attr) {
- if (is_pci_tsm_pf0(pdev) && has_tee(pdev))
- return attr->mode;
- if (pdev->tsm && has_tee(pdev->tsm->dsm_dev))
- return attr->mode;
- }
-
if (attr == &dev_attr_dsm.attr) {
if (is_pci_tsm_pf0(pdev))
return attr->mode;
@@ -603,7 +478,6 @@ DEFINE_SYSFS_GROUP_VISIBLE(pci_tsm);
static struct attribute *pci_tsm_attrs[] = {
&dev_attr_connect.attr,
&dev_attr_disconnect.attr,
- &dev_attr_bound.attr,
&dev_attr_dsm.attr,
NULL
};
@@ -693,22 +567,6 @@ static struct pci_dev *find_dsm_dev(struct pci_dev *pdev)
return NULL;
}
-/**
- * pci_tsm_tdi_constructor() - base 'struct pci_tdi' initialization for link TSMs
- * @pdev: PCI device function representing the TDI
- * @tdi: context to initialize
- * @kvm: Private memory attach context
- * @tdi_id: Identifier (virtual BDF) for the TDI as referenced by the TSM and DSM
- */
-void pci_tsm_tdi_constructor(struct pci_dev *pdev, struct pci_tdi *tdi,
- struct kvm *kvm, u32 tdi_id)
-{
- tdi->pdev = pdev;
- tdi->kvm = kvm;
- tdi->tdi_id = tdi_id;
-}
-EXPORT_SYMBOL_GPL(pci_tsm_tdi_constructor);
-
/**
* pci_tsm_link_constructor() - base 'struct pci_tsm' initialization for link TSMs
* @pdev: The PCI device
@@ -788,12 +646,6 @@ int pci_tsm_register(struct tsm_dev *tsm_dev)
return 0;
}
-static void pci_tsm_fn_exit(struct pci_dev *pdev)
-{
- __pci_tsm_unbind(pdev, NULL);
- tsm_remove(pdev->tsm);
-}
-
/**
* __pci_tsm_destroy() - destroy the TSM context for @pdev
* @pdev: device to cleanup
@@ -831,7 +683,7 @@ static void __pci_tsm_destroy(struct pci_dev *pdev, struct tsm_dev *tsm_dev)
if (pci_tsm_disconnect(pdev))
pci_warn(pdev, "TSM connection is still in use\n");
} else {
- pci_tsm_fn_exit(pdev);
+ tsm_remove(pdev->tsm);
}
}
diff --git a/include/linux/pci-tsm.h b/include/linux/pci-tsm.h
index 38b03d71e3f3..e6fe099f2cc9 100644
--- a/include/linux/pci-tsm.h
+++ b/include/linux/pci-tsm.h
@@ -6,7 +6,6 @@
struct pci_tsm;
struct tsm_dev;
-struct kvm;
/*
* struct pci_tsm_ops - manage confidential links and security state
@@ -30,16 +29,12 @@ struct pci_tsm_ops {
* @connect: establish / validate a secure connection (e.g. IDE)
* with the device
* @disconnect: teardown the secure link
- * @bind: bind a TDI in preparation for it to be accepted by a TVM
- * @unbind: remove a TDI from secure operation with a TVM
*
* Context: @probe, @remove, @connect, and @disconnect run under
* pci_tsm_rwsem held for write to sync with TSM unregistration and
* mutual exclusion of @connect and @disconnect. @connect and
* @disconnect additionally run under the DSM lock (struct
* pci_tsm_pf0::lock) as well as @probe and @remove of the subfunctions.
- * @bind and @unbind run under pci_tsm_rwsem held for read
- * and the DSM lock.
*/
struct_group_tagged(pci_tsm_link_ops, link_ops,
struct pci_tsm *(*probe)(struct tsm_dev *tsm_dev,
@@ -47,9 +42,6 @@ struct pci_tsm_ops {
void (*remove)(struct pci_tsm *tsm);
int (*connect)(struct pci_dev *pdev);
void (*disconnect)(struct pci_dev *pdev);
- struct pci_tdi *(*bind)(struct pci_dev *pdev,
- struct kvm *kvm, u32 tdi_id);
- void (*unbind)(struct pci_tdi *tdi);
);
/*
@@ -69,25 +61,12 @@ struct pci_tsm_ops {
);
};
-/**
- * struct pci_tdi - Core TEE I/O Device Interface (TDI) context
- * @pdev: host side representation of guest-side TDI
- * @kvm: TEE VM context of bound TDI
- * @tdi_id: Identifier (virtual BDF) for the TDI as referenced by the TSM and DSM
- */
-struct pci_tdi {
- struct pci_dev *pdev;
- struct kvm *kvm;
- u32 tdi_id;
-};
-
/**
* struct pci_tsm - Core TSM context for a given PCIe endpoint
* @pdev: Back ref to device function, distinguishes type of pci_tsm context
* @dsm_dev: PCI Device Security Manager for link operations on @pdev
* @tsm_dev: PCI TEE Security Manager device for Link Confidentiality or Device
* Function Security operations
- * @tdi: TDI context established by the @bind link operation
*
* This structure is wrapped by low level TSM driver data and returned by
* probe()/lock(), it is freed by the corresponding remove()/unlock().
@@ -103,7 +82,6 @@ struct pci_tsm {
struct pci_dev *pdev;
struct pci_dev *dsm_dev;
struct tsm_dev *tsm_dev;
- struct pci_tdi *tdi;
};
/**
@@ -163,10 +141,6 @@ int pci_tsm_pf0_constructor(struct pci_dev *pdev, struct pci_tsm_pf0 *tsm,
void pci_tsm_pf0_destructor(struct pci_tsm_pf0 *tsm);
int pci_tsm_doe_transfer(struct pci_dev *pdev, u8 type, const void *req,
size_t req_sz, void *resp, size_t resp_sz);
-int pci_tsm_bind(struct pci_dev *pdev, struct kvm *kvm, u32 tdi_id);
-void pci_tsm_unbind(struct pci_dev *pdev);
-void pci_tsm_tdi_constructor(struct pci_dev *pdev, struct pci_tdi *tdi,
- struct kvm *kvm, u32 tdi_id);
int pci_tsm_context_get(struct pci_dev *pdev, struct tsm_dev *tsm_dev);
void pci_tsm_context_put(struct pci_dev *pdev);
#else
@@ -177,13 +151,7 @@ static inline int pci_tsm_register(struct tsm_dev *tsm_dev)
static inline void pci_tsm_unregister(struct tsm_dev *tsm_dev)
{
}
-static inline int pci_tsm_bind(struct pci_dev *pdev, struct kvm *kvm, u64 tdi_id)
-{
- return -ENXIO;
-}
-static inline void pci_tsm_unbind(struct pci_dev *pdev)
-{
-}
+
static inline int
pci_tsm_context_get(struct pci_dev *pdev, struct tsm_dev *tsm_dev)
{
--
2.43.0
next prev parent reply other threads:[~2026-11-25 8:14 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 8:11 [PATCH v10 00/18] iommufd: TSM-backed virtual IOMMUs for confidential guests Aneesh Kumar K.V (Arm)
2026-11-25 8:11 ` [PATCH v10 01/18] MAINTAINERS: Update TSM file coverage and repository Aneesh Kumar K.V (Arm)
2026-11-25 8:11 ` [PATCH v10 02/18] virt: coco: tsm: Require PCI operations when registering a TSM Aneesh Kumar K.V (Arm)
2026-11-30 2:39 ` Xu Yilun
2026-11-25 8:11 ` [PATCH v10 03/18] virt: coco: tsm: Remove the device from lookup before PCI teardown Aneesh Kumar K.V (Arm)
2026-11-30 3:28 ` Xu Yilun
2026-11-25 8:11 ` [PATCH v10 04/18] virt: coco: tsm: Complete PCI registration before publishing the device Aneesh Kumar K.V (Arm)
2026-11-25 8:11 ` [PATCH v10 05/18] virt: coco: tsm: Register the TSM class before device drivers Aneesh Kumar K.V (Arm)
2026-11-25 8:25 ` sashiko-bot
2026-11-25 8:11 ` [PATCH v10 06/18] iommufd/device: Associate KVM file pointer with iommufd_device Aneesh Kumar K.V (Arm)
2026-11-25 8:11 ` [PATCH v10 07/18] iommufd/viommu: Keep a reference to the KVM file Aneesh Kumar K.V (Arm)
2026-11-25 8:11 ` [PATCH v10 08/18] iommufd: Add a vDEVICE operation ioctl framework Aneesh Kumar K.V (Arm)
2026-11-25 8:11 ` [PATCH v10 09/18] PCI/TSM: Remove the legacy guest request interface Aneesh Kumar K.V (Arm)
2026-11-25 8:11 ` [PATCH v10 10/18] PCI/TSM: Add helpers to prevent disconnect while in use Aneesh Kumar K.V (Arm)
2026-11-25 8:11 ` Aneesh Kumar K.V (Arm) [this message]
2026-11-25 8:11 ` [PATCH v10 12/18] iommufd/viommu: Select vIOMMU operations before allocation Aneesh Kumar K.V (Arm)
2026-11-25 8:28 ` sashiko-bot
2026-11-25 8:11 ` [PATCH v10 13/18] PCI/TSM: Add helpers to look up and reference a device's TSM Aneesh Kumar K.V (Arm)
2026-11-25 8:11 ` [PATCH v10 14/18] iommufd/viommu: Identify physical IOMMU backing with a tag Aneesh Kumar K.V (Arm)
2026-11-25 8:11 ` [PATCH v10 15/18] iommufd/viommu: Allow PCI TSM backends to provide vIOMMU operations Aneesh Kumar K.V (Arm)
2026-11-25 8:33 ` sashiko-bot
2026-11-25 10:55 ` Aneesh Kumar K.V
2026-11-25 8:11 ` [PATCH v10 16/18] iommufd/viommu: Allow vIOMMUs without a parent HWPT Aneesh Kumar K.V (Arm)
2026-11-25 8:11 ` [PATCH v10 17/18] PCI/TSM: Wait for DSM users before removing PF0 Aneesh Kumar K.V (Arm)
2026-11-25 8:11 ` [PATCH v10 18/18] PCI/TSM: Wait for vIOMMUs to release the TSM before unregistering Aneesh Kumar K.V (Arm)
2026-11-25 8:43 ` sashiko-bot
2026-11-25 10:53 ` Aneesh Kumar K.V
2026-11-25 8:43 ` [PATCH v10 00/18] iommufd: TSM-backed virtual IOMMUs for confidential guests sashiko-bot
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=20261125081121.379481-12-aneesh.kumar@kernel.org \
--to=aneesh.kumar@kernel.org \
--cc=aik@amd.com \
--cc=alex@shazbot.org \
--cc=ashish.kalra@amd.com \
--cc=bhelgaas@google.com \
--cc=catalin.marinas@arm.com \
--cc=herbert@gondor.apana.org.au \
--cc=iommu@lists.linux.dev \
--cc=jacob.pan@linux.microsoft.com \
--cc=jgg@ziepe.ca \
--cc=jic23@kernel.org \
--cc=jonathan.cameron@huawei.com \
--cc=jonathanh@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-pci@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=nicolinc@nvidia.com \
--cc=patches@lists.linux.dev \
--cc=robin.murphy@arm.com \
--cc=sameo@rivosinc.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=steven.price@arm.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=suzuki.poulose@arm.com \
--cc=thierry.reding@kernel.org \
--cc=thomas.lendacky@amd.com \
--cc=vasant.hegde@amd.com \
--cc=vdumpa@nvidia.com \
--cc=will@kernel.org \
--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 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.