Skip to contentSkip to conversation

xen/iommu: fix usage of shared EPT/IOMMU page tables on PVH guests

PATCH Superseded Roger Pau Monne 2 participants 2 messages Feb 27, 2015

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen/iommu: fix usage of shared EPT/IOMMU page tables on PVH guests

iommu_share_p2m_table should not prevent PVH guests from using a shared page table. Change the condition to has_hvm_container_domain instead of is_hvm_domain. This allows both PVH and HVM guests to use it. Remove the asserts in iommu_set_pgd and amd_iommu_share_p2m, iommu_share_p2m_table and p2m_alloc_table already do them.

Also fix another incorrect usage of is_hvm_domain usage in arch_iommu_populate_page_table. This has not given problems so far because all the pages in PVH guests are of type PGT_writable_page.

Cc Suravee Suthikulpanit <[email protected]>
Cc Aravind Gopalakrishnan <[email protected]>
Cc Jan Beulich <[email protected]>
Cc Yang Zhang <[email protected]>
Cc Kevin Tian <[email protected]>
---
 xen/drivers/passthrough/amd/iommu_map.c | 2 --
 xen/drivers/passthrough/iommu.c         | 2 +-
 xen/drivers/passthrough/vtd/iommu.c     | 2 --
 xen/drivers/passthrough/x86/iommu.c     | 2 +-
 4 files changed, 2 insertions(+), 6 deletions(-)
xen/drivers/passthrough/amd/iommu_map.c +0 -2
index a8c60ec..31dc05d 100644
@@ -785,8 +785,6 @@ void amd_iommu_share_p2m(struct domain *d)
     struct page_info *p2m_table;
     mfn_t pgd_mfn;
 
-    ASSERT( is_hvm_domain(d) && d->arch.hvm_domain.hap_enabled );
-
     if ( !iommu_use_hap_pt(d) )
         return;
 
xen/drivers/passthrough/iommu.c +1 -1
index cc12735..3e11d6b 100644
@@ -332,7 +332,7 @@ void iommu_share_p2m_table(struct domain* d)
 {
     const struct iommu_ops *ops = iommu_get_ops();
 
-    if ( iommu_enabled && is_hvm_domain(d) )
+    if ( iommu_enabled && has_hvm_container_domain(d) )
         ops->share_p2m(d);
 }
 
xen/drivers/passthrough/vtd/iommu.c +0 -2
index 2e113d7..ff542cb 100644
@@ -1788,8 +1788,6 @@ static void iommu_set_pgd(struct domain *d)
     struct hvm_iommu *hd  = domain_hvm_iommu(d);
     mfn_t pgd_mfn;
 
-    ASSERT( is_hvm_domain(d) && d->arch.hvm_domain.hap_enabled );
-
     if ( !iommu_use_hap_pt(d) )
         return;
 
xen/drivers/passthrough/x86/iommu.c +1 -1
index 52d8948..9eb8d33 100644
@@ -56,7 +56,7 @@ int arch_iommu_populate_page_table(struct domain *d)
 
     while ( !rc && (page = page_list_remove_head(&d->page_list)) )
     {
-        if ( is_hvm_domain(d) ||
+        if ( has_hvm_container_domain(d) ||
             (page->u.inuse.type_info & PGT_type_mask) == PGT_writable_page )
         {
             BUG_ON(SHARED_M2P(mfn_to_gmfn(d, page_to_mfn(page))));
Signature · 7 lines
1.9.3 (Apple Git-50)


_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
#1 lore raw
Quoted 6 lines
Quoted 1 line
Quoted 1 line · On 27.02.15 at 11:10, <[email protected]> wrote:

iommu_share_p2m_table should not prevent PVH guests from using a shared page table. Change the condition to has_hvm_container_domain instead of is_hvm_domain. This allows both PVH and HVM guests to use it. Remove the asserts in iommu_set_pgd and amd_iommu_share_p2m, iommu_share_p2m_table and p2m_alloc_table already do them.

This wording is confusing - it took me to got into p2m_alloc_table() to see that one half of the assertion is being satisfied there an the other in iommu_share_p2m_table(). While not asserting what IOMMU code does is quite fine in IOMMU code (especially as closely related as is the case here), the assertion regarding what P2M code does (and what a future second caller of iommu_share_p2m_table() might violate) should be kept, but perhaps be moved into iommu_share_p2m_table() instead of keeping it in vendor specific code.

Jan