Skip to contentSkip to conversation

x86/vtd: fix iommu_share_p2m_table

PATCH Superseded Roger Pau Monne 3 participants 7 messages Oct 8, 2018

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/vtd: fix iommu_share_p2m_table

Commit 2916951c1 changed the check in iommu_share_p2m_table to use need_iommu(d) 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.

---
Cc: Jan Beulich <[email protected]>
Cc: Paul Durrant <[email protected]>

---
 xen/drivers/passthrough/iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/passthrough/iommu.c +1 -1
index debb5e6fe1..a9408f1de9 100644
@@ -505,7 +505,7 @@ int iommu_do_domctl(
 
 void iommu_share_p2m_table(struct domain* d)
 {
-    if ( iommu_use_hap_pt(d) )
+    if ( iommu_enabled && hap_enabled(d) && 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 v1 1/1
#1 lore raw
Quoted 8 lines

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

Quoted 6 lines

Commit 2916951c1 changed the check in iommu_share_p2m_table to use need_iommu(d) 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.

Thanks for finding this.

Above, I think you need to include the title of commit 2916951c1 and also the text should say that the need_iommu() check became implicit in iommu_hap_pt_share() (otherwise folks looking at the patch may be bemused because need_iommu is not in the code).

The code looks fine though so...

Quoted 24 lines

---
Cc: Jan Beulich <[email protected]>
Cc: Paul Durrant <[email protected]>

---
 xen/drivers/passthrough/iommu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
xen/drivers/passthrough/iommu.c +1 -2
index debb5e6fe1..a9408f1de9 100644
@@ -505,7 +505,7 @@ int iommu_do_domctl(
 
 void iommu_share_p2m_table(struct domain* d)
 {
-    if ( iommu_use_hap_pt(d) )
+    if ( iommu_enabled && hap_enabled(d) && 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

#3 lore raw
In reply to Roger Pau Monne

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

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 08.10.18 at 12:14, <[email protected]> wrote:
xen/drivers/passthrough/iommu.c +1 -1
@@ -505,7 +505,7 @@ int iommu_do_domctl(
 
 void iommu_share_p2m_table(struct domain* d)
 {
-    if ( iommu_use_hap_pt(d) )
+    if ( iommu_enabled && hap_enabled(d) && iommu_hap_pt_share )

Considering the only caller, the hap_enabled() part is (and was) not needed here. I also would prefer to see a comment attached here, to (briefly) explain why this can't be iommu_use_hap_pt().

Is this what Wei also has found to break his PVH Dom0?

Jan

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

#2 lore raw
In reply to Paul Durrant
Quoted 14 lines
Quoted 14 lines
Quoted 1 line · On 08.10.18 at 12:27, <[email protected]> wrote:

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

Commit 2916951c1 changed the check in iommu_share_p2m_table to use need_iommu(d) 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 8 lines
Quoted 1 line

Fix this by reverting to the previous logic.

Thanks for finding this.

Above, I think you need to include the title of commit 2916951c1 and also the text should say that the need_iommu() check became implicit in iommu_hap_pt_share() (otherwise folks looking at the patch may be bemused because need_iommu is not in the code).

Indeed, it did take me more than just a moment to make the connection between description and code change (in this regard).

Jan

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

#4 lore raw
In reply to Jan Beulich
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 08.10.18 at 12:14, <[email protected]> wrote:
xen/drivers/passthrough/iommu.c +0 -0
@@ -505,7 +505,7 @@ int iommu_do_domctl(
 
Quoted 7 lines

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

Quoted 4 lines
xen/drivers/passthrough/iommu.c +1 -1
 void iommu_share_p2m_tableiommu_share_p2m_table(struct domain* d)
 {
-    if ( iommu_use_hap_pt(d) )
+    if ( iommu_enabled && hap_enabled(d) && iommu_hap_pt_share )

Considering the only caller, the hap_enabled() part is (and was) not needed here.

Would you like me to remove it in this patch?

I've merely changed iommu_share_p2m_table back to use the same logic as before 2916951c1.

Quoted 4 lines

I also would prefer to see a comment attached here, to (briefly) explain why this can't be iommu_use_hap_pt().

Is this what Wei also has found to break his PVH Dom0?

Yes, I think so.

Roger.

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

#5 lore raw
Quoted 14 lines · Roger Pau Monné
Quoted 5 lines · Jan Beulich
Quoted 5 lines
Quoted 1 line
Quoted 1 line · On 08.10.18 at 12:14, <[email protected]> wrote:
xen/drivers/passthrough/iommu.c +0 -0
@@ -505,7 +505,7 @@ int iommu_do_domctl(
 
Quoted 7 lines

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

Quoted 4 lines
xen/drivers/passthrough/iommu.c +1 -1
 void iommu_share_p2m_tableiommu_share_p2m_table(struct domain* d)
 {
-    if ( iommu_use_hap_pt(d) )
+    if ( iommu_enabled && hap_enabled(d) && iommu_hap_pt_share )

Considering the only caller, the hap_enabled() part is (and was) not needed here.

Quoted 1 line

Would you like me to remove it in this patch?

I've converted it to an ASSERT instead of just removing it.

Roger.

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

#6 lore raw
Quoted 16 lines
Quoted 1 line
Quoted 1 line · On 08.10.18 at 12:50, <[email protected]> wrote:
Quoted 14 lines · Roger Pau Monné
Quoted 12 lines · Jan Beulich

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

Quoted 9 lines
Quoted 1 line
Quoted 1 line · On 08.10.18 at 12:14, <[email protected]> wrote:
xen/drivers/passthrough/iommu.c +1 -1
@@ -505,7 +505,7 @@ int iommu_do_domctl(
 
 void iommu_share_p2m_tableiommu_share_p2m_table(struct domain* d)
 {
-    if ( iommu_use_hap_pt(d) )
+    if ( iommu_enabled && hap_enabled(d) && iommu_hap_pt_share )

Considering the only caller, the hap_enabled() part is (and was) not needed here.

Quoted 3 lines
Quoted 1 line

Would you like me to remove it in this patch?

I've converted it to an ASSERT instead of just removing it.

That's fine of course (and I was about to suggest this in reply to your earlier mail, but luckily have looked here first).

Jan

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