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: <20240115172430.GN734935@nvidia.com>
Date: Mon, 15 Jan 2024 13:24:30 -0400
From: Jason Gunthorpe <jgg@...dia.com>
To: Yi Liu <yi.l.liu@...el.com>
Cc: joro@...tes.org, alex.williamson@...hat.com, kevin.tian@...el.com,
	robin.murphy@....com, baolu.lu@...ux.intel.com, cohuck@...hat.com,
	eric.auger@...hat.com, nicolinc@...dia.com, kvm@...r.kernel.org,
	mjrosato@...ux.ibm.com, chao.p.peng@...ux.intel.com,
	yi.y.sun@...ux.intel.com, peterx@...hat.com, jasowang@...hat.com,
	shameerali.kolothum.thodi@...wei.com, lulu@...hat.com,
	suravee.suthikulpanit@....com, iommu@...ts.linux.dev,
	linux-kernel@...r.kernel.org, linux-kselftest@...r.kernel.org,
	zhenzhong.duan@...el.com, joao.m.martins@...cle.com,
	xin.zeng@...el.com, yan.y.zhao@...el.com
Subject: Re: [PATCH 3/8] iommufd: Support attach/replace hwpt per pasid

On Sun, Nov 26, 2023 at 10:34:23PM -0800, Yi Liu wrote:
> @@ -534,7 +537,17 @@ iommufd_device_do_replace(struct iommufd_device *idev,
>  static struct iommufd_hw_pagetable *do_attach(struct iommufd_device *idev,
>  		struct iommufd_hw_pagetable *hwpt, struct attach_data *data)
>  {
> -	return data->attach_fn(idev, hwpt);
> +	if (data->pasid == IOMMU_PASID_INVALID) {
> +		BUG_ON((data->attach_fn != iommufd_device_do_attach) &&
> +		       (data->attach_fn != iommufd_device_do_replace));
> +		return data->attach_fn(idev, hwpt);
> +	} else {
> +		BUG_ON((data->pasid_attach_fn !=
> +			iommufd_device_pasid_do_attach) &&
> +		       (data->pasid_attach_fn !=
> +			iommufd_device_pasid_do_replace));
> +		return data->pasid_attach_fn(idev, data->pasid, hwpt);
> +	}

Seems like the BUG_ON's are pointless

> +/**
> + * iommufd_device_pasid_detach - Disconnect a {device, pasid} to an iommu_domain
> + * @idev: device to detach
> + * @pasid: pasid to detach
> + *
> + * Undo iommufd_device_pasid_attach(). This disconnects the idev/pasid from
> + * the previously attached pt_id.
> + */
> +void iommufd_device_pasid_detach(struct iommufd_device *idev, u32 pasid)
> +{
> +	struct iommufd_hw_pagetable *hwpt;
> +
> +	hwpt = xa_load(&idev->pasid_hwpts, pasid);
> +	if (!hwpt)
> +		return;
> +	xa_erase(&idev->pasid_hwpts, pasid);
> +	iommu_detach_device_pasid(hwpt->domain, idev->dev, pasid);
> +	iommufd_hw_pagetable_put(idev->ictx, hwpt);
> +}

None of this xarray stuff looks locked properly

Jason

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ