x86/vtd: fix IOMMU share PT destruction path
PATCH v2 1/1 x86/vtd: fix IOMMU share PT destruction path
Commit 2916951c1 ("mm / iommu: include need_iommu() test in iommu_use_hap_pt()") included need_iommu() in iommu_use_hap_pt and 91d4eca7add ("mm / iommu: split need_iommu() into has_iommu_pt() and need_iommu_pt_sync()") made things finer grain by spliting need_iommu into three states.
The destruction path can't use iommu_use_hap_pt because at the point platform op is called, IOMMU is either already switched to or has always been in disabled state, and the shared PT test would always be false.
---
v2: fix bug and update comment.
--- xen/drivers/passthrough/vtd/iommu.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
xen/drivers/passthrough/vtd/iommu.c +11 -1
@@ -1752,7 +1752,17 @@ static void iommu_domain_teardown(struct domain *d)xfree (mrmrr); } -if (iommu_use_hap_pt (d) ) +ASSERT (iommu_enabled); + +/* +* We can't use iommu_use_hap_pt here because either IOMMU state +* is already changed to IOMMU_STATUS_disabled at this point or +* has always been IOMMU_STATUS_disabled. +* +* We also need to test if HAP is enabled because PV guests can +* enter this path too. +*/ +if (hap_enabled (d) && iommu_hap_pt_share )return ;spin_lock (&hd->arch.mapping_lock);
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 15 lines
-----Original Message-----
From: Wei Liu [mailto:[email protected]]
Sent: 09 October 2018 15:57
To: [email protected]
Cc: Paul Durrant <[email protected]>; Jan Beulich <[email protected]>; Roger Pau Monne <[email protected]>; Wei Liu <[email protected]>; Kevin Tian <[email protected]>
Subject: [PATCH v2] x86/vtd: fix IOMMU share PT destruction pathCommit
2916951c1("mm / iommu: includeneed_iommu()test iniommu_use_hap_pt()") includedneed_iommu()iniommu_use_hap_ptand91d4eca7add("mm / iommu: splitneed_iommu()intohas_iommu_pt()andneed_iommu_pt_sync()") made things finer grain by splitingneed_iommuinto three states.
Quoted 6 lines
The destruction path can't use
iommu_use_hap_ptbecause at the point platform op is called, IOMMU is either already switched to or has always been in disabled state, and the shared PT test would always be false.Signed-off-by Wei Liu <[email protected]>
Quoted 31 lines
---
v2: fix bug and update comment.--- xen/drivers/passthrough/vtd/iommu.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)xen/drivers/passthrough/vtd/iommu.c +11
-2@@ -1752,7 +1752,17 @@ static void iommu_domain_teardown(struct domain *d)xfree (mrmrr); } -if (iommu_use_hap_pt (d) ) +ASSERT (iommu_enabled); + +/* +* We can't use iommu_use_hap_pt here because either IOMMU state +* is already changed to IOMMU_STATUS_disabled at this point or +* has always been IOMMU_STATUS_disabled. +* +* We also need to test if HAP is enabled because PV guests can +* enter this path too. +*/ +if (hap_enabled (d) && iommu_hap_pt_share )return ;spin_lock (&hd->arch.mapping_lock); --
Quoted 1 line
2.11.0
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 6 lines · Wei Liu
Commit
2916951c1("mm / iommu: includeneed_iommu()test iniommu_use_hap_pt()") includedneed_iommu()iniommu_use_hap_ptand91d4eca7add("mm / iommu: splitneed_iommu()intohas_iommu_pt()andneed_iommu_pt_sync()") made things finer grain by splitingneed_iommuinto three states.
Quoted 6 lines
The destruction path can't use
iommu_use_hap_ptbecause at the point platform op is called, IOMMU is either already switched to or has always been in disabled state, and the shared PT test would always be false.Signed-off-by Wei Liu <[email protected]>
This is fine (and will fix destroying HVM/PVH guests), but I would still like deallocate_iommu_page_tables (from pci_amd_iommu.c) to be fixed in order to avoid the usage of iommu_use_hap_pt there also.
IMO the check itself could be converted into ASSERT(!iommu_hap_pt_share) since it's unlikely that AMD will have support for share page tables anytime soon.
Thanks, Roger.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 6 lines · Wei Liu
Commit
2916951c1("mm / iommu: includeneed_iommu()test iniommu_use_hap_pt()") includedneed_iommu()iniommu_use_hap_ptand91d4eca7add("mm / iommu: splitneed_iommu()intohas_iommu_pt()andneed_iommu_pt_sync()") made things finer grain by splitingneed_iommuinto three states.
Quoted 6 lines
The destruction path can't use
iommu_use_hap_ptbecause at the point platform op is called, IOMMU is either already switched to or has always been in disabled state, and the shared PT test would always be false.Signed-off-by Wei Liu <[email protected]>
Kevin, can you ack/nack this patch? Staging is currently blocked by a bug which is fixed by this patch.
Thanks,
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Add Kevin in the To: field
Quoted 12 lines · Wei Liu
Quoted 11 lines · Wei Liu
Commit
2916951c1("mm / iommu: includeneed_iommu()test iniommu_use_hap_pt()") includedneed_iommu()iniommu_use_hap_ptand91d4eca7add("mm / iommu: splitneed_iommu()intohas_iommu_pt()andneed_iommu_pt_sync()") made things finer grain by splitingneed_iommuinto three states.The destruction path can't use
iommu_use_hap_ptbecause at the point platform op is called, IOMMU is either already switched to or has always been in disabled state, and the shared PT test would always be false.
Quoted 7 lines
Quoted 1 line
Signed-off-by Wei Liu <[email protected]>Kevin, can you ack/nack this patch? Staging is currently blocked by a bug which is fixed by this patch.
Thanks,
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Tian, Kevin
Acked-byQuoted 17 lines
From: Wei Liu [mailto:[email protected]]
Sent: Thursday, October 11, 2018 4:28 PMQuoted 2 lines · Wei Liu
Commit
2916951c1("mm / iommu: includeneed_iommu()test iniommu_use_hap_pt()") includedneed_iommu()iniommu_use_hap_ptand
Quoted 1 line
91d4eca7add("mm / iommu: splitneed_iommu()intohas_iommu_pt()and
Quoted 8 lines
need_iommu_pt_sync()") made things finer grain by splitingneed_iommuinto three states.The destruction path can't use
iommu_use_hap_ptbecause at the point platform op is called, IOMMU is either already switched to or has always been in disabled state, and the shared PT test would always be false.
Quoted 5 lines
Quoted 1 line
Signed-off-by Wei Liu <[email protected]>Kevin, can you ack/nack this patch? Staging is currently blocked by a bug which is fixed by this patch.
Sorry I thought I've sent the ack but looks not:
Thanks
Kevin
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 19 lines · Kevin
Quoted 19 lines
From: Wei Liu [mailto:[email protected]]
Sent: Thursday, October 11, 2018 4:28 PMQuoted 2 lines · Wei Liu
Commit
2916951c1("mm / iommu: includeneed_iommu()test iniommu_use_hap_pt()") includedneed_iommu()iniommu_use_hap_ptand
Quoted 1 line
91d4eca7add("mm / iommu: splitneed_iommu()intohas_iommu_pt()and
Quoted 9 lines
need_iommu_pt_sync()") made things finer grain by splitingneed_iommuinto three states.The destruction path can't use
iommu_use_hap_ptbecause at the point platform op is called, IOMMU is either already switched to or has always been in disabled state, and the shared PT test would always be false.Signed-off-by Wei Liu <[email protected]>
Quoted 7 lines
Quoted 3 lines
Kevin, can you ack/nack this patch? Staging is currently blocked by a bug which is fixed by this patch.
Sorry I thought I've sent the ack but looks not:
Acked-by Kevin Tian <[email protected]>
Thank you!
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel