linux-doc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicolin Chen <nicolinc@nvidia.com>
To: Alexey Kardashevskiy <aik@amd.com>
Cc: <jgg@nvidia.com>, <kevin.tian@intel.com>, <corbet@lwn.net>,
	<joro@8bytes.org>, <suravee.suthikulpanit@amd.com>,
	<will@kernel.org>, <robin.murphy@arm.com>, <dwmw2@infradead.org>,
	<shuah@kernel.org>, <iommu@lists.linux.dev>,
	<linux-doc@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<linux-kselftest@vger.kernel.org>, <baolu.lu@linux.intel.com>,
	<eric.auger@redhat.com>, <jean-philippe@linaro.org>,
	<mdf@kernel.org>, <mshavit@google.com>,
	<shameerali.kolothum.thodi@huawei.com>, <smostafa@google.com>,
	<yi.l.liu@intel.com>, <zhangfei.gao@linaro.org>,
	<patches@lists.linux.dev>
Subject: Re: [PATCH v6 05/13] iommufd/viommu: Add IOMMU_VIOMMU_ALLOC ioctl
Date: Wed, 6 Nov 2024 18:03:50 -0800	[thread overview]
Message-ID: <ZywgBswnOahnFATB@Asurada-Nvidia> (raw)
In-Reply-To: <40c1587f-a6af-4851-8632-cb02adece66b@amd.com>

On Thu, Nov 07, 2024 at 12:37:59PM +1100, Alexey Kardashevskiy wrote:
> On 31/10/24 08:34, Nicolin Chen wrote:
> > +int iommufd_viommu_alloc_ioctl(struct iommufd_ucmd *ucmd)
> > +{
> > +     struct iommu_viommu_alloc *cmd = ucmd->cmd;
> > +     struct iommufd_hwpt_paging *hwpt_paging;
> > +     struct iommufd_viommu *viommu;
> > +     struct iommufd_device *idev;
> > +     const struct iommu_ops *ops;
> > +     int rc;
> > +
> > +     if (cmd->flags || cmd->type == IOMMU_VIOMMU_TYPE_DEFAULT)
> > +             return -EOPNOTSUPP;
> > +
> > +     idev = iommufd_get_device(ucmd, cmd->dev_id);
> > +     if (IS_ERR(idev))
> > +             return PTR_ERR(idev);
> > +
> > +     ops = dev_iommu_ops(idev->dev);
> > +     if (!ops->viommu_alloc) {
> > +             rc = -EOPNOTSUPP;
> > +             goto out_put_idev;
> > +     }
> > +
> > +     hwpt_paging = iommufd_get_hwpt_paging(ucmd, cmd->hwpt_id);
> > +     if (IS_ERR(hwpt_paging)) {
> > +             rc = PTR_ERR(hwpt_paging);
> > +             goto out_put_idev;
> > +     }
> > +
> > +     if (!hwpt_paging->nest_parent) {
> 
> 
> I am trying to use this for my so-called viommu which does not have this
> so this fails. My viommu is only visible to the VM via paravirt
> interface to populate sDTE (secure device table) so no viommu device in
> the guest or nested paging, nothing like this just yet.
> 
> Is there a writeup somewhere about possible uses of this
> IOMMU_HWPT_ALLOC_NEST_PARENT? I'd think one pass through device equals 1
> IOAS, 1 HWPT, 1 domain, 1 viommu, even with guest visible vIOMMU but it
> is not the case, is it?

So far, the vIOMMU is exclusively designed for nesting, with the
only use case of ARM SMMUv3. So, a nesting parent HWPT/domain is
a must. So long as your use case is a good fit, we can drop this
when adding support for your case, assuming there would be some
new iommufd patches.

For nesting, there will be at least two HWPTs (i.e. two domains)
for 2 stages. And stage-2 HWPT/domain is the nesting parent one.

> btw is there a way to get a snapshot of all current objects in iommufd?
> They all use "dev_id" and not file descriptors so cannot look at
> /proc/><pid>/fd, and there is nothing in debugfs either.

I am not aware of anything like that. How would you like to use
it if there was one?

> For my current hack, I can pass IOMMU_HWPT_ALLOC_NEST_PARENT to QEMU's
> iommufd_backend_alloc_hwpt() but it is... meh. Thanks,
 
Again, assuming you have some other iommufd patches, I think you
could have a small patch dropping this check -- we might need an
additional flag or another HWPT type, but we can discuss later.

Thanks
Nicolin

  reply	other threads:[~2024-11-07  2:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-30 21:34 [PATCH v6 00/13] iommufd: Add vIOMMU infrastructure (Part-1) Nicolin Chen
2024-10-30 21:34 ` [PATCH v6 01/13] iommufd: Move struct iommufd_object to public iommufd header Nicolin Chen
2024-10-30 21:34 ` [PATCH v6 02/13] iommufd: Move _iommufd_object_alloc helper to a sharable file Nicolin Chen
2024-10-31 13:12   ` Jason Gunthorpe
2024-10-30 21:34 ` [PATCH v6 03/13] iommufd: Introduce IOMMUFD_OBJ_VIOMMU and its related struct Nicolin Chen
2024-10-30 21:34 ` [PATCH v6 04/13] iommufd: Verify object in iommufd_object_finalize/abort() Nicolin Chen
2024-10-31 13:13   ` Jason Gunthorpe
2024-10-30 21:34 ` [PATCH v6 05/13] iommufd/viommu: Add IOMMU_VIOMMU_ALLOC ioctl Nicolin Chen
2024-11-07  1:37   ` Alexey Kardashevskiy
2024-11-07  2:03     ` Nicolin Chen [this message]
2024-11-07 18:46     ` Jason Gunthorpe
2024-10-30 21:34 ` [PATCH v6 06/13] iommufd: Add alloc_domain_nested op to iommufd_viommu_ops Nicolin Chen
2024-10-30 21:34 ` [PATCH v6 07/13] iommufd: Allow pt_id to carry viommu_id for IOMMU_HWPT_ALLOC Nicolin Chen
2024-10-31 13:14   ` Jason Gunthorpe
2024-10-31 16:37     ` Nicolin Chen
2024-10-30 21:34 ` [PATCH v6 08/13] iommufd/selftest: Add container_of helpers Nicolin Chen
2024-10-30 21:34 ` [PATCH v6 09/13] iommufd/selftest: Prepare for mock_viommu_alloc_domain_nested() Nicolin Chen
2024-10-30 21:34 ` [PATCH v6 10/13] iommufd/selftest: Add refcount to mock_iommu_device Nicolin Chen
2024-10-30 21:34 ` [PATCH v6 11/13] iommufd/selftest: Add IOMMU_VIOMMU_TYPE_SELFTEST Nicolin Chen
2024-10-30 21:34 ` [PATCH v6 12/13] iommufd/selftest: Add IOMMU_VIOMMU_ALLOC test coverage Nicolin Chen
2024-10-31 13:16   ` Jason Gunthorpe
2024-10-31 16:38     ` Nicolin Chen
2024-10-31 18:33       ` Nicolin Chen
2024-10-30 21:34 ` [PATCH v6 13/13] Documentation: userspace-api: iommufd: Update vIOMMU Nicolin Chen

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=ZywgBswnOahnFATB@Asurada-Nvidia \
    --to=nicolinc@nvidia.com \
    --cc=aik@amd.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=corbet@lwn.net \
    --cc=dwmw2@infradead.org \
    --cc=eric.auger@redhat.com \
    --cc=iommu@lists.linux.dev \
    --cc=jean-philippe@linaro.org \
    --cc=jgg@nvidia.com \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=mdf@kernel.org \
    --cc=mshavit@google.com \
    --cc=patches@lists.linux.dev \
    --cc=robin.murphy@arm.com \
    --cc=shameerali.kolothum.thodi@huawei.com \
    --cc=shuah@kernel.org \
    --cc=smostafa@google.com \
    --cc=suravee.suthikulpanit@amd.com \
    --cc=will@kernel.org \
    --cc=yi.l.liu@intel.com \
    --cc=zhangfei.gao@linaro.org \
    /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;
as well as URLs for NNTP newsgroup(s).