[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <c6e7e0b6-454b-c4c9-e21b-dab68db00b21@intel.com>
Date: Mon, 13 Mar 2023 21:51:27 +0800
From: "Liu, Jingqi" <jingqi.liu@...el.com>
To: Yi Liu <yi.l.liu@...el.com>, <joro@...tes.org>,
<alex.williamson@...hat.com>, <jgg@...dia.com>,
<kevin.tian@...el.com>, <robin.murphy@....com>,
<baolu.lu@...ux.intel.com>
CC: <cohuck@...hat.com>, <eric.auger@...hat.com>,
<nicolinc@...dia.com>, <kvm@...r.kernel.org>,
<mjrosato@...ux.ibm.com>, <chao.p.peng@...ux.intel.com>,
<yi.y.sun@...ux.intel.com>, <peterx@...hat.com>,
<jasowang@...hat.com>, <shameerali.kolothum.thodi@...wei.com>,
<lulu@...hat.com>, <suravee.suthikulpanit@....com>,
<iommu@...ts.linux.dev>, <linux-kernel@...r.kernel.org>,
<linux-kselftest@...r.kernel.org>,
Jacob Pan <jacob.jun.pan@...ux.intel.com>
Subject: Re: [PATCH v2 5/5] iommu/vt-d: Add nested domain support
On 3/9/2023 4:22 PM, Yi Liu wrote:
> From: Lu Baolu <baolu.lu@...ux.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@...ux.intel.com>
> Signed-off-by: Lu Baolu <baolu.lu@...ux.intel.com>
> Signed-off-by: Nicolin Chen <nicolinc@...dia.com>
> Signed-off-by: Yi Liu <yi.l.liu@...el.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
Powered by blists - more mailing lists