[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZRHOz+uuJ9gGE2ZF@Asurada-Nvidia>
Date: Mon, 25 Sep 2023 11:17:51 -0700
From: Nicolin Chen <nicolinc@...dia.com>
To: Jason Gunthorpe <jgg@...dia.com>
CC: Baolu Lu <baolu.lu@...ux.intel.com>, Yi Liu <yi.l.liu@...el.com>,
<joro@...tes.org>, <alex.williamson@...hat.com>,
<kevin.tian@...el.com>, <robin.murphy@....com>,
<cohuck@...hat.com>, <eric.auger@...hat.com>,
<kvm@...r.kernel.org>, <mjrosato@...ux.ibm.com>,
<chao.p.peng@...ux.intel.com>, <yi.y.sun@...ux.intel.com>,
<peterx@...hat.com>, <jasowang@...hat.com>,
<shameerali.kolothum.thodi@...wei.com>, <lulu@...hat.com>,
<suravee.suthikulpanit@....com>, <iommu@...ts.linux.dev>,
<linux-kernel@...r.kernel.org>, <linux-kselftest@...r.kernel.org>,
<zhenzhong.duan@...el.com>, <joao.m.martins@...cle.com>
Subject: Re: [PATCH v4 01/17] iommu: Add hwpt_type with user_data for
domain_alloc_user op
On Mon, Sep 25, 2023 at 10:05:06AM -0300, Jason Gunthorpe wrote:
> On Thu, Sep 21, 2023 at 01:58:19PM -0700, Nicolin Chen wrote:
>
> > Perhaps we could put all min_len defines in uAPI header, like:
> > include/uapi/linux/gfs2_ondisk.h:442:#define LH_V1_SIZE (offsetofend(struct gfs2_log_header, lh_hash))
> > In this way, drivers won't need to deal with that nor have risks
> > of breaking ABI by changing a min_len.
>
> I don't think we need constants, just be sure that every call to
> iommu_copy_user_data() has an offsetof() as the last parameter.
>
> Indeed perhaps you should put it in a macro and force this to happen eg:
>
> #define iommu_copy_user_data(user_data, from, min_size_member) \
> __iommu_copy_user_data(user_data, from, offsetofend(typeof(*from), min_size_member))
>
> iommu_copy_user_data(user_data, &data, iotlb);
OK. And always use sizeof(typeof(*from)) in the mcaro for the
current data_len, I assume?
Thanks
Nic
Powered by blists - more mailing lists