From: Nicolin Chen <nicolinc@nvidia.com>
To: "Tian, Kevin" <kevin.tian@intel.com>
Cc: "jgg@nvidia.com" <jgg@nvidia.com>,
"will@kernel.org" <will@kernel.org>,
"joro@8bytes.org" <joro@8bytes.org>,
"suravee.suthikulpanit@amd.com" <suravee.suthikulpanit@amd.com>,
"robin.murphy@arm.com" <robin.murphy@arm.com>,
"dwmw2@infradead.org" <dwmw2@infradead.org>,
"baolu.lu@linux.intel.com" <baolu.lu@linux.intel.com>,
"shuah@kernel.org" <shuah@kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"iommu@lists.linux.dev" <iommu@lists.linux.dev>,
"linux-arm-kernel@lists.infradead.org"
<linux-arm-kernel@lists.infradead.org>,
"linux-kselftest@vger.kernel.org"
<linux-kselftest@vger.kernel.org>,
"eric.auger@redhat.com" <eric.auger@redhat.com>,
"jean-philippe@linaro.org" <jean-philippe@linaro.org>,
"mdf@kernel.org" <mdf@kernel.org>,
"mshavit@google.com" <mshavit@google.com>,
"shameerali.kolothum.thodi@huawei.com"
<shameerali.kolothum.thodi@huawei.com>,
"smostafa@google.com" <smostafa@google.com>,
"Liu, Yi L" <yi.l.liu@intel.com>, "aik@amd.com" <aik@amd.com>,
"zhangfei.gao@linaro.org" <zhangfei.gao@linaro.org>,
"patches@lists.linux.dev" <patches@lists.linux.dev>
Subject: Re: [PATCH v5 01/13] iommufd/viommu: Add IOMMUFD_OBJ_VDEVICE and IOMMU_VDEVICE_ALLOC ioctl
Date: Mon, 28 Oct 2024 13:18:50 -0700 [thread overview]
Message-ID: <Zx/xqlvEBZgmV84d@Asurada-Nvidia> (raw)
In-Reply-To: <BN9PR11MB52765EED4209A26DC60F138D8C4A2@BN9PR11MB5276.namprd11.prod.outlook.com>
On Mon, Oct 28, 2024 at 03:11:32AM +0000, Tian, Kevin wrote:
> > From: Nicolin Chen <nicolinc@nvidia.com>
> > Sent: Saturday, October 26, 2024 7:51 AM
> >
> > +
> > +/**
> > + * struct iommu_vdevice_alloc - ioctl(IOMMU_VDEVICE_ALLOC)
> > + * @size: sizeof(struct iommu_vdevice_alloc)
> > + * @viommu_id: vIOMMU ID to associate with the virtual device
> > + * @dev_id: The pyhsical device to allocate a virtual instance on the
> > vIOMMU
>
> s/pyhsical/physical/, or just say 'iommufd device"
Ack for "physical", aligning with other @dev_id lines.
> > +
> > +int iommufd_vdevice_alloc_ioctl(struct iommufd_ucmd *ucmd)
> > +{
> > + struct iommu_vdevice_alloc *cmd = ucmd->cmd;
> > + struct iommufd_vdevice *vdev, *curr;
> > + struct iommufd_viommu *viommu;
> > + struct iommufd_device *idev;
> > + u64 virt_id = cmd->virt_id;
> > + int rc = 0;
> > +
> > + if (virt_id > ULONG_MAX)
> > + return -EINVAL;
> > +
> > + viommu = iommufd_get_viommu(ucmd, cmd->viommu_id);
> > + if (IS_ERR(viommu))
> > + return PTR_ERR(viommu);
> > +
> > + idev = iommufd_get_device(ucmd, cmd->dev_id);
> > + if (IS_ERR(idev)) {
> > + rc = PTR_ERR(idev);
> > + goto out_put_viommu;
> > + }
> > +
> > + mutex_lock(&idev->igroup->lock);
> > + if (idev->vdev) {
> > + rc = -EEXIST;
> > + goto out_unlock_igroup;
> > + }
> > +
> > + vdev = iommufd_object_alloc(ucmd->ictx, vdev,
> > IOMMUFD_OBJ_VDEVICE);
> > + if (IS_ERR(vdev)) {
> > + rc = PTR_ERR(vdev);
> > + goto out_unlock_igroup;
> > + }
> > +
>
> also need to check that the device and the viommu are associated
> to a same physical iommu.
Ack. Will add this prior to mutex_lock(&idev->igroup->lock);
+ if (viommu->iommu_dev != __iommu_get_iommu_dev(idev->dev)) {
+ rc = -EINVAL;
+ goto out_put_idev;
+ }
Thanks!
Nicolin
next prev parent reply other threads:[~2024-10-28 20:21 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-25 23:50 [PATCH v5 00/13] iommufd: Add vIOMMU infrastructure (Part-2: vDEVICE) Nicolin Chen
2024-10-25 23:50 ` [PATCH v5 01/13] iommufd/viommu: Add IOMMUFD_OBJ_VDEVICE and IOMMU_VDEVICE_ALLOC ioctl Nicolin Chen
2024-10-28 3:11 ` Tian, Kevin
2024-10-28 20:18 ` Nicolin Chen [this message]
2024-10-29 15:58 ` Jason Gunthorpe
2024-10-29 17:29 ` Nicolin Chen
2024-10-29 18:48 ` Jason Gunthorpe
2024-10-29 19:30 ` Nicolin Chen
2024-10-30 0:08 ` Jason Gunthorpe
2024-10-25 23:50 ` [PATCH v5 02/13] iommufd/selftest: Add IOMMU_VDEVICE_ALLOC test coverage Nicolin Chen
2024-10-29 8:19 ` Tian, Kevin
2024-10-29 15:58 ` Jason Gunthorpe
2024-10-25 23:50 ` [PATCH v5 03/13] iommu/viommu: Add cache_invalidate to iommufd_viommu_ops Nicolin Chen
2024-10-29 8:19 ` Tian, Kevin
2024-10-25 23:50 ` [PATCH v5 04/13] iommufd/hw_pagetable: Enforce invalidation op on vIOMMU-based hwpt_nested Nicolin Chen
2024-10-29 8:22 ` Tian, Kevin
2024-10-29 16:04 ` Jason Gunthorpe
2024-10-30 0:41 ` Tian, Kevin
2024-10-29 16:01 ` Jason Gunthorpe
2024-10-25 23:50 ` [PATCH v5 05/13] iommufd: Allow hwpt_id to carry viommu_id for IOMMU_HWPT_INVALIDATE Nicolin Chen
2024-10-29 8:23 ` Tian, Kevin
2024-10-29 19:09 ` Jason Gunthorpe
2024-10-29 19:45 ` Nicolin Chen
2024-10-25 23:50 ` [PATCH v5 06/13] iommu: Add iommu_copy_struct_from_full_user_array helper Nicolin Chen
2024-10-29 8:24 ` Tian, Kevin
2024-10-30 4:08 ` Nicolin Chen
2024-10-25 23:50 ` [PATCH v5 07/13] iommufd/viommu: Add iommufd_viommu_find_dev helper Nicolin Chen
2024-10-27 15:02 ` Zhangfei Gao
2024-10-27 22:49 ` Nicolin Chen
2024-10-29 8:25 ` Tian, Kevin
2024-10-25 23:50 ` [PATCH v5 08/13] iommufd/selftest: Add mock_viommu_cache_invalidate Nicolin Chen
2024-10-29 8:25 ` Tian, Kevin
2024-10-25 23:50 ` [PATCH v5 09/13] iommufd/selftest: Add IOMMU_TEST_OP_DEV_CHECK_CACHE test command Nicolin Chen
2024-10-29 8:25 ` Tian, Kevin
2024-10-25 23:50 ` [PATCH v5 10/13] iommufd/selftest: Add vIOMMU coverage for IOMMU_HWPT_INVALIDATE ioctl Nicolin Chen
2024-10-29 8:26 ` Tian, Kevin
2024-10-25 23:50 ` [PATCH v5 11/13] Documentation: userspace-api: iommufd: Update vDEVICE Nicolin Chen
2024-10-29 8:40 ` Tian, Kevin
2024-10-25 23:50 ` [PATCH v5 12/13] iommu/arm-smmu-v3: Add arm_vsmmu_cache_invalidate Nicolin Chen
2024-10-29 8:42 ` Tian, Kevin
2024-10-25 23:50 ` [PATCH v5 13/13] iommu/arm-smmu-v3: Allow ATS for IOMMU_DOMAIN_NESTED Nicolin Chen
2024-10-28 3:03 ` [PATCH v5 00/13] iommufd: Add vIOMMU infrastructure (Part-2: vDEVICE) Tian, Kevin
2024-10-28 14:17 ` Jason Gunthorpe
2024-10-29 8:51 ` Tian, Kevin
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=Zx/xqlvEBZgmV84d@Asurada-Nvidia \
--to=nicolinc@nvidia.com \
--cc=aik@amd.com \
--cc=baolu.lu@linux.intel.com \
--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-arm-kernel@lists.infradead.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).