All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] xen/iommu: fix usage of shared EPT/IOMMU page tables on PVH guests
@ 2015-02-27 11:33 Roger Pau Monne
  2015-03-04 16:53 ` David Vrabel
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: Roger Pau Monne @ 2015-02-27 11:33 UTC (permalink / raw)
  To: xen-devel
  Cc: Kevin Tian, Suravee Suthikulpanit, Aravind Gopalakrishnan,
	Jan Beulich, Yang Zhang, Roger Pau Monne

iommu_share_p2m_table should not prevent PVH guests from using a shared page
table between the IOMMU and EPT. Clean the code by removing the asserts in
the vendor specific implementations (amd_iommu_share_p2m, iommu_set_pgd),
and moving the hap_enabled assert to the caller (iommu_share_p2m_table).

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.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>
Cc: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
Cc: Jan Beulich <jbeulich@suse.com>
Cc: Yang Zhang <yang.z.zhang@intel.com>
Cc: Kevin Tian <kevin.tian@intel.com>
---
Changes since v1:
 - Reword commit message.
 - Move the hap_enabled assert from vendor implementation to the generic
   code.
 - Remove the has_hvm_container_domain condition from iommu_share_p2m_table,
   hap_enabled is more restrictive.
---
 xen/drivers/passthrough/amd/iommu_map.c | 2 --
 xen/drivers/passthrough/iommu.c         | 3 ++-
 xen/drivers/passthrough/vtd/iommu.c     | 2 --
 xen/drivers/passthrough/x86/iommu.c     | 2 +-
 4 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/xen/drivers/passthrough/amd/iommu_map.c b/xen/drivers/passthrough/amd/iommu_map.c
index a8c60ec..31dc05d 100644
--- a/xen/drivers/passthrough/amd/iommu_map.c
+++ b/xen/drivers/passthrough/amd/iommu_map.c
@@ -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;
 
diff --git a/xen/drivers/passthrough/iommu.c b/xen/drivers/passthrough/iommu.c
index cc12735..7fcbbb1 100644
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -332,7 +332,8 @@ void iommu_share_p2m_table(struct domain* d)
 {
     const struct iommu_ops *ops = iommu_get_ops();
 
-    if ( iommu_enabled && is_hvm_domain(d) )
+    ASSERT( hap_enabled(d) );
+    if ( iommu_enabled )
         ops->share_p2m(d);
 }
 
diff --git a/xen/drivers/passthrough/vtd/iommu.c b/xen/drivers/passthrough/vtd/iommu.c
index 2e113d7..ff542cb 100644
--- a/xen/drivers/passthrough/vtd/iommu.c
+++ b/xen/drivers/passthrough/vtd/iommu.c
@@ -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;
 
diff --git a/xen/drivers/passthrough/x86/iommu.c b/xen/drivers/passthrough/x86/iommu.c
index 52d8948..9eb8d33 100644
--- a/xen/drivers/passthrough/x86/iommu.c
+++ b/xen/drivers/passthrough/x86/iommu.c
@@ -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))));
-- 
1.9.3 (Apple Git-50)


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-03-11 10:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-27 11:33 [PATCH v2] xen/iommu: fix usage of shared EPT/IOMMU page tables on PVH guests Roger Pau Monne
2015-03-04 16:53 ` David Vrabel
2015-03-05  9:49 ` Tim Deegan
2015-03-09  3:30 ` Tian, Kevin
2015-03-09  9:02   ` Roger Pau Monné
2015-03-10 12:51 ` Julien Grall
2015-03-10 13:06   ` Jan Beulich
2015-03-10 13:18     ` Julien Grall
2015-03-10 13:35       ` Jan Beulich
2015-03-11 10:52         ` Julien Grall

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.