[xen staging] x86/vtd: fix IOMMU share PT destruction path

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

[xen staging] x86/vtd: fix IOMMU share PT destruction path

commit 0c0677f003c116781d0fe7c8f3bc023f8b81862d
Author:     Wei Liu <[hidden email]>
AuthorDate: Tue Oct 9 15:57:08 2018 +0100
Commit:     Wei Liu <[hidden email]>
CommitDate: Thu Oct 11 09:33:46 2018 +0100

    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
    Signed-off-by: Wei Liu <[hidden email]>
    Reviewed-by: Paul Durrant <[hidden email]>
    Reviewed-by: Roger Pau Monné <[hidden email]>
    Acked-by: Kevin Tian <[hidden email]>
 xen/drivers/passthrough/vtd/iommu.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
index f94b522c73..4d1ff10817 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -1752,7 +1752,17 @@ static void iommu_domain_teardown(struct domain *d)
-    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 )
generated by git-patchbot for /home/xen/git/xen.git#staging

Xen-changelog mailing list
[hidden email]