Linux IOMMU Development
 help / color / mirror / Atom feed
* [PATCH v2] iommu/vt-d: Set SRE bit when hardware has SRS cap
@ 2022-11-15  7:03 Tina Zhang
  2022-11-16  5:19 ` Baolu Lu
  0 siblings, 1 reply; 2+ messages in thread
From: Tina Zhang @ 2022-11-15  7:03 UTC (permalink / raw)
  To: iommu; +Cc: baolu.lu, Tina Zhang

SRS cap is the hardware cap telling if the hardware IOMMU can support
requests seeking supervisor privilege or not. SRE bit in scalable-mode
PASID table entry is treated as Reserved(0) for implementation not
supporting SRS cap.

Checking SRS cap before setting SRE bit can avoid the non-recoverable
fault of "Non-zero reserved field set in PASID Table Entry" caused by
setting SRE bit while there is no SRS cap support.

V2: Add SRS cap checking in intel_pasid_setup_second_level()

Fixes: 6f7db75e1c46 ("iommu/vt-d: Add second level page table interface")
Signed-off-by: Tina Zhang <tina.zhang@intel.com>
---
 drivers/iommu/intel/pasid.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c
index c30ddac40ee5..23dee5db7439 100644
--- a/drivers/iommu/intel/pasid.c
+++ b/drivers/iommu/intel/pasid.c
@@ -642,7 +642,7 @@ int intel_pasid_setup_second_level(struct intel_iommu *iommu,
 	 * Since it is a second level only translation setup, we should
 	 * set SRE bit as well (addresses are expected to be GPAs).
 	 */
-	if (pasid != PASID_RID2PASID)
+	if ((pasid != PASID_RID2PASID) && ecap_srs(iommu->ecap))
 		pasid_set_sre(pte);
 	pasid_set_present(pte);
 	spin_unlock(&iommu->lock);
@@ -685,7 +685,8 @@ int intel_pasid_setup_pass_through(struct intel_iommu *iommu,
 	 * We should set SRE bit as well since the addresses are expected
 	 * to be GPAs.
 	 */
-	pasid_set_sre(pte);
+	if (ecap_srs(iommu->ecap))
+		pasid_set_sre(pte);
 	pasid_set_present(pte);
 	spin_unlock(&iommu->lock);
 
-- 
2.25.1


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

* Re: [PATCH v2] iommu/vt-d: Set SRE bit when hardware has SRS cap
  2022-11-15  7:03 [PATCH v2] iommu/vt-d: Set SRE bit when hardware has SRS cap Tina Zhang
@ 2022-11-16  5:19 ` Baolu Lu
  0 siblings, 0 replies; 2+ messages in thread
From: Baolu Lu @ 2022-11-16  5:19 UTC (permalink / raw)
  To: Tina Zhang, iommu; +Cc: baolu.lu

On 11/15/22 3:03 PM, Tina Zhang wrote:
> SRS cap is the hardware cap telling if the hardware IOMMU can support
> requests seeking supervisor privilege or not. SRE bit in scalable-mode
> PASID table entry is treated as Reserved(0) for implementation not
> supporting SRS cap.
> 
> Checking SRS cap before setting SRE bit can avoid the non-recoverable
> fault of "Non-zero reserved field set in PASID Table Entry" caused by
> setting SRE bit while there is no SRS cap support.
> 
> V2: Add SRS cap checking in intel_pasid_setup_second_level()
> 
> Fixes: 6f7db75e1c46 ("iommu/vt-d: Add second level page table interface")
> Signed-off-by: Tina Zhang<tina.zhang@intel.com>

Patch queued for v6.1. Thank you!

https://lore.kernel.org/linux-iommu/20221116051544.26540-1-baolu.lu@linux.intel.com/

Best regards,
baolu

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

end of thread, other threads:[~2022-11-16  5:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-15  7:03 [PATCH v2] iommu/vt-d: Set SRE bit when hardware has SRS cap Tina Zhang
2022-11-16  5:19 ` Baolu Lu

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