Skip to contentSkip to conversation

x86/vtd: fix iommu_share_p2m_table

PATCH In review Roger Pau Monne 3 participants 3 messages Oct 8, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/vtd: fix iommu_share_p2m_table

Commit 2916951c1 "mm / iommu: include need_iommu() test in iommu_use_hap_pt()" changed the check in iommu_share_p2m_table to use need_iommu(d) (as part of iommu_use_hap_pt) instead of iommu_enabled, which broke the check because at the point in domain construction where iommu_share_p2m_table is called need_iommu(d) will always return false.

Fix this by reverting to the previous logic.

While there turn the hap_enabled check into an ASSERT, since the only caller of iommu_share_p2m_table already performs the hap_enabled check before calling the function.

---
Cc: Jan Beulich <[email protected]>
Cc: Paul Durrant <[email protected]>
---
Changes since v1:
- Add a comment about why iommu_use_hap_pt cannot be used in iommu_share_p2m_table.
- Expand commit message.
- Convert the hap_enabled check into an ASSERT.

---
 xen/drivers/passthrough/iommu.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
xen/drivers/passthrough/iommu.c +7 -1
index debb5e6fe1..75bc410c2c 100644
@@ -505,7 +505,13 @@ int iommu_do_domctl(
 
 void iommu_share_p2m_table(struct domain* d)
 {
-    if ( iommu_use_hap_pt(d) )
+    ASSERT(hap_enabled(d));
+    /*
+     * iommu_use_hap_pt cannot be used here because at the point in the domain
+     * construction where iommu_share_p2m_table get called need_iommu(d) will
+     * always return false.
+     */
+    if ( iommu_enabled && iommu_hap_pt_share )
         iommu_get_ops()->share_p2m(d);
 }
 
Signature · 7 lines
2.19.0


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Reviewed-by on v2 1/1
#1 lore raw
Quoted 15 lines

-----Original Message-----
From: Roger Pau Monne [mailto:[email protected]]
Sent: 08 October 2018 14:53
To: [email protected]
Cc: Roger Pau Monne <[email protected]>; Jan Beulich <[email protected]>; Paul Durrant <[email protected]>
Subject: [PATCH v2] x86/vtd: fix iommu_share_p2m_table

Commit 2916951c1 "mm / iommu: include need_iommu() test in iommu_use_hap_pt()" changed the check in iommu_share_p2m_table to use need_iommu(d) (as part of iommu_use_hap_pt) instead of iommu_enabled, which broke the check because at the point in domain construction where iommu_share_p2m_table is called need_iommu(d) will always return false.

Quoted 7 lines

Fix this by reverting to the previous logic.

While there turn the hap_enabled check into an ASSERT, since the only caller of iommu_share_p2m_table already performs the hap_enabled check before calling the function.

Quoted 36 lines

---
Cc: Jan Beulich <[email protected]>
Cc: Paul Durrant <[email protected]>
---
Changes since v1:
- Add a comment about why iommu_use_hap_pt cannot be used in iommu_share_p2m_table.
- Expand commit message.
- Convert the hap_enabled check into an ASSERT.

---
 xen/drivers/passthrough/iommu.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
xen/drivers/passthrough/iommu.c +3 -1
index debb5e6fe1..75bc410c2c 100644
@@ -505,7 +505,13 @@ int iommu_do_domctl(
 
 void iommu_share_p2m_table(struct domain* d)
 {
-    if ( iommu_use_hap_pt(d) )
+    ASSERT(hap_enabled(d));
+    /*
+     * iommu_use_hap_pt cannot be used here because at the point in the

domain
+ * construction where iommu_share_p2m_table get called need_iommu(d)
will

xen/drivers/passthrough/iommu.c +3 -1
+     * always return false.
+     */
+    if ( iommu_enabled && iommu_hap_pt_share )
         iommu_get_ops()->share_p2m(d);
 }
 
--
Quoted 1 line

2.19.0

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reviewed-by on v2 1/1
#2 lore raw
In reply to Roger Pau Monne
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 08.10.18 at 15:52, <[email protected]> wrote:

Commit 2916951c1 "mm / iommu: include need_iommu() test in iommu_use_hap_pt()" changed the check in iommu_share_p2m_table to use need_iommu(d) (as part of iommu_use_hap_pt) instead of iommu_enabled, which broke the check because at the point in domain construction where iommu_share_p2m_table is called need_iommu(d) will always return false.

Quoted 7 lines

Fix this by reverting to the previous logic.

While there turn the hap_enabled check into an ASSERT, since the only caller of iommu_share_p2m_table already performs the hap_enabled check before calling the function.

xen/drivers/passthrough/iommu.c int iommu_do_domctl( · line 513

Quoted 13 lines
xen/drivers/passthrough/iommu.c +6 -1
@@ -505,7 +505,13 @@ int iommu_do_domctl(
 
 void iommu_share_p2m_table(struct domain* d)
 {
-    if ( iommu_use_hap_pt(d) )
+    ASSERT(hap_enabled(d));
+    /*
+     * iommu_use_hap_pt cannot be used here because at the point in the domain
+     * construction where iommu_share_p2m_table get called need_iommu(d) will
+     * always return false.
+     */

I'm fighting with myself whether to shorten this comment while committing - it's certainly not "brief".

Jan

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel