lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 12 May 2024 19:35:32 -0700
From: Nicolin Chen <nicolinc@...dia.com>
To: Jason Gunthorpe <jgg@...dia.com>
CC: <will@...nel.org>, <robin.murphy@....com>, <kevin.tian@...el.com>,
	<suravee.suthikulpanit@....com>, <joro@...tes.org>,
	<linux-kernel@...r.kernel.org>, <iommu@...ts.linux.dev>,
	<linux-arm-kernel@...ts.infradead.org>, <linux-tegra@...r.kernel.org>,
	<yi.l.liu@...el.com>, <eric.auger@...hat.com>, <vasant.hegde@....com>,
	<jon.grimm@....com>, <santosh.shukla@....com>, <Dhaval.Giani@....com>,
	<shameerali.kolothum.thodi@...wei.com>
Subject: Re: [PATCH RFCv1 03/14] iommufd: Prepare for viommu structures and
 functions

On Sun, May 12, 2024 at 10:42:12AM -0300, Jason Gunthorpe wrote:
> On Fri, Apr 12, 2024 at 08:47:00PM -0700, Nicolin Chen wrote:
> 
> > +static inline struct iommufd_object *___iommufd_object_alloc(size_t size)
> > +{
> > +	struct iommufd_object *obj;
> > +
> > +	obj = kzalloc(size, GFP_KERNEL_ACCOUNT);
> > +	if (!obj)
> > +		return ERR_PTR(-ENOMEM);
> > +
> > +	/* Starts out bias'd by 1 until it is removed from the xarray */
> > +	refcount_set(&obj->shortterm_users, 1);
> > +	refcount_set(&obj->users, 1);
> > +
> > +	/*
> > +	 * The allocation of an obj->id needs an ictx, so it has to be done
> > +	 * after this ___iommufd_object_alloc() callback.
> > +	 */
> > +
> > +	return obj;
> > +}
> 
> It is probably cleaner to just make the existing allocation work with
> a NULL ictx for this case? Then we can use the existing alloc
> functions.
> 
> > +#define viommu_struct_alloc(name)                                              \
> > +	struct iommufd_##name *_iommufd_##name##_alloc(size_t size)            \
> > +	{                                                                      \
> > +		struct iommufd_object *obj;                                    \
> > +		if (WARN_ON(size < sizeof(struct iommufd_##name)))             \
> > +			return NULL;                                           \
> 
> Then here you'd just use the exisint container_of based flow with the
> driver sub struct name passed as the 'obj'

Yes. And then we can probably unwrap this macro too since it's
no long that verbose to duplicate in viommu/vqueue allocators.

Thanks
Nicolin

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ