[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZMe0IQksFgV6yKTB@nvidia.com>
Date: Mon, 31 Jul 2023 10:16:17 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: "Tian, Kevin" <kevin.tian@...el.com>
Cc: "Liu, Yi L" <yi.l.liu@...el.com>,
"joro@...tes.org" <joro@...tes.org>,
"alex.williamson@...hat.com" <alex.williamson@...hat.com>,
"robin.murphy@....com" <robin.murphy@....com>,
"baolu.lu@...ux.intel.com" <baolu.lu@...ux.intel.com>,
"cohuck@...hat.com" <cohuck@...hat.com>,
"eric.auger@...hat.com" <eric.auger@...hat.com>,
"nicolinc@...dia.com" <nicolinc@...dia.com>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>,
"mjrosato@...ux.ibm.com" <mjrosato@...ux.ibm.com>,
"chao.p.peng@...ux.intel.com" <chao.p.peng@...ux.intel.com>,
"yi.y.sun@...ux.intel.com" <yi.y.sun@...ux.intel.com>,
"peterx@...hat.com" <peterx@...hat.com>,
"jasowang@...hat.com" <jasowang@...hat.com>,
"shameerali.kolothum.thodi@...wei.com"
<shameerali.kolothum.thodi@...wei.com>,
"lulu@...hat.com" <lulu@...hat.com>,
"suravee.suthikulpanit@....com" <suravee.suthikulpanit@....com>,
"iommu@...ts.linux.dev" <iommu@...ts.linux.dev>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-kselftest@...r.kernel.org" <linux-kselftest@...r.kernel.org>,
"Duan, Zhenzhong" <zhenzhong.duan@...el.com>
Subject: Re: [PATCH v3 08/17] iommufd: IOMMU_HWPT_ALLOC allocation with user
data
On Mon, Jul 31, 2023 at 06:31:20AM +0000, Tian, Kevin wrote:
> > From: Jason Gunthorpe <jgg@...dia.com>
> > Sent: Saturday, July 29, 2023 1:56 AM
> >
> > On Mon, Jul 24, 2023 at 04:03:57AM -0700, Yi Liu wrote:
> >
> > > + switch (pt_obj->type) {
> > > + case IOMMUFD_OBJ_IOAS:
> > > + ioas = container_of(pt_obj, struct iommufd_ioas, obj);
> > > + break;
> > > + case IOMMUFD_OBJ_HW_PAGETABLE:
> > > + /* pt_id points HWPT only when hwpt_type
> > is !IOMMU_HWPT_TYPE_DEFAULT */
> > > + if (cmd->hwpt_type == IOMMU_HWPT_TYPE_DEFAULT) {
> > > + rc = -EINVAL;
> > > + goto out_put_pt;
> > > + }
> > > +
> > > + parent = container_of(pt_obj, struct iommufd_hw_pagetable,
> > obj);
> > > + /*
> > > + * Cannot allocate user-managed hwpt linking to
> > auto_created
> > > + * hwpt. If the parent hwpt is already a user-managed hwpt,
> > > + * don't allocate another user-managed hwpt linking to it.
> > > + */
> > > + if (parent->auto_domain || parent->parent) {
> > > + rc = -EINVAL;
> > > + goto out_put_pt;
> > > + }
> > > + ioas = parent->ioas;
> >
> > Why do we set ioas here? I would think it should be NULL.
> >
> > I think it is looking like a mistake to try and re-use
> > iommufd_hw_pagetable_alloc() directly for the nested case. It should
> > not have a IOAS argument, it should not do enforce_cc, or iopt_*
> > functions
>
> enforce_cc is still required since it's about memory accesses post
> page table walking (no matter the walked table is single stage or
> nested).
enforce_cc only has meaning if the kernel owns the IOPTEs, and if we
are creating a nest it does not. The guest has to set any necessary
IOPTE bits.
enforce_cc will be done on the parent of the nest as normal.
> Ideally expanding uAPI structure size should come with new flag bits.
Flags or some kind of 'zero is the same behavior as a smaller struct'
scheme.
This patch is doing the zero option:
__u32 __reserved;
+ __u32 hwpt_type;
+ __u32 data_len;
+ __aligned_u64 data_uptr;
};
hwpt_type == 0 means default type
data_len == 0 means no data
data_uptr is ignored (zero is safe)
So there is no need to change it
Jason
Powered by blists - more mailing lists