kvmarm.lists.cs.columbia.edu archive mirror
 help / color / mirror / Atom feed
From: Zenghui Yu <yuzenghui@huawei.com>
To: Eric Auger <eric.auger@redhat.com>, <eric.auger.pro@gmail.com>,
	<iommu@lists.linux-foundation.org>,
	<linux-kernel@vger.kernel.org>, <kvm@vger.kernel.org>,
	<kvmarm@lists.cs.columbia.edu>, <joro@8bytes.org>,
	<alex.williamson@redhat.com>, <jacob.jun.pan@linux.intel.com>,
	<yi.l.liu@intel.com>, <robin.murphy@arm.com>
Subject: Re: [PATCH v10 01/11] vfio: VFIO_IOMMU_SET_PASID_TABLE
Date: Wed, 23 Sep 2020 19:27:46 +0800	[thread overview]
Message-ID: <2fba23af-9cd7-147d-6202-01c13fff92e5@huawei.com> (raw)
In-Reply-To: <20200320161911.27494-2-eric.auger@redhat.com>

Hi Eric,

On 2020/3/21 0:19, Eric Auger wrote:
> From: "Liu, Yi L" <yi.l.liu@linux.intel.com>
> 
> This patch adds an VFIO_IOMMU_SET_PASID_TABLE ioctl
> which aims to pass the virtual iommu guest configuration
> to the host. This latter takes the form of the so-called
> PASID table.
> 
> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
> Signed-off-by: Liu, Yi L <yi.l.liu@linux.intel.com>
> Signed-off-by: Eric Auger <eric.auger@redhat.com>

[...]

> diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
> index a177bf2c6683..bfacbd876ee1 100644
> --- a/drivers/vfio/vfio_iommu_type1.c
> +++ b/drivers/vfio/vfio_iommu_type1.c
> @@ -2172,6 +2172,43 @@ static int vfio_iommu_iova_build_caps(struct vfio_iommu *iommu,
>   	return ret;
>   }
>   
> +static void
> +vfio_detach_pasid_table(struct vfio_iommu *iommu)
> +{
> +	struct vfio_domain *d;
> +
> +	mutex_lock(&iommu->lock);
> +
> +	list_for_each_entry(d, &iommu->domain_list, next) {
> +		iommu_detach_pasid_table(d->domain);
> +	}
> +	mutex_unlock(&iommu->lock);
> +}
> +
> +static int
> +vfio_attach_pasid_table(struct vfio_iommu *iommu,
> +			struct vfio_iommu_type1_set_pasid_table *ustruct)
> +{
> +	struct vfio_domain *d;
> +	int ret = 0;
> +
> +	mutex_lock(&iommu->lock);
> +
> +	list_for_each_entry(d, &iommu->domain_list, next) {
> +		ret = iommu_attach_pasid_table(d->domain, &ustruct->config);
> +		if (ret)
> +			goto unwind;
> +	}
> +	goto unlock;
> +unwind:
> +	list_for_each_entry_continue_reverse(d, &iommu->domain_list, next) {
> +		iommu_detach_pasid_table(d->domain);
> +	}
> +unlock:
> +	mutex_unlock(&iommu->lock);
> +	return ret;
> +}
> +
>   static long vfio_iommu_type1_ioctl(void *iommu_data,
>   				   unsigned int cmd, unsigned long arg)
>   {
> @@ -2276,6 +2313,25 @@ static long vfio_iommu_type1_ioctl(void *iommu_data,
>   
>   		return copy_to_user((void __user *)arg, &unmap, minsz) ?
>   			-EFAULT : 0;
> +	} else if (cmd == VFIO_IOMMU_SET_PASID_TABLE) {
> +		struct vfio_iommu_type1_set_pasid_table ustruct;
> +
> +		minsz = offsetofend(struct vfio_iommu_type1_set_pasid_table,
> +				    config);
> +
> +		if (copy_from_user(&ustruct, (void __user *)arg, minsz))
> +			return -EFAULT;
> +
> +		if (ustruct.argsz < minsz)
> +			return -EINVAL;
> +
> +		if (ustruct.flags & VFIO_PASID_TABLE_FLAG_SET)
> +			return vfio_attach_pasid_table(iommu, &ustruct);
> +		else if (ustruct.flags & VFIO_PASID_TABLE_FLAG_UNSET) {
> +			vfio_detach_pasid_table(iommu);
> +			return 0;
> +		} else
> +			return -EINVAL;

Nit:

What if user-space blindly set both flags? Should we check that only one
flag is allowed to be set at this stage, and return error otherwise?

Besides, before going through the whole series [1][2], I'd like to know
if this is the latest version of your Nested-Stage-Setup work in case I
had missed something.

[1] https://lore.kernel.org/r/20200320161911.27494-1-eric.auger@redhat.com
[2] https://lore.kernel.org/r/20200414150607.28488-1-eric.auger@redhat.com


Thanks,
Zenghui
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm

  parent reply	other threads:[~2020-09-23 11:28 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-20 16:19 [PATCH v10 00/11] SMMUv3 Nested Stage Setup (VFIO part) Eric Auger
2020-03-20 16:19 ` [PATCH v10 01/11] vfio: VFIO_IOMMU_SET_PASID_TABLE Eric Auger
2020-03-21  5:18   ` kbuild test robot
2020-09-23 11:27   ` Zenghui Yu [this message]
2020-09-23 11:47     ` Auger Eric
2020-10-27 12:20       ` Shameerali Kolothum Thodi
2020-10-27 13:04         ` Auger Eric
2020-03-20 16:19 ` [PATCH v10 02/11] vfio: VFIO_IOMMU_CACHE_INVALIDATE Eric Auger
2020-03-20 16:19 ` [PATCH v10 03/11] vfio: VFIO_IOMMU_SET_MSI_BINDING Eric Auger
2020-03-20 16:19 ` [PATCH v10 04/11] vfio/pci: Add VFIO_REGION_TYPE_NESTED region type Eric Auger
2020-04-01 13:18   ` Liu, Yi L
2020-04-01 13:31     ` Auger Eric
2020-04-06  6:29       ` Liu, Yi L
2020-09-24  8:23   ` Zenghui Yu
2020-11-13 16:12     ` Auger Eric
2020-03-20 16:19 ` [PATCH v10 05/11] vfio/pci: Register an iommu fault handler Eric Auger
2020-09-24  8:49   ` Zenghui Yu
2020-11-13 16:11     ` Auger Eric
2020-03-20 16:19 ` [PATCH v10 06/11] vfio/pci: Allow to mmap the fault queue Eric Auger
2020-03-20 16:19 ` [PATCH v10 07/11] vfio: Use capability chains to handle device specific irq Eric Auger
2020-03-20 16:19 ` [PATCH v10 08/11] vfio: Add new IRQ for DMA fault reporting Eric Auger
2020-03-20 16:19 ` [PATCH v10 09/11] vfio/pci: Add framework for custom interrupt indices Eric Auger
2020-03-20 16:19 ` [PATCH v10 10/11] vfio/pci: Register and allow DMA FAULT IRQ signaling Eric Auger
2020-03-20 16:19 ` [PATCH v10 11/11] vfio: Document nested stage control Eric Auger
2020-09-24 13:42   ` Zenghui Yu
2020-10-06 15:29     ` Auger Eric

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2fba23af-9cd7-147d-6202-01c13fff92e5@huawei.com \
    --to=yuzenghui@huawei.com \
    --cc=alex.williamson@redhat.com \
    --cc=eric.auger.pro@gmail.com \
    --cc=eric.auger@redhat.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jacob.jun.pan@linux.intel.com \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=kvmarm@lists.cs.columbia.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=yi.l.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).