From: Jason Gunthorpe <jgg@nvidia.com>
To: "Aneesh Kumar K.V" <aneesh.kumar@kernel.org>
Cc: linux-coco@lists.linux.dev, iommu@lists.linux.dev,
linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
Alexey Kardashevskiy <aik@amd.com>,
Bjorn Helgaas <helgaas@kernel.org>,
Joerg Roedel <joro@8bytes.org>,
Jonathan Cameron <jic23@kernel.org>,
Kevin Tian <kevin.tian@intel.com>,
Nicolin Chen <nicolinc@nvidia.com>,
Samuel Ortiz <sameo@rivosinc.com>,
Steven Price <steven.price@arm.com>,
Suzuki K Poulose <Suzuki.Poulose@arm.com>,
Will Deacon <will@kernel.org>,
Xu Yilun <yilun.xu@linux.intel.com>,
Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [RFC PATCH v6 08/11] iommufd: Add vIOMMU provider support
Date: Fri, 25 Sep 2026 09:39:18 -0300 [thread overview]
Message-ID: <20260925123918.GI9354@nvidia.com> (raw)
In-Reply-To: <yq5acxu1kgmo.fsf@kernel.org>
On Fri, Sep 25, 2026 at 11:38:15AM +0530, Aneesh Kumar K.V wrote:
> Jason Gunthorpe <jgg@nvidia.com> writes:
>
> >> vIOMMU creation currently dispatches directly through the physical IOMMU
> >> driver. Some vIOMMU types need an implementation supplied by another
> >> subsystem, together with private data whose lifetime extends across all
> >> vIOMMUs using that implementation.
> >>
> >> Introduce a vIOMMU provider that associates implementation operations,
> >> their module owner and private data. Allow one external provider to
> >> register for each non-default vIOMMU type.
> >
> > This seems much more extensive than I imagined when I proposed this.
> >
> > I imagined you'd just have iommufd see there is a TSM attached the pci
> > device with a function call, and check if that TSM handled the
> > requested iommu ID.
> >
> > No need for a registration system because we already know the only
> > possible TSM driver that can handle it,
> >
>
> Agreed, there will be only one vIOMMU provider. But, without a
> registration mechanism, what would the module dependency look like?
>
> I currently have the TSM driver depending on IOMMUFD. Therefore, the TSM
> driver needs to tell iommufd which vIOMMU type it provides and register
> the corresponding provider. IOMMUFD does not call into TSM directly.
Just put the two new ops in:
struct pci_tsm_ops {
size_t (*viommu_get_size)(struct device *dev, enum iommu_viommu_type type);
int (*viommu_init)(struct iommufd_viommu *viommu, struct device *dev,
struct iommu_domain *parent,
const struct iommu_user_data *user_data);
}
And bounce them with a static inline
static inline
ssize_t pci_tsm_viommu_get_size(struct device *dev, enum iommu_viommu_type type)
{
const struct pci_tsm_ops *ops;
struct pci_dev *pdev;
if (!dev_is_pci(dev))
return -EINVAL;
pdev = to_pci_dev(dev);
if (!pdev->tsm)
return -ENODEV;
ops = to_pci_tsm_ops(pdev->tsm);
if (!ops->viommu_get_size)
return 0;
return ops->viommu_get_size(dev, type);
}
No module dependency.
The iommufd side is simple, it just calls this before calling the
iommu driver. First one to return a size wins and creates the viommu.
We'd want to have a reasonable lifetime model where the the pdev->tsm
is guarenteed stable while a driver is bound.
Jason
next prev parent reply other threads:[~2026-09-25 12:39 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 14:01 [RFC PATCH v6 00/11] iommufd: Infrastructure for vIOMMU creation for confidential guests and guest TSM requests Aneesh Kumar K.V (Arm)
2026-09-17 14:01 ` [RFC PATCH v6 01/11] vfio: cache KVM VM file references instead of raw struct kvm pointers Aneesh Kumar K.V (Arm)
2026-09-24 19:41 ` Jason Gunthorpe
2026-09-17 14:01 ` [RFC PATCH v6 02/11] vfio: cdev: Reject duplicate bind before updating KVM file Aneesh Kumar K.V (Arm)
2026-09-24 7:53 ` Tian, Kevin
2026-09-25 5:49 ` Aneesh Kumar K.V
2026-09-17 14:01 ` [RFC PATCH v6 03/11] iommufd/device: Associate KVM file pointer with iommufd_device Aneesh Kumar K.V (Arm)
2026-09-17 14:01 ` [RFC PATCH v6 04/11] iommufd/viommu: Keep a reference to the KVM file Aneesh Kumar K.V (Arm)
2026-09-17 14:01 ` [RFC PATCH v6 05/11] iommu: Add a helper to validate a vIOMMU parent Aneesh Kumar K.V (Arm)
2026-09-24 19:41 ` Jason Gunthorpe
2026-09-25 5:48 ` Aneesh Kumar K.V
2026-09-25 12:23 ` Jason Gunthorpe
2026-09-17 14:01 ` [RFC PATCH v6 06/11] iommu: Add a helper to query vIOMMU hardware parameters Aneesh Kumar K.V (Arm)
2026-09-24 19:41 ` Jason Gunthorpe
2026-09-25 5:59 ` Aneesh Kumar K.V
2026-09-25 12:29 ` Jason Gunthorpe
2026-09-17 14:01 ` [RFC PATCH v6 07/11] coco: tsm: Expose active-user lifetime references Aneesh Kumar K.V (Arm)
2026-09-17 14:01 ` [RFC PATCH v6 08/11] iommufd: Add vIOMMU provider support Aneesh Kumar K.V (Arm)
2026-09-24 19:41 ` Jason Gunthorpe
2026-09-25 6:08 ` Aneesh Kumar K.V
2026-09-25 12:39 ` Jason Gunthorpe [this message]
2026-09-17 14:01 ` [RFC PATCH v6 09/11] iommufd: Add the vdevice TSM request ioctl Aneesh Kumar K.V (Arm)
2026-09-18 13:09 ` Alexey Kardashevskiy
2026-09-18 13:13 ` Jason Gunthorpe
2026-09-24 19:41 ` Jason Gunthorpe
2026-09-17 14:01 ` [RFC PATCH v6 10/11] PCI/TSM: Remove the legacy guest request interface Aneesh Kumar K.V (Arm)
2026-09-17 14:01 ` [RFC PATCH v6 11/11] PCI/TSM: Add reference-counted contexts for vdevice providers Aneesh Kumar K.V (Arm)
2026-09-24 8:17 ` Tian, Kevin
2026-09-24 19:41 ` Jason Gunthorpe
2026-09-25 8:15 ` Aneesh Kumar K.V
2026-09-17 14:17 ` [RFC PATCH v6 00/11] iommufd: Infrastructure for vIOMMU creation for confidential guests and guest TSM requests Aneesh Kumar K.V
2026-09-24 7:48 ` Tian, Kevin
2026-09-24 19:20 ` Jason Gunthorpe
2026-09-25 8:29 ` Aneesh Kumar K.V
2026-09-24 19:09 ` Jason Gunthorpe
2026-09-25 6:46 ` Aneesh Kumar K.V
2026-09-25 12:45 ` 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=20260925123918.GI9354@nvidia.com \
--to=jgg@nvidia.com \
--cc=Suzuki.Poulose@arm.com \
--cc=aik@amd.com \
--cc=aneesh.kumar@kernel.org \
--cc=helgaas@kernel.org \
--cc=iommu@lists.linux.dev \
--cc=jic23@kernel.org \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-coco@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolinc@nvidia.com \
--cc=pbonzini@redhat.com \
--cc=sameo@rivosinc.com \
--cc=shameerali.kolothum.thodi@huawei.com \
--cc=steven.price@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®