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] [day] [month] [year] [list]
Message-ID: <ca1980887ae352811b922fca28965f5cd4639f97.camel@linux.ibm.com>
Date: Mon, 13 Oct 2025 11:59:14 +0200
From: Niklas Schnelle <schnelle@...ux.ibm.com>
To: Nicolin Chen <nicolinc@...dia.com>, joro@...tes.org, jgg@...dia.com,
        kevin.tian@...el.com
Cc: suravee.suthikulpanit@....com, will@...nel.org, robin.murphy@....com,
        sven@...nel.org, j@...nau.net, jean-philippe@...aro.org,
        robin.clark@....qualcomm.com, dwmw2@...radead.org,
        baolu.lu@...ux.intel.com, yong.wu@...iatek.com, matthias.bgg@...il.com,
        angelogioacchino.delregno@...labora.com, tjeznach@...osinc.com,
        pjw@...nel.org, palmer@...belt.com, aou@...s.berkeley.edu,
        heiko@...ech.de, mjrosato@...ux.ibm.com, wens@...e.org,
        jernej.skrabec@...il.com, samuel@...lland.org,
        thierry.reding@...il.com, jonathanh@...dia.com, iommu@...ts.linux.dev,
        linux-kernel@...r.kernel.org, asahi@...ts.linux.dev,
        linux-arm-kernel@...ts.infradead.org, linux-arm-msm@...r.kernel.org,
        linux-mediatek@...ts.infradead.org, linux-riscv@...ts.infradead.org,
        linux-rockchip@...ts.infradead.org, linux-s390@...r.kernel.org,
        linux-sunxi@...ts.linux.dev, linux-tegra@...r.kernel.org,
        virtualization@...ts.linux.dev, patches@...ts.linux.dev
Subject: Re: [PATCH v1 17/20] iommu/s390-iommu: Implement
 s390_iommu_domain_test_device

On Sun, 2025-10-12 at 17:05 -0700, Nicolin Chen wrote:
> Move sanity and compatibility tests from the attach_dev callback to the
> new test_dev callback function. The IOMMU core makes sure an attach_dev
> call must be invoked after a successful test_dev call.
> 
> Signed-off-by: Nicolin Chen <nicolinc@...dia.com>
> ---
>  drivers/iommu/s390-iommu.c | 22 +++++++++++++++-------
>  1 file changed, 15 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c
> index 366e47978ac07..3c6141a4a1faf 100644
> --- a/drivers/iommu/s390-iommu.c
> +++ b/drivers/iommu/s390-iommu.c
> @@ -694,6 +694,20 @@ static int blocking_domain_attach_device(struct iommu_domain *domain,
>  	return 0;
>  }
>  
> +static int s390_iommu_domain_test_device(struct iommu_domain *domain,
> +					 struct device *dev, ioasid_t pasid,
> +					 struct iommu_domain *old)
> +{
> +	struct zpci_dev *zdev = to_zpci_dev(dev);
> +
> +	if (!zdev)
> +		return -ENODEV;
> +	if (WARN_ON(domain->geometry.aperture_start > zdev->end_dma ||
> +		    domain->geometry.aperture_end < zdev->start_dma))
> +		return -EINVAL;
> +	return 0;
> +}
> +
>  static int s390_iommu_attach_device(struct iommu_domain *domain,
>  				    struct device *dev,
>  				    struct iommu_domain *old)
> @@ -704,13 +718,6 @@ static int s390_iommu_attach_device(struct iommu_domain *domain,
>  	u8 status;
>  	int cc;
>  
> -	if (!zdev)
> -		return -ENODEV;
> -
> -	if (WARN_ON(domain->geometry.aperture_start > zdev->end_dma ||
> -		domain->geometry.aperture_end < zdev->start_dma))
> -		return -EINVAL;
> -
>  	blocking_domain_attach_device(&blocking_domain, dev);
>  
>  	/* If we fail now DMA remains blocked via blocking domain */
> @@ -1177,6 +1184,7 @@ static struct iommu_domain blocking_domain = {
>  	.device_group = generic_device_group, \
>  	.get_resv_regions = s390_iommu_get_resv_regions, \
>  	.default_domain_ops = &(const struct iommu_domain_ops) { \
> +		.test_dev	= s390_iommu_domain_test_device, \
>  		.attach_dev	= s390_iommu_attach_device, \
>  		.map_pages	= s390_iommu_map_pages, \
>  		.unmap_pages	= s390_iommu_unmap_pages, \

Looks good to me, thanks!

Reviewed-by: Niklas Schnelle <schnelle@...ux.ibm.com>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ