xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Andres Lagar-Cavilla <andres@lagarcavilla.org>
To: xen-devel@lists.xen.org
Cc: olaf@aepfle.de, keir@xen.org, andres@gridcentric.ca, tim@xen.org,
	wei.wang2@amd.com, JBeulich@suse.com, adin@gridcentric.ca
Subject: [PATCH 2 of 2] x86/mm: Make iommu passthrough and mem paging/sharing mutually exclusive
Date: Tue, 27 Mar 2012 11:43:28 -0400	[thread overview]
Message-ID: <1bf42bfcdd4564d5fd78.1332863008@xdev.gridcentric.ca> (raw)
In-Reply-To: <patchbomb.1332863006@xdev.gridcentric.ca>

 xen/arch/x86/mm/mem_event.c     |  4 ++++
 xen/arch/x86/mm/mem_sharing.c   |  5 ++++-
 xen/drivers/passthrough/iommu.c |  7 +++++++
 3 files changed, 15 insertions(+), 1 deletions(-)


Regardless of table sharing or processor vendor, these features cannot coexist
since iommu's don't expect gfn->mfn mappings to change, and sharing and paging
depend on trapping all accesses.

Signed-off-by: Andres Lagar-Cavilla <andres@lagarcavilla.org>

diff -r 92eaf393cad3 -r 1bf42bfcdd45 xen/arch/x86/mm/mem_event.c
--- a/xen/arch/x86/mm/mem_event.c
+++ b/xen/arch/x86/mm/mem_event.c
@@ -567,7 +567,11 @@ int mem_event_domctl(struct domain *d, x
             if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL )
                 break;
 
+            /* No paging if iommu is used */
             rc = -EXDEV;
+            if ( unlikely(need_iommu(d)) )
+                break;
+
             /* Disallow paging in a PoD guest */
             if ( p2m->pod.entry_count )
                 break;
diff -r 92eaf393cad3 -r 1bf42bfcdd45 xen/arch/x86/mm/mem_sharing.c
--- a/xen/arch/x86/mm/mem_sharing.c
+++ b/xen/arch/x86/mm/mem_sharing.c
@@ -1205,8 +1205,11 @@ int mem_sharing_domctl(struct domain *d,
     {
         case XEN_DOMCTL_MEM_SHARING_CONTROL:
         {
-            d->arch.hvm_domain.mem_sharing_enabled = mec->u.enable;
             rc = 0;
+            if ( unlikely(need_iommu(d) && mec->u.enable) )
+                rc = -EXDEV;
+            else
+                d->arch.hvm_domain.mem_sharing_enabled = mec->u.enable;
         }
         break;
 
diff -r 92eaf393cad3 -r 1bf42bfcdd45 xen/drivers/passthrough/iommu.c
--- a/xen/drivers/passthrough/iommu.c
+++ b/xen/drivers/passthrough/iommu.c
@@ -207,6 +207,13 @@ static int assign_device(struct domain *
     if ( !iommu_enabled || !hd->platform_ops )
         return 0;
 
+    /* Prevent device assign if mem paging or mem sharing have been 
+     * enabled for this domain */
+    if ( unlikely(!need_iommu(d) &&
+            (d->arch.hvm_domain.mem_sharing_enabled ||
+             d->mem_event->paging.ring_page)) )
+        return -EXDEV;
+
     spin_lock(&pcidevs_lock);
     if ( (rc = hd->platform_ops->assign_device(d, seg, bus, devfn)) )
         goto done;

  parent reply	other threads:[~2012-03-27 15:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-27 15:43 [PATCH 0 of 2] Support for Paging/Sharing on AMD Andres Lagar-Cavilla
2012-03-27 15:43 ` [PATCH 1 of 2] x86/mm: Teach paging to page table-based p2m Andres Lagar-Cavilla
2012-03-27 15:43 ` Andres Lagar-Cavilla [this message]
2012-03-29 11:03 ` [PATCH 0 of 2] Support for Paging/Sharing on AMD Tim Deegan
2012-03-29 14:46   ` Andres Lagar-Cavilla
2012-03-29 15:01     ` Tim Deegan
2012-03-29 15:26       ` Andres Lagar-Cavilla
2012-03-29 15:42         ` Tim Deegan
2012-03-29 15:48           ` Andres Lagar-Cavilla
2012-03-29 16:00             ` Tim Deegan
2012-03-29 16:01           ` Olaf Hering
2012-03-29 16:05             ` Andres Lagar-Cavilla
2012-03-29 16:08             ` Tim Deegan
2012-03-29 16:41               ` Olaf Hering
2012-03-29 16:58                 ` Tim Deegan
2012-04-03 14:42     ` Olaf Hering
2012-04-03 15:10       ` Andres Lagar-Cavilla
2012-04-03 15:16         ` Olaf Hering

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=1bf42bfcdd4564d5fd78.1332863008@xdev.gridcentric.ca \
    --to=andres@lagarcavilla.org \
    --cc=JBeulich@suse.com \
    --cc=adin@gridcentric.ca \
    --cc=andres@gridcentric.ca \
    --cc=keir@xen.org \
    --cc=olaf@aepfle.de \
    --cc=tim@xen.org \
    --cc=wei.wang2@amd.com \
    --cc=xen-devel@lists.xen.org \
    /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).