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: <20241025132054.GE6956@nvidia.com>
Date: Fri, 25 Oct 2024 10:20:54 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: Alexey Kardashevskiy <aik@....com>
Cc: Nicolin Chen <nicolinc@...dia.com>, kevin.tian@...el.com,
	will@...nel.org, joro@...tes.org, suravee.suthikulpanit@....com,
	robin.murphy@....com, dwmw2@...radead.org, baolu.lu@...ux.intel.com,
	shuah@...nel.org, linux-kernel@...r.kernel.org,
	iommu@...ts.linux.dev, linux-arm-kernel@...ts.infradead.org,
	linux-kselftest@...r.kernel.org, eric.auger@...hat.com,
	jean-philippe@...aro.org, mdf@...nel.org, mshavit@...gle.com,
	shameerali.kolothum.thodi@...wei.com, smostafa@...gle.com,
	yi.l.liu@...el.com, zhangfei.gao@...aro.org,
	patches@...ts.linux.dev
Subject: Re: [PATCH v4 01/14] iommufd/viommu: Introduce IOMMUFD_OBJ_VDEVICE
 and its related struct

On Fri, Oct 25, 2024 at 06:53:01PM +1100, Alexey Kardashevskiy wrote:
> > +#define iommufd_vdevice_alloc(ictx, drv_struct, member)                        \
> > +	({                                                                     \
> > +		static_assert(                                                 \
> > +			__same_type(struct iommufd_vdevice,                    \
> > +				    ((struct drv_struct *)NULL)->member));     \
> > +		static_assert(offsetof(struct drv_struct, member.obj) == 0);   \
> > +		container_of(_iommufd_object_alloc(ictx,                       \
> > +						   sizeof(struct drv_struct),  \
> > +						   IOMMUFD_OBJ_VDEVICE),       \
> > +			     struct drv_struct, member.obj);                   \
> > +	})
> >   #endif
> 
> A nit: it hurts eyes to read:
> 
> mock_vdev = iommufd_vdevice_alloc(viommu->ictx, mock_vdevice, core);
> 
> vs.
> 
> mock_vdev = iommufd_vdevice_alloc(viommu->ictx, struct mock_vdevice, core);
> 
> as for the former I go searching for a "mock_vdevice" variable and for the
> latter it is clear it is 1) a macro 2) which does some type checking.
> 
> also, it makes it impossible to pass things like typeof(..) or a type from
> typedef. Thanks,

Makes sense to me

And the container_of() should not be used in these macros, the point
was to avoid it to make the PTR_ERR behavior cleraer. Just put a force
type cast

Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ