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]
Message-ID: <ZkDHNP/sCxqxeyRq@nvidia.com>
Date: Sun, 12 May 2024 10:42:12 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: Nicolin Chen <nicolinc@...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 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'

Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ