public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Nicolin Chen <nicolinc@nvidia.com>
Cc: Zhangfei Gao <zhangfei.gao@linaro.org>,
	kevin.tian@intel.com, will@kernel.org, joro@8bytes.org,
	suravee.suthikulpanit@amd.com, robin.murphy@arm.com,
	dwmw2@infradead.org, baolu.lu@linux.intel.com, shuah@kernel.org,
	linux-kernel@vger.kernel.org, iommu@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-kselftest@vger.kernel.org, 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, aik@amd.com, patches@lists.linux.dev
Subject: Re: [PATCH v5 06/13] iommufd: Allow pt_id to carry viommu_id for IOMMU_HWPT_ALLOC
Date: Tue, 29 Oct 2024 12:27:46 -0300	[thread overview]
Message-ID: <20241029152746.GE209124@nvidia.com> (raw)
In-Reply-To: <Zx+lGr9iD4DSkc8I@Asurada-Nvidia>

On Mon, Oct 28, 2024 at 07:52:10AM -0700, Nicolin Chen wrote:
> On Mon, Oct 28, 2024 at 10:03:09AM -0300, Jason Gunthorpe wrote:
> > On Mon, Oct 28, 2024 at 11:24:10AM +0800, Zhangfei Gao wrote:
> > 
> > > > +/**
> > > > + * iommufd_viommu_alloc_hwpt_nested() - Get a hwpt_nested for a vIOMMU
> > > > + * @viommu: vIOMMU ojbect to associate the hwpt_nested/domain with
> > > > + * @user_data: user_data pointer. Must be valid
> > > > + *
> > > > + * Allocate a new IOMMU_DOMAIN_NESTED for a vIOMMU and return it as a NESTED
> > > > + * hw_pagetable.
> > > > + */
> > > > +static struct iommufd_hwpt_nested *
> > > > +iommufd_viommu_alloc_hwpt_nested(struct iommufd_viommu *viommu, u32 flags,
> > > > +                                const struct iommu_user_data *user_data)
> > > > +{
> > > > +       struct iommufd_hwpt_nested *hwpt_nested;
> > > > +       struct iommufd_hw_pagetable *hwpt;
> > > > +       int rc;
> > > > +
> > > > +       if (flags)
> > > > +               return ERR_PTR(-EOPNOTSUPP);
> > > 
> > > This check should be removed.
> > > 
> > > When a user page fault is required, IOMMU_HWPT_FAULT_ID_VALID is set.
> > > if (cmd->flags & IOMMU_HWPT_FAULT_ID_VALID) {
> > 
> > It can't just be removed..
> > 
> > I suspect that IOMMU_HWPT_FAULT_ID_VALID should not be set on the
> > nested domain but on the parent?
> 
> By giving another look,
> 
> In iommufd_hwpt_paging_alloc(), we reject IOMMU_HWPT_FAULT_ID_VALID:
> 	const u32 valid_flags = IOMMU_HWPT_ALLOC_NEST_PARENT |
> 				IOMMU_HWPT_ALLOC_DIRTY_TRACKING;
> 	...
> 	if (flags & ~valid_flags)
> 		return ERR_PTR(-EOPNOTSUPP);
> 
> In iommufd_hwpt_nested_alloc(), we mask the flag away:
> 	if ((flags & ~IOMMU_HWPT_FAULT_ID_VALID) ||
> 	    !user_data->len || !ops->domain_alloc_user)
> 		return ERR_PTR(-EOPNOTSUPP);
> 	...
> 	hwpt->domain = ops->domain_alloc_user(idev->dev,
> 					      flags & ~IOMMU_HWPT_FAULT_ID_VALID,
> 					      parent->common.domain, user_data);
> 
> Then, in the common function it has a section of
> 	if (cmd->flags & IOMMU_HWPT_FAULT_ID_VALID) {
> 	...
> 
> It seems that this IOMMU_HWPT_FAULT_ID_VALID is for nested domains?

OK, but ARM should be blocking it since it doesn't work there.

I think we made some error here, it should have been passed in flags
to the drivers and only intel should have accepted it.

This suggests we should send flags down the viommu alloc domain path too.

Jason

  parent reply	other threads:[~2024-10-29 15:27 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-25 23:49 [PATCH v5 00/13] iommufd: Add vIOMMU infrastructure (Part-1) Nicolin Chen
2024-10-25 23:49 ` [PATCH v5 01/13] iommufd: Move struct iommufd_object to public iommufd header Nicolin Chen
2024-10-25 23:49 ` [PATCH v5 02/13] iommufd: Introduce IOMMUFD_OBJ_VIOMMU and its related struct Nicolin Chen
2024-10-28  2:41   ` Tian, Kevin
2024-10-29 14:42   ` Jason Gunthorpe
2024-10-25 23:49 ` [PATCH v5 03/13] iommufd: Add iommufd_verify_unfinalized_object Nicolin Chen
2024-10-29 14:49   ` Jason Gunthorpe
2024-10-29 16:18     ` Nicolin Chen
2024-10-29 18:55       ` Jason Gunthorpe
2024-10-29 19:32         ` Nicolin Chen
2024-10-30  4:05         ` Nicolin Chen
2024-10-30 12:53           ` Jason Gunthorpe
2024-10-25 23:49 ` [PATCH v5 04/13] iommufd/viommu: Add IOMMU_VIOMMU_ALLOC ioctl Nicolin Chen
2024-10-28  2:43   ` Tian, Kevin
2024-10-29 14:54   ` Jason Gunthorpe
2024-10-29 15:36     ` Jason Gunthorpe
2024-10-29 15:46       ` Nicolin Chen
2024-10-29 15:59         ` Jason Gunthorpe
2024-10-29 16:03           ` Nicolin Chen
2024-10-29 15:37     ` Nicolin Chen
2024-10-25 23:49 ` [PATCH v5 05/13] iommufd: Add alloc_domain_nested op to iommufd_viommu_ops Nicolin Chen
2024-10-29 15:25   ` Jason Gunthorpe
2024-10-25 23:49 ` [PATCH v5 06/13] iommufd: Allow pt_id to carry viommu_id for IOMMU_HWPT_ALLOC Nicolin Chen
2024-10-28  2:46   ` Tian, Kevin
2024-10-28  3:24   ` Zhangfei Gao
2024-10-28 13:03     ` Jason Gunthorpe
2024-10-28 14:52       ` Nicolin Chen
2024-10-28 21:08         ` Nicolin Chen
2024-10-29 15:27         ` Jason Gunthorpe [this message]
2024-10-29 16:07           ` Nicolin Chen
2024-10-29 18:53             ` Jason Gunthorpe
2024-10-28 14:53     ` Zhangfei Gao
2024-10-28 15:01       ` Nicolin Chen
2024-10-25 23:49 ` [PATCH v5 07/13] iommufd/selftest: Add container_of helpers Nicolin Chen
2024-10-28  2:46   ` Tian, Kevin
2024-10-29 15:28   ` Jason Gunthorpe
2024-10-25 23:49 ` [PATCH v5 08/13] iommufd/selftest: Prepare for mock_viommu_alloc_domain_nested() Nicolin Chen
2024-10-28  2:48   ` Tian, Kevin
2024-10-29 15:30   ` Jason Gunthorpe
2024-10-25 23:49 ` [PATCH v5 09/13] iommufd/selftest: Add refcount to mock_iommu_device Nicolin Chen
2024-10-28  2:49   ` Tian, Kevin
2024-10-29 15:34   ` Jason Gunthorpe
2024-10-29 16:02     ` Nicolin Chen
2024-10-29 18:53       ` Jason Gunthorpe
2024-10-25 23:49 ` [PATCH v5 10/13] iommufd/selftest: Add IOMMU_VIOMMU_TYPE_SELFTEST Nicolin Chen
2024-10-28  2:51   ` Tian, Kevin
2024-10-29 15:41   ` Jason Gunthorpe
2024-10-25 23:49 ` [PATCH v5 11/13] iommufd/selftest: Add IOMMU_VIOMMU_ALLOC test coverage Nicolin Chen
2024-10-28  2:52   ` Tian, Kevin
2024-10-25 23:49 ` [PATCH v5 12/13] Documentation: userspace-api: iommufd: Update vIOMMU Nicolin Chen
2024-10-30  6:16   ` Nicolin Chen
2024-10-25 23:49 ` [PATCH v5 13/13] iommu/arm-smmu-v3: Add IOMMU_VIOMMU_TYPE_ARM_SMMUV3 support Nicolin Chen
2024-10-28  2:54   ` 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=20241029152746.GE209124@nvidia.com \
    --to=jgg@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=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=nicolinc@nvidia.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