public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu/vt-d: Enhance capability check for nested parent domain allocation
@ 2023-10-24 15:00 Yi Liu
  2023-10-25  1:10 ` Baolu Lu
  2023-10-25  7:37 ` Tian, Kevin
  0 siblings, 2 replies; 4+ messages in thread
From: Yi Liu @ 2023-10-24 15:00 UTC (permalink / raw)
  To: joro, alex.williamson, jgg, kevin.tian, robin.murphy, baolu.lu
  Cc: cohuck, eric.auger, nicolinc, kvm, mjrosato, chao.p.peng,
	yi.l.liu, yi.y.sun, peterx, jasowang, shameerali.kolothum.thodi,
	lulu, suravee.suthikulpanit, iommu, linux-kernel, linux-kselftest,
	zhenzhong.duan, joao.m.martins

This adds the scalable mode check before allocating the nested parent domain
as checking nested capability is not enough. User may turn off scalable mode
which also means no nested support even if the hardware supports it.

Fixes: c97d1b20d383 ("iommu/vt-d: Add domain_alloc_user op")
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
---
v1: Based on Joao's dirty page tracking v6 https://github.com/jpemartins/linux/commits/iommufd-v6
---
 drivers/iommu/intel/iommu.c | 2 +-
 drivers/iommu/intel/iommu.h | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index eb92a201cc0b..65f46f1347e6 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -4090,7 +4090,7 @@ intel_iommu_domain_alloc_user(struct device *dev, u32 flags)
 	if (!iommu)
 		return ERR_PTR(-ENODEV);
 
-	if ((flags & IOMMU_HWPT_ALLOC_NEST_PARENT) && !ecap_nest(iommu->ecap))
+	if ((flags & IOMMU_HWPT_ALLOC_NEST_PARENT) && !nested_supported(iommu))
 		return ERR_PTR(-EOPNOTSUPP);
 
 	dirty_tracking = (flags & IOMMU_HWPT_ALLOC_DIRTY_TRACKING);
diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h
index 3bb569146229..cc7301579773 100644
--- a/drivers/iommu/intel/iommu.h
+++ b/drivers/iommu/intel/iommu.h
@@ -544,6 +544,8 @@ enum {
 				 ecap_pasid((iommu)->ecap))
 #define ssads_supported(iommu) (sm_supported(iommu) &&                 \
 				ecap_slads((iommu)->ecap))
+#define nested_supported(iommu)	(sm_supported(iommu) &&			\
+				 ecap_nest((iommu)->ecap))
 
 struct pasid_entry;
 struct pasid_state_entry;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] iommu/vt-d: Enhance capability check for nested parent domain allocation
  2023-10-24 15:00 [PATCH] iommu/vt-d: Enhance capability check for nested parent domain allocation Yi Liu
@ 2023-10-25  1:10 ` Baolu Lu
  2023-10-25 11:33   ` Jason Gunthorpe
  2023-10-25  7:37 ` Tian, Kevin
  1 sibling, 1 reply; 4+ messages in thread
From: Baolu Lu @ 2023-10-25  1:10 UTC (permalink / raw)
  To: Yi Liu, joro, alex.williamson, jgg, kevin.tian, robin.murphy
  Cc: baolu.lu, cohuck, eric.auger, nicolinc, kvm, mjrosato,
	chao.p.peng, yi.y.sun, peterx, jasowang,
	shameerali.kolothum.thodi, lulu, suravee.suthikulpanit, iommu,
	linux-kernel, linux-kselftest, zhenzhong.duan, joao.m.martins

On 10/24/23 11:00 PM, Yi Liu wrote:
> This adds the scalable mode check before allocating the nested parent domain
> as checking nested capability is not enough. User may turn off scalable mode
> which also means no nested support even if the hardware supports it.
> 
> Fixes: c97d1b20d383 ("iommu/vt-d: Add domain_alloc_user op")
> Signed-off-by: Yi Liu <yi.l.liu@intel.com>
> ---
> v1: Based on Joao's dirty page tracking v6 https://github.com/jpemartins/linux/commits/iommufd-v6
> ---
>   drivers/iommu/intel/iommu.c | 2 +-
>   drivers/iommu/intel/iommu.h | 2 ++
>   2 files changed, 3 insertions(+), 1 deletion(-)

Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>

Hi Jason,

Given that this fixes a commit in the iommufd tree, can you please pick
this fix as well?

Best regards,
baolu

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH] iommu/vt-d: Enhance capability check for nested parent domain allocation
  2023-10-24 15:00 [PATCH] iommu/vt-d: Enhance capability check for nested parent domain allocation Yi Liu
  2023-10-25  1:10 ` Baolu Lu
@ 2023-10-25  7:37 ` Tian, Kevin
  1 sibling, 0 replies; 4+ messages in thread
From: Tian, Kevin @ 2023-10-25  7:37 UTC (permalink / raw)
  To: Liu, Yi L, joro@8bytes.org, alex.williamson@redhat.com,
	jgg@nvidia.com, robin.murphy@arm.com, baolu.lu@linux.intel.com
  Cc: cohuck@redhat.com, eric.auger@redhat.com, nicolinc@nvidia.com,
	kvm@vger.kernel.org, mjrosato@linux.ibm.com,
	chao.p.peng@linux.intel.com, yi.y.sun@linux.intel.com,
	peterx@redhat.com, jasowang@redhat.com,
	shameerali.kolothum.thodi@huawei.com, lulu@redhat.com,
	suravee.suthikulpanit@amd.com, iommu@lists.linux.dev,
	linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
	Duan, Zhenzhong, Martins, Joao

> From: Liu, Yi L <yi.l.liu@intel.com>
> Sent: Tuesday, October 24, 2023 11:00 PM
> 
> This adds the scalable mode check before allocating the nested parent
> domain
> as checking nested capability is not enough. User may turn off scalable mode
> which also means no nested support even if the hardware supports it.
> 
> Fixes: c97d1b20d383 ("iommu/vt-d: Add domain_alloc_user op")
> Signed-off-by: Yi Liu <yi.l.liu@intel.com>

Reviewed-by: Kevin Tian <kevin.tian@intel.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] iommu/vt-d: Enhance capability check for nested parent domain allocation
  2023-10-25  1:10 ` Baolu Lu
@ 2023-10-25 11:33   ` Jason Gunthorpe
  0 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2023-10-25 11:33 UTC (permalink / raw)
  To: Baolu Lu
  Cc: Yi Liu, joro, alex.williamson, kevin.tian, robin.murphy, cohuck,
	eric.auger, nicolinc, kvm, mjrosato, chao.p.peng, yi.y.sun,
	peterx, jasowang, shameerali.kolothum.thodi, lulu,
	suravee.suthikulpanit, iommu, linux-kernel, linux-kselftest,
	zhenzhong.duan, joao.m.martins

On Wed, Oct 25, 2023 at 09:10:08AM +0800, Baolu Lu wrote:
> On 10/24/23 11:00 PM, Yi Liu wrote:
> > This adds the scalable mode check before allocating the nested parent domain
> > as checking nested capability is not enough. User may turn off scalable mode
> > which also means no nested support even if the hardware supports it.
> > 
> > Fixes: c97d1b20d383 ("iommu/vt-d: Add domain_alloc_user op")
> > Signed-off-by: Yi Liu <yi.l.liu@intel.com>
> > ---
> > v1: Based on Joao's dirty page tracking v6 https://github.com/jpemartins/linux/commits/iommufd-v6
> > ---
> >   drivers/iommu/intel/iommu.c | 2 +-
> >   drivers/iommu/intel/iommu.h | 2 ++
> >   2 files changed, 3 insertions(+), 1 deletion(-)
> 
> Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
> 
> Hi Jason,
> 
> Given that this fixes a commit in the iommufd tree, can you please pick
> this fix as well?

Done

Thanks
Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-10-25 11:34 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-10-24 15:00 [PATCH] iommu/vt-d: Enhance capability check for nested parent domain allocation Yi Liu
2023-10-25  1:10 ` Baolu Lu
2023-10-25 11:33   ` Jason Gunthorpe
2023-10-25  7:37 ` Tian, Kevin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox