lkml.org 
[lkml]   [2023]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH v2 5/5] iommu/vt-d: Add nested domain support
From

On 3/9/2023 4:22 PM, Yi Liu wrote:
> From: Lu Baolu <baolu.lu@linux.intel.com>
>
> This adds nested domain support in the Intel IOMMU driver. It allows to
> allocate and free a nested domain, set the nested domain to a device,
> and synchronize the caches when the userspace managed page tables are
> updated.
>
> Signed-off-by: Jacob Pan <jacob.jun.pan@linux.intel.com>
> Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> Signed-off-by: Yi Liu <yi.l.liu@intel.com>
> ---
> drivers/iommu/intel/Makefile | 2 +-
> drivers/iommu/intel/iommu.c | 38 ++++++----
> drivers/iommu/intel/iommu.h | 15 ++++
> drivers/iommu/intel/nested.c | 143 +++++++++++++++++++++++++++++++++++
> 4 files changed, 182 insertions(+), 16 deletions(-)
> create mode 100644 drivers/iommu/intel/nested.c
[...]

> +
> +struct iommu_domain *intel_nested_domain_alloc(struct iommu_domain *s2_domain,
> + const void *user_data)
> +{
> + const struct iommu_hwpt_intel_vtd *vtd = user_data;
> + struct dmar_domain *domain;
> +

Would it be better to add the following check ?

if (WARN_ON(!user_data))
return NULL;

> + domain = kzalloc(sizeof(*domain), GFP_KERNEL_ACCOUNT);
> + if (!domain)
> + return NULL;
> +
> + domain->use_first_level = true;
> + domain->s2_domain = to_dmar_domain(s2_domain);
> + domain->s1_pgtbl = vtd->pgtbl_addr;
> + domain->s1_cfg = *vtd;
> + domain->domain.ops = &intel_nested_domain_ops;
> + domain->domain.type = IOMMU_DOMAIN_NESTED;
> + INIT_LIST_HEAD(&domain->devices);
> + spin_lock_init(&domain->lock);
> + xa_init(&domain->iommu_array);
> +
> + return &domain->domain;
> +}

Thanks,

Jingqi


\
 
 \ /
  Last update: 2023-03-27 00:56    [W:0.266 / U:1.088 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site