x86/vtd: fix iommu_share_p2m_table
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
@@ -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
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: fixiommu_share_p2m_tableCommit
2916951c1"mm / iommu: includeneed_iommu()test iniommu_use_hap_pt()" changed the check iniommu_share_p2m_tableto useneed_iommu(d)(as part ofiommu_use_hap_pt) instead ofiommu_enabled, which broke the check because at the point in domain construction whereiommu_share_p2m_tableis calledneed_iommu(d)will always return false.
Quoted 7 lines
Fix this by reverting to the previous logic.
While there turn the
hap_enabledcheck into an ASSERT, since the only caller ofiommu_share_p2m_tablealready performs thehap_enabledcheck before calling the function.Signed-off-by Roger Pau Monné <[email protected]>
Quoted 36 lines
---
Cc: Jan Beulich <[email protected]>
Cc: Paul Durrant <[email protected]>
---
Changes since v1:
- Add a comment about whyiommu_use_hap_ptcannot be used iniommu_share_p2m_table.
- Expand commit message.
- Convert thehap_enabledcheck into an ASSERT.--- xen/drivers/passthrough/iommu.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-)xen/drivers/passthrough/iommu.c +3
-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 whereiommu_share_p2m_tableget calledneed_iommu(d)
willxen/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
Quoted 8 lines
Quoted 1 line
Quoted 1 line · On 08.10.18 at 15:52, <[email protected]> wrote:
Commit
2916951c1"mm / iommu: includeneed_iommu()test iniommu_use_hap_pt()" changed the check iniommu_share_p2m_tableto useneed_iommu(d)(as part ofiommu_use_hap_pt) instead ofiommu_enabled, which broke the check because at the point in domain construction whereiommu_share_p2m_tableis calledneed_iommu(d)will always return false.
Quoted 7 lines
Fix this by reverting to the previous logic.
While there turn the
hap_enabledcheck into an ASSERT, since the only caller ofiommu_share_p2m_tablealready performs thehap_enabledcheck before calling the function.Signed-off-by Roger Pau Monné <[email protected]>
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