lkml.org 
[lkml]   [2022]   [Sep]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH v3 5/6] iommu: Use EINVAL for incompatible device/domain in ->attach_dev
Date
> From: Nicolin Chen <nicolinc@nvidia.com>
> Sent: Thursday, September 15, 2022 3:54 PM
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index 1f2cd43cf9bc..51ef42b1bd4e 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -4158,19 +4158,15 @@ static int prepare_domain_attach_device(struct
> iommu_domain *domain,
> return -ENODEV;
>
> if (dmar_domain->force_snooping && !ecap_sc_support(iommu-
> >ecap))
> - return -EOPNOTSUPP;
> + return -EINVAL;
>
> /* check if this iommu agaw is sufficient for max mapped address */
> addr_width = agaw_to_width(iommu->agaw);
> if (addr_width > cap_mgaw(iommu->cap))
> addr_width = cap_mgaw(iommu->cap);
>
> - if (dmar_domain->max_addr > (1LL << addr_width)) {
> - dev_err(dev, "%s: iommu width (%d) is not "
> - "sufficient for the mapped address (%llx)\n",
> - __func__, addr_width, dmar_domain->max_addr);
> - return -EFAULT;
> - }
> + if (dmar_domain->max_addr > (1LL << addr_width))
> + return -EINVAL;
> dmar_domain->gaw = addr_width;
>
> /*

Above lacks of a conversion in intel-iommu:

intel_iommu_attach_device()
if (domain->type == IOMMU_DOMAIN_UNMANAGED &&
device_is_rmrr_locked(dev)) {
dev_warn(dev, "Device is ineligible for IOMMU domain attach due to platform RMRR requirement. Contact your platform vendor.\n");
return -EPERM;
}

since it's based on the domain type, picking a different domain
may work in theory though it won't apply to vfio which always
creates unmanaged type.

\
 
 \ /
  Last update: 2022-09-20 08:40    [W:0.322 / U:0.076 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site