Re: [PATCH V9 10/10] iommu/vt-d: Report PASID format as domain attribute

Lu Baolu
2020-01-30T07:55:07Z

Hi,

On 2020/1/29 14:01, Jacob Pan wrote:
> Report the domain attribute of PASID table format. As multiple formats
> of PASID table entry are supported, it is important for the guest to
> know which format to use in virtual IOMMU. The result will be used for
> binding device with guest PASID.
>
> Signed-off-by: Liu Yi L <yi.l.liu@intel.com>
> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
> ---
> drivers/iommu/intel-iommu.c | 22 ++++++++++++++++++++++
> include/linux/iommu.h | 1 +
> 2 files changed, 23 insertions(+)
>
> diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c
> index 2f0bf7cc70ce..b3778e86dc32 100644
> --- a/drivers/iommu/intel-iommu.c
> +++ b/drivers/iommu/intel-iommu.c
> @@ -6413,6 +6413,27 @@ intel_iommu_domain_set_attr(struct iommu_domain *domain,
> return ret;
> }
>
> +static int intel_iommu_domain_get_attr(struct iommu_domain *domain,
> + enum iommu_attr attr, void *data)
> +{
> + /* Only used for guest */
> + switch (domain->type) {
> + case IOMMU_DOMAIN_DMA:
> + return -ENODEV;
> + case IOMMU_DOMAIN_UNMANAGED:
> + switch (attr) {
> + case DOMAIN_ATTR_PASID_FORMAT:
> + *(int *)data = IOMMU_PASID_FORMAT_INTEL_VTD;
> + return 0;
> + default:
> + return -ENODEV;
> + }
> + break;
> + default:
> + return -EINVAL;
> + }
> +}
> +
> const struct iommu_ops intel_iommu_ops = {
> .capable = intel_iommu_capable,
> .domain_alloc = intel_iommu_domain_alloc,
> @@ -6432,6 +6453,7 @@ const struct iommu_ops intel_iommu_ops = {
> .put_resv_regions = intel_iommu_put_resv_regions,
> .apply_resv_region = intel_iommu_apply_resv_region,
> .device_group = pci_device_group,
> + .domain_get_attr = intel_iommu_domain_get_attr,
> .dev_has_feat = intel_iommu_dev_has_feat,
> .dev_feat_enabled = intel_iommu_dev_feat_enabled,
> .dev_enable_feat = intel_iommu_dev_enable_feat,
> diff --git a/include/linux/iommu.h b/include/linux/iommu.h
> index f2223cbb5fd5..9718c109ea0a 100644
> --- a/include/linux/iommu.h
> +++ b/include/linux/iommu.h
> @@ -126,6 +126,7 @@ enum iommu_attr {
> DOMAIN_ATTR_FSL_PAMUV1,
> DOMAIN_ATTR_NESTING, /* two stages of translation */
> DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE,
> + DOMAIN_ATTR_PASID_FORMAT,
> DOMAIN_ATTR_MAX,
> };

Need to separate the new domain attribution definition and the vt-d
implementation.

Best regards,
baolu