xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Tim Deegan <tim@xen.org>
To: "Kay, Allen M" <allen.m.kay@intel.com>
Cc: "Ren, Yongjie" <yongjie.ren@intel.com>,
	Xen Devel <xen-devel@lists.xensource.com>,
	"Li, Xin" <xin.li@intel.com>, Jan Beulich <JBeulich@novell.com>
Subject: Re: [bug] 'VT-d 1G super page' feature is blocked
Date: Tue, 16 Aug 2011 10:13:20 +0100	[thread overview]
Message-ID: <20110816091320.GL11708@ocelot.phlegethon.org> (raw)
In-Reply-To: <987664A83D2D224EAE907B061CE93D5301EA3F8905@orsmsx505.amr.corp.intel.com>

[-- Attachment #1: Type: text/plain, Size: 518 bytes --]

At 15:37 -0700 on 15 Aug (1313422621), Kay, Allen M wrote:
> > #define iommu_use_hap_pt(d) (paging_mode_translate(d) && iommu_hap_pt_share)
> 
> Tim, should the code be checking for paging_mode_hap(d) instead to
> make sure HAP page table is used?

Ah, yes it should; thanks for spotting that.  For AMD _external() is
sufficient but not for VtD.  Updated version attached. 

Cheers,

Tim

-- 
Tim Deegan <tim@xen.org>
Principal Software Engineer, Xen Platform Team
Citrix Systems UK Ltd.  (Company #02937203, SL9 0BG)

[-- Attachment #2: iommu-share-check --]
[-- Type: text/plain, Size: 3869 bytes --]

IOMMU: only try to share IOMMU and HAP tables for domains with P2M.
This makes the check more precise, and brings VTd in line with AMD code.

Signed-off-by: Tim Deegan <tim@xen.org>

diff -r e856f75d327c xen/include/xen/iommu.h
--- a/xen/include/xen/iommu.h	Mon Aug 15 11:22:52 2011 +0100
+++ b/xen/include/xen/iommu.h	Mon Aug 15 11:24:18 2011 +0100
@@ -33,6 +33,9 @@ extern bool_t iommu_snoop, iommu_qinval,
 extern bool_t iommu_hap_pt_share;
 extern bool_t iommu_debug;
 
+/* Does this domain have a P2M table we can use as its IOMMU pagetable? */
+#define iommu_use_hap_pt(d) (paging_mode_hap(d) && iommu_hap_pt_share)
+
 extern struct rangeset *mmio_ro_ranges;
 
 #define domain_hvm_iommu(d)     (&d->arch.hvm_domain.hvm_iommu)
diff -r e856f75d327c xen/drivers/passthrough/amd/iommu_map.c
--- a/xen/drivers/passthrough/amd/iommu_map.c	Mon Aug 15 11:22:52 2011 +0100
+++ b/xen/drivers/passthrough/amd/iommu_map.c	Mon Aug 15 11:24:18 2011 +0100
@@ -581,7 +581,7 @@ int amd_iommu_map_page(struct domain *d,
 
     BUG_ON( !hd->root_table );
 
-    if ( iommu_hap_pt_share && is_hvm_domain(d) )
+    if ( iommu_use_hap_pt(d) )
         return 0;
 
     spin_lock(&hd->mapping_lock);
@@ -624,7 +624,7 @@ int amd_iommu_unmap_page(struct domain *
 
     BUG_ON( !hd->root_table );
 
-    if ( iommu_hap_pt_share && is_hvm_domain(d) )
+    if ( iommu_use_hap_pt(d) )
         return 0;
 
     spin_lock(&hd->mapping_lock);
@@ -723,7 +723,7 @@ void amd_iommu_share_p2m(struct domain *
 
     ASSERT( is_hvm_domain(d) && d->arch.hvm_domain.hap_enabled );
 
-    if ( !iommu_hap_pt_share )
+    if ( !iommu_use_hap_pt(d) )
         return;
 
     pgd_mfn = pagetable_get_mfn(p2m_get_pagetable(p2m_get_hostp2m(d)));
diff -r e856f75d327c xen/drivers/passthrough/amd/pci_amd_iommu.c
--- a/xen/drivers/passthrough/amd/pci_amd_iommu.c	Mon Aug 15 11:22:52 2011 +0100
+++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c	Mon Aug 15 11:24:18 2011 +0100
@@ -21,6 +21,7 @@
 #include <xen/sched.h>
 #include <xen/pci.h>
 #include <xen/pci_regs.h>
+#include <xen/paging.h>
 #include <asm/hvm/iommu.h>
 #include <asm/amd-iommu.h>
 #include <asm/hvm/svm/amd-iommu-proto.h>
@@ -359,7 +360,7 @@ static void deallocate_iommu_page_tables
 {
     struct hvm_iommu *hd  = domain_hvm_iommu(d);
 
-    if ( iommu_hap_pt_share )
+    if ( iommu_use_hap_pt(d) )
         return;
 
     spin_lock(&hd->mapping_lock);
diff -r e856f75d327c xen/drivers/passthrough/iommu.c
--- a/xen/drivers/passthrough/iommu.c	Mon Aug 15 11:22:52 2011 +0100
+++ b/xen/drivers/passthrough/iommu.c	Mon Aug 15 11:24:18 2011 +0100
@@ -177,7 +177,7 @@ int assign_device(struct domain *d, u8 b
     if ( has_arch_pdevs(d) && !need_iommu(d) )
     {
         d->need_iommu = 1;
-        if ( !iommu_hap_pt_share )
+        if ( !iommu_use_hap_pt(d) )
             rc = iommu_populate_page_table(d);
         goto done;
     }
diff -r e856f75d327c xen/drivers/passthrough/vtd/iommu.c
--- a/xen/drivers/passthrough/vtd/iommu.c	Mon Aug 15 11:22:52 2011 +0100
+++ b/xen/drivers/passthrough/vtd/iommu.c	Mon Aug 15 11:24:18 2011 +0100
@@ -1613,7 +1613,7 @@ void iommu_domain_teardown(struct domain
     if ( list_empty(&acpi_drhd_units) )
         return;
 
-    if ( iommu_hap_pt_share )
+    if ( iommu_use_hap_pt(d) )
         return;
 
     spin_lock(&hd->mapping_lock);
@@ -1635,7 +1635,7 @@ static int intel_iommu_map_page(
     int iommu_domid;
 
     /* Do nothing if VT-d shares EPT page table */
-    if ( iommu_hap_pt_share )
+    if ( iommu_use_hap_pt(d) )
         return 0;
 
     /* do nothing if dom0 and iommu supports pass thru */
@@ -1760,7 +1760,7 @@ void iommu_set_pgd(struct domain *d)
 
     ASSERT( is_hvm_domain(d) && d->arch.hvm_domain.hap_enabled );
 
-    if ( !iommu_hap_pt_share )
+    if ( !iommu_use_hap_pt(d) )
         return;
 
     pgd_mfn = pagetable_get_mfn(p2m_get_pagetable(p2m_get_hostp2m(d)));

[-- Attachment #3: Type: text/plain, Size: 138 bytes --]

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

  reply	other threads:[~2011-08-16  9:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-30  6:58 [bug] 'VT-d 1G super page' feature is blocked Ren, Yongjie
2011-07-30  8:11 ` Tim Deegan
2011-07-30  9:00   ` Ren, Yongjie
2011-08-03  2:08     ` Ren, Yongjie
2011-08-03 17:12       ` Tim Deegan
2011-08-03 17:58         ` Kay, Allen M
2011-08-08  7:40           ` Jan Beulich
2011-08-08 15:11             ` Tim Deegan
2011-08-10 16:25               ` Tim Deegan
2011-08-15 10:11                 ` Tim Deegan
2011-08-15 10:40                   ` Tim Deegan
2011-08-15 22:37                     ` Kay, Allen M
2011-08-16  9:13                       ` Tim Deegan [this message]
2011-08-18  0:07                         ` Kay, Allen M
2011-08-20  1:47                         ` [PATCH][VTD] fixing vt-d/ept page table sharing in xen-4.1 Kay, Allen M
2011-08-22  7:39                           ` Jan Beulich
2011-08-22 16:51                             ` Kay, Allen M
2011-08-23  9:58                           ` Tim Deegan
2011-08-23 17:40                             ` Kay, Allen M
2011-08-25 10:59                               ` Tim Deegan
2011-08-25 15:23                                 ` Kay, Allen M
2011-08-25 16:56                                 ` Kay, Allen M
2011-08-26 12:27                                   ` Tim Deegan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110816091320.GL11708@ocelot.phlegethon.org \
    --to=tim@xen.org \
    --cc=JBeulich@novell.com \
    --cc=allen.m.kay@intel.com \
    --cc=xen-devel@lists.xensource.com \
    --cc=xin.li@intel.com \
    --cc=yongjie.ren@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).