All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Tian, Kevin" <kevin.tian@intel.com>
To: Lu Baolu <baolu.lu@linux.intel.com>,
	"Pan, Jacob jun" <jacob.jun.pan@intel.com>,
	"Raj, Ashok" <ashok.raj@intel.com>,
	"Liu, Yi L" <yi.l.liu@intel.com>
Cc: "iommu@lists.linux-foundation.org"
	<iommu@lists.linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v2 1/4] iommu/vt-d: Check before setting PGSNP bit in pasid table entry
Date: Sun, 24 Apr 2022 03:37:48 +0000	[thread overview]
Message-ID: <BN9PR11MB52766E90CF544C2B00F364008CF99@BN9PR11MB5276.namprd11.prod.outlook.com> (raw)
In-Reply-To: <503795b0-282c-2a8a-b669-5e7a0fc4a696@linux.intel.com>

> From: Lu Baolu <baolu.lu@linux.intel.com>
> Sent: Friday, April 22, 2022 9:04 PM
> 
> On 2022/4/22 10:47, Tian, Kevin wrote:
> >> From: Lu Baolu
> >> Sent: Thursday, April 21, 2022 7:36 PM
> >>
> >> The latest VT-d specification states that the PGSNP field in the pasid
> >> table entry should be treated as Reserved(0) for implementations not
> >> supporting Snoop Control (SC=0 in the Extended Capability Register).
> >> This adds a check before setting the field.
> >>
> >> Signed-off-by: Lu Baolu<baolu.lu@linux.intel.com>
> >> ---
> >>   drivers/iommu/intel/pasid.c | 13 ++++++++++---
> >>   1 file changed, 10 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c
> >> index f8d215d85695..5cb2daa2b8cb 100644
> >> --- a/drivers/iommu/intel/pasid.c
> >> +++ b/drivers/iommu/intel/pasid.c
> >> @@ -625,8 +625,14 @@ int intel_pasid_setup_first_level(struct
> intel_iommu
> >> *iommu,
> >>   		}
> >>   	}
> >>
> >> -	if (flags & PASID_FLAG_PAGE_SNOOP)
> >> -		pasid_set_pgsnp(pte);
> >> +	if (flags & PASID_FLAG_PAGE_SNOOP) {
> >> +		if (ecap_sc_support(iommu->ecap)) {
> >> +			pasid_set_pgsnp(pte);
> >> +		} else {
> >> +			pasid_clear_entry(pte);
> >> +			return -EINVAL;
> >> +		}
> >> +	}
> >>
> >>   	pasid_set_domain_id(pte, did);
> >>   	pasid_set_address_width(pte, iommu->agaw);
> >> @@ -710,7 +716,8 @@ int intel_pasid_setup_second_level(struct
> >> intel_iommu *iommu,
> >>   	pasid_set_fault_enable(pte);
> >>   	pasid_set_page_snoop(pte, !!ecap_smpwc(iommu->ecap));
> >>
> >> -	if (domain->domain.type == IOMMU_DOMAIN_UNMANAGED)
> >> +	if (ecap_sc_support(iommu->ecap) &&
> >> +	    domain->domain.type == IOMMU_DOMAIN_UNMANAGED)
> >>   		pasid_set_pgsnp(pte);
> >>
> > This should be rebased on top of Jason's enforce coherency series
> > instead of blindly setting it. No matter whether it's legacy mode
> > where we set SNP in PTE or scalable mode where we set PGSNP
> > in PASID entry for entire page table, the trigger point should be
> > same i.e. when someone calls enforce_cache_coherency().
> 
> With Jason's enforce coherency series merged, we even don't need to set
> PGSNP bit of a pasid entry for second level translation. 2nd level
> always supports SNP in PTEs, so set PGSNP in pasid table entry is
> unnecessary.
> 

Yes, this sounds correct for 2nd-level.

but setting PGSNP of 1st level translation is also relevant to that
change when talking about enforcing coherency in the guest. In
this case PASID_FLAG_PAGE_SNOOP should be set also after
enforce_cache_coherency() is called.

Currently it's always set for unmanaged domain in
domain_setup_first_level():

	if (domain->domain.type == IOMMU_DOMAIN_UNMANAGED)
		flags |= PASID_FLAG_PAGE_SNOOP;

Suppose we need a separate interface to update PGSNP after pasid
entry is set up.

Thanks
Kevin

WARNING: multiple messages have this Message-ID (diff)
From: "Tian, Kevin" <kevin.tian@intel.com>
To: Lu Baolu <baolu.lu@linux.intel.com>,
	"Pan, Jacob jun" <jacob.jun.pan@intel.com>,
	"Raj, Ashok" <ashok.raj@intel.com>,
	"Liu, Yi L" <yi.l.liu@intel.com>
Cc: "iommu@lists.linux-foundation.org"
	<iommu@lists.linux-foundation.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: [PATCH v2 1/4] iommu/vt-d: Check before setting PGSNP bit in pasid table entry
Date: Sun, 24 Apr 2022 03:37:48 +0000	[thread overview]
Message-ID: <BN9PR11MB52766E90CF544C2B00F364008CF99@BN9PR11MB5276.namprd11.prod.outlook.com> (raw)
In-Reply-To: <503795b0-282c-2a8a-b669-5e7a0fc4a696@linux.intel.com>

> From: Lu Baolu <baolu.lu@linux.intel.com>
> Sent: Friday, April 22, 2022 9:04 PM
> 
> On 2022/4/22 10:47, Tian, Kevin wrote:
> >> From: Lu Baolu
> >> Sent: Thursday, April 21, 2022 7:36 PM
> >>
> >> The latest VT-d specification states that the PGSNP field in the pasid
> >> table entry should be treated as Reserved(0) for implementations not
> >> supporting Snoop Control (SC=0 in the Extended Capability Register).
> >> This adds a check before setting the field.
> >>
> >> Signed-off-by: Lu Baolu<baolu.lu@linux.intel.com>
> >> ---
> >>   drivers/iommu/intel/pasid.c | 13 ++++++++++---
> >>   1 file changed, 10 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c
> >> index f8d215d85695..5cb2daa2b8cb 100644
> >> --- a/drivers/iommu/intel/pasid.c
> >> +++ b/drivers/iommu/intel/pasid.c
> >> @@ -625,8 +625,14 @@ int intel_pasid_setup_first_level(struct
> intel_iommu
> >> *iommu,
> >>   		}
> >>   	}
> >>
> >> -	if (flags & PASID_FLAG_PAGE_SNOOP)
> >> -		pasid_set_pgsnp(pte);
> >> +	if (flags & PASID_FLAG_PAGE_SNOOP) {
> >> +		if (ecap_sc_support(iommu->ecap)) {
> >> +			pasid_set_pgsnp(pte);
> >> +		} else {
> >> +			pasid_clear_entry(pte);
> >> +			return -EINVAL;
> >> +		}
> >> +	}
> >>
> >>   	pasid_set_domain_id(pte, did);
> >>   	pasid_set_address_width(pte, iommu->agaw);
> >> @@ -710,7 +716,8 @@ int intel_pasid_setup_second_level(struct
> >> intel_iommu *iommu,
> >>   	pasid_set_fault_enable(pte);
> >>   	pasid_set_page_snoop(pte, !!ecap_smpwc(iommu->ecap));
> >>
> >> -	if (domain->domain.type == IOMMU_DOMAIN_UNMANAGED)
> >> +	if (ecap_sc_support(iommu->ecap) &&
> >> +	    domain->domain.type == IOMMU_DOMAIN_UNMANAGED)
> >>   		pasid_set_pgsnp(pte);
> >>
> > This should be rebased on top of Jason's enforce coherency series
> > instead of blindly setting it. No matter whether it's legacy mode
> > where we set SNP in PTE or scalable mode where we set PGSNP
> > in PASID entry for entire page table, the trigger point should be
> > same i.e. when someone calls enforce_cache_coherency().
> 
> With Jason's enforce coherency series merged, we even don't need to set
> PGSNP bit of a pasid entry for second level translation. 2nd level
> always supports SNP in PTEs, so set PGSNP in pasid table entry is
> unnecessary.
> 

Yes, this sounds correct for 2nd-level.

but setting PGSNP of 1st level translation is also relevant to that
change when talking about enforcing coherency in the guest. In
this case PASID_FLAG_PAGE_SNOOP should be set also after
enforce_cache_coherency() is called.

Currently it's always set for unmanaged domain in
domain_setup_first_level():

	if (domain->domain.type == IOMMU_DOMAIN_UNMANAGED)
		flags |= PASID_FLAG_PAGE_SNOOP;

Suppose we need a separate interface to update PGSNP after pasid
entry is set up.

Thanks
Kevin
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

  reply	other threads:[~2022-04-24  3:38 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-21 11:35 [PATCH v2 0/4] iommu/vt-d: Some fine tuning of SVA Lu Baolu
2022-04-21 11:35 ` Lu Baolu
2022-04-21 11:35 ` [PATCH v2 1/4] iommu/vt-d: Check before setting PGSNP bit in pasid table entry Lu Baolu
2022-04-21 11:35   ` Lu Baolu
2022-04-22  2:47   ` Tian, Kevin
2022-04-22  2:47     ` Tian, Kevin
2022-04-22 13:04     ` Lu Baolu
2022-04-22 13:04       ` Lu Baolu
2022-04-24  3:37       ` Tian, Kevin [this message]
2022-04-24  3:37         ` Tian, Kevin
2022-04-24  4:37         ` Lu Baolu
2022-04-24  4:37           ` Lu Baolu
2022-04-24  5:55           ` Tian, Kevin
2022-04-24  5:55             ` Tian, Kevin
2022-04-24  6:23             ` Lu Baolu
2022-04-24  6:23               ` Lu Baolu
2022-04-21 11:35 ` [PATCH v2 2/4] iommu/vt-d: Set PGSNP bit in pasid table entry for SVA binding Lu Baolu
2022-04-21 11:35   ` Lu Baolu
2022-04-22  3:05   ` Tian, Kevin
2022-04-22  3:05     ` Tian, Kevin
2022-04-22 13:13     ` Lu Baolu
2022-04-22 13:13       ` Lu Baolu
2022-04-21 11:35 ` [PATCH v2 3/4] iommu/vt-d: Drop stop marker messages Lu Baolu
2022-04-21 11:35   ` Lu Baolu
2022-04-22  3:05   ` Tian, Kevin
2022-04-22  3:05     ` Tian, Kevin
2022-04-23  7:32     ` Lu Baolu
2022-04-23  7:32       ` Lu Baolu
2022-04-21 11:35 ` [PATCH v2 4/4] iommu/vt-d: Size Page Request Queue to avoid overflow condition Lu Baolu
2022-04-21 11:35   ` Lu Baolu
2022-04-22  3:07   ` Tian, Kevin
2022-04-22  3:07     ` Tian, Kevin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BN9PR11MB52766E90CF544C2B00F364008CF99@BN9PR11MB5276.namprd11.prod.outlook.com \
    --to=kevin.tian@intel.com \
    --cc=ashok.raj@intel.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=jacob.jun.pan@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yi.l.liu@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.