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: <BN9PR11MB5276E7E2BA88DD54DC5EE99A8C849@BN9PR11MB5276.namprd11.prod.outlook.com>
Date:   Fri, 24 Mar 2023 03:02:46 +0000
From:   "Tian, Kevin" <kevin.tian@...el.com>
To:     Nicolin Chen <nicolinc@...dia.com>,
        "jgg@...dia.com" <jgg@...dia.com>,
        "joro@...tes.org" <joro@...tes.org>,
        "will@...nel.org" <will@...nel.org>,
        "robin.murphy@....com" <robin.murphy@....com>,
        "alex.williamson@...hat.com" <alex.williamson@...hat.com>,
        "shuah@...nel.org" <shuah@...nel.org>
CC:     "Liu, Yi L" <yi.l.liu@...el.com>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "iommu@...ts.linux.dev" <iommu@...ts.linux.dev>,
        "kvm@...r.kernel.org" <kvm@...r.kernel.org>,
        "linux-kselftest@...r.kernel.org" <linux-kselftest@...r.kernel.org>,
        "mjrosato@...ux.ibm.com" <mjrosato@...ux.ibm.com>,
        "farman@...ux.ibm.com" <farman@...ux.ibm.com>
Subject: RE: [PATCH v5 2/4] iommufd: Add iommufd_access_replace() API

> From: Nicolin Chen <nicolinc@...dia.com>
> Sent: Thursday, March 23, 2023 4:33 PM
> 
> +int iommufd_access_replace(struct iommufd_access *access, u32 ioas_id)
> +{
> +	struct iommufd_ioas *new_ioas;
> +
> +	mutex_lock(&access->ioas_lock);
> +	if (!access->ioas) {
>  		mutex_unlock(&access->ioas_lock);
> -		iommufd_put_object(obj);
> -		return rc;
> +		return -ENOENT;
> +	}
> +	if (access->ioas->obj.id == ioas_id) {
> +		mutex_unlock(&access->ioas_lock);
> +		return 0;
>  	}
> -	iommufd_ref_to_users(obj);
> 
> +	new_ioas = iommufd_access_change_pt(access, ioas_id);
> +	if (IS_ERR(new_ioas)) {
> +		mutex_unlock(&access->ioas_lock);
> +		return PTR_ERR(new_ioas);
> +	}
> +	__iommufd_access_detach(access);
>  	access->ioas = new_ioas;
>  	access->ioas_unpin = new_ioas;

Above three lines can be moved into iommufd_access_change_pt():

	If (access->ioas)
		__iommufd_access_detach(access);
	access->ioas = new_ioas;
	access->ioas_unpin = new_ioas;

Then both attach/replace can end by calling the common function.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ