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: <20250613134522.GE1174925@nvidia.com>
Date: Fri, 13 Jun 2025 10:45:22 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: Nicolin Chen <nicolinc@...dia.com>
Cc: kevin.tian@...el.com, will@...nel.org, robin.murphy@....com,
	joro@...tes.org, ddutile@...hat.com, yi.l.liu@...el.com,
	peterz@...radead.org, jsnitsel@...hat.com, praan@...gle.com,
	linux-arm-kernel@...ts.infradead.org, iommu@...ts.linux.dev,
	linux-kernel@...r.kernel.org, patches@...ts.linux.dev,
	baolu.lu@...ux.intel.com
Subject: Re: [PATCH v1 06/12] iommufd/selftest: Implement
 mock_get_viommu_size and mock_viommu_init

On Mon, Jun 09, 2025 at 10:13:29AM -0700, Nicolin Chen wrote:
> Sanitize the inputs and report the size of struct mock_viommu on success,
> in mock_get_viommu_size().
> 
> The core will ensure the viommu_type is set to the core vIOMMU object, so
> simply init the driver part in mock_viommu_init().
> 
> The mock_viommu_alloc() will be cleaned up once the transition is done.

Note the addition of the missed s2_parent store

> Signed-off-by: Nicolin Chen <nicolinc@...dia.com>
> ---
>  drivers/iommu/iommufd/selftest.c | 25 +++++++++++++++++++++++++
>  1 file changed, 25 insertions(+)
> 
> diff --git a/drivers/iommu/iommufd/selftest.c b/drivers/iommu/iommufd/selftest.c
> index 4d5dca8027b1..b0de205a2303 100644
> --- a/drivers/iommu/iommufd/selftest.c
> +++ b/drivers/iommu/iommufd/selftest.c
> @@ -772,6 +772,29 @@ static struct iommufd_viommu_ops mock_viommu_ops = {
>  	.cache_invalidate = mock_viommu_cache_invalidate,
>  };
>  
> +static int mock_get_viommu_size(enum iommu_viommu_type viommu_type,
> +				struct device *dev, size_t *viommu_size)
> +{
> +	if (viommu_type != IOMMU_VIOMMU_TYPE_SELFTEST)
> +		return -EOPNOTSUPP;
> +	*viommu_size = VIOMMU_STRUCT_SIZE(struct mock_viommu, core);
> +	return 0;
> +}
> +
> +static int mock_viommu_init(struct iommufd_viommu *viommu,
> +			    struct iommu_domain *parent_domain)
> +{
> +	struct mock_iommu_device *mock_iommu = container_of(
> +		viommu->iommu_dev, struct mock_iommu_device, iommu_dev);
> +	struct mock_viommu *mock_viommu = to_mock_viommu(viommu);
> +
> +	refcount_inc(&mock_iommu->users);
> +	mock_viommu->s2_parent = to_mock_domain(parent_domain);
> +
> +	viommu->ops = &mock_viommu_ops;
> +	return 0;
> +}

The patches will read better if you add the call logic for init along
side alloc based on init or alloc ops being non-NULL in the prior
patch and then have these driver patches replace alloc with init.

Duplicating alloc into init and leaving both makes the patch harder to
check.

But the change looks right

Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ