On Wed, Sep 20, 2023 at 01:41:07PM +0800, Yang, Weijiang wrote:
On 9/19/2023 5:25 PM, Yi Liu wrote:
This adds the domain_alloc_user op implementation. It supports allocating domains to be used as parent under nested translation.
Signed-off-by: Yi Liu yi.l.liu@intel.com
drivers/iommu/intel/iommu.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c index 5db283c17e0d..491bcde1ff96 100644 --- a/drivers/iommu/intel/iommu.c +++ b/drivers/iommu/intel/iommu.c @@ -4074,6 +4074,25 @@ static struct iommu_domain *intel_iommu_domain_alloc(unsigned type) return NULL; } +static struct iommu_domain * +intel_iommu_domain_alloc_user(struct device *dev, u32 flags) +{
- struct iommu_domain *domain;
- struct intel_iommu *iommu;
- iommu = device_to_iommu(dev, NULL, NULL);
- if (!iommu)
return ERR_PTR(-ENODEV);
- if ((flags & IOMMU_HWPT_ALLOC_NEST_PARENT) && !ecap_nest(iommu->ecap))
return ERR_PTR(-EOPNOTSUPP);
The outer caller has checked (flags & IOMMU_HWPT_ALLOC_NEST_PARENT) before it comes here. If this callback is dedicated for nested domain allocation, then you may omit the condition here.
No, please don't.
The point of the flags is to be passed to the driver. The driver should validate them, not the core code.
We will add more flags, I don't want to change every driver to do this.
Jason