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: <e8f0980c-8431-593c-f9ef-f8f6104e60ec@linux.intel.com>
Date:   Fri, 20 Mar 2020 17:06:33 +0800
From:   Lu Baolu <baolu.lu@...ux.intel.com>
To:     Joerg Roedel <joro@...tes.org>
Cc:     baolu.lu@...ux.intel.com, ashok.raj@...el.com,
        jacob.jun.pan@...ux.intel.com, kevin.tian@...el.com,
        Sai Praneeth Prakhya <sai.praneeth.prakhya@...el.com>,
        iommu@...ts.linux-foundation.org, linux-kernel@...r.kernel.org,
        Daniel Drake <drake@...lessm.com>,
        Derrick Jonathan <jonathan.derrick@...el.com>,
        Jerry Snitselaar <jsnitsel@...hat.com>,
        Robin Murphy <robin.murphy@....com>,
        Christoph Hellwig <hch@....de>
Subject: Re: [PATCH v2 2/6] iommu: Configure default domain with
 def_domain_type

Hi Joerg,

On 2020/3/19 22:03, Joerg Roedel wrote:
> Hi Baolu,
> 
> On Sat, Mar 14, 2020 at 09:07:01AM +0800, Lu Baolu wrote:
>> +static int iommu_group_change_def_domain(struct iommu_group *group, int type)
>> +{
>> +	struct group_device *grp_dev, *temp;
>> +	struct iommu_domain *new, *old;
>> +	const struct iommu_ops *ops;
>> +	int ret = 0;
>> +
>> +	if ((type != IOMMU_DOMAIN_IDENTITY && type != IOMMU_DOMAIN_DMA) ||
>> +	    !group->default_domain || type == group->default_domain->type ||
>> +	    !group->default_domain->ops)
>> +		return -EINVAL;
>> +
>> +	if (group->domain != group->default_domain)
>> +		return -EBUSY;
>> +
>> +	iommu_group_ref_get(group);
>> +	old = group->default_domain;
>> +	ops = group->default_domain->ops;
>> +
>> +	/* Allocate a new domain of requested type. */
>> +	new = ops->domain_alloc(type);
>> +	if (!new) {
>> +		ret = -ENOMEM;
>> +		goto domain_out;
>> +	}
>> +	new->type = type;
>> +	new->ops = ops;
>> +	new->pgsize_bitmap = group->default_domain->pgsize_bitmap;
>> +
>> +	group->default_domain = new;
>> +	group->domain = new;
>> +	list_for_each_entry_safe(grp_dev, temp, &group->devices, list) {
>> +		struct device *dev;
>> +
>> +		dev = grp_dev->dev;
>> +		if (device_is_bound(dev)) {
>> +			ret = -EINVAL;
>> +			goto device_out;
>> +		}
>> +
>> +		iommu_group_create_direct_mappings(group, dev);
>> +		ret = __iommu_attach_device(group->domain, dev);
>> +		if (ret)
>> +			goto device_out;
> 
> In case of a failure here with a group containing multiple devices, the
> other devices temporarily lose their mappings. Please only do the
> device_is_bound() check in the loop and the actual re-attachment of the
> group with a call to __iommu_attach_group().

Sure. I've post a v3 of this patch according to your comments here.
Please help to review.

Best regards,
baolu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ