WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ppc-devel

[XenPPC] [PATCH 1 of 2] [PATCH] Add mfn flag to disambiguate gmfn in pfn

To: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Subject: [XenPPC] [PATCH 1 of 2] [PATCH] Add mfn flag to disambiguate gmfn in pfn2mfn
From: Ryan Harper <ryanh@xxxxxxxxxx>
Date: Mon, 19 Mar 2007 17:38:27 -0500
Delivery-date: Mon, 19 Mar 2007 15:38:43 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1174343906@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-ppc-devel-request@lists.xensource.com?subject=help>
List-id: Xen PPC development <xen-ppc-devel.lists.xensource.com>
List-post: <mailto:xen-ppc-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-ppc-devel-bounces@xxxxxxxxxxxxxxxxxxx
3 files changed, 43 insertions(+), 20 deletions(-)
xen/arch/powerpc/mm.c        |   50 +++++++++++++++++++++++++-----------------
xen/arch/powerpc/ofd_fixup.c |    6 +++++
xen/include/asm-powerpc/mm.h |    7 +++++


# HG changeset patch
# User Ryan Harper <ryanh@xxxxxxxxxx>
# Date 1174331761 18000
# Node ID 155c212fda16103d2f58ea3a321f61a68b044846
# Parent  cd4e590ca12dbeee51130648e6f0887948c3d3d8
[PATCH] Add mfn flag to disambiguate gmfn in pfn2mfn

This patch adds in a new flag, a bit higher than is possible for the current
platform, to disambiguate the case where priv domains are asking to insert a mfn
in its htab and the value is also a valid pfn for the priv domain.  Linux will
add the mfn flag specifically when priv domains are mapping memory from domU.

The flag value is added to dom0's devtree notifying Linux which value to
use for domU mfn mapping.

Signed-off-by: Ryan Harper <ryanh@xxxxxxxxxx>

diff -r cd4e590ca12d -r 155c212fda16 xen/arch/powerpc/mm.c
--- a/xen/arch/powerpc/mm.c     Wed Mar 14 12:41:40 2007 -0500
+++ b/xen/arch/powerpc/mm.c     Mon Mar 19 14:16:01 2007 -0500
@@ -31,6 +31,7 @@
 #include <asm/platform.h>
 #include <asm/string.h>
 #include <asm/platform.h>
+#include <asm/mm.h>
 #include <public/arch-powerpc.h>
 
 #ifdef VERBOSE
@@ -407,6 +408,34 @@ ulong pfn2mfn(struct domain *d, ulong pf
     ulong mfn = INVALID_MFN;
     int t = PFN_TYPE_NONE;
     ulong foreign_map_pfn = 1UL << cpu_foreign_map_order();
+
+    /* Check if we are mapping another domain's mfns */
+    if (gmfn_is_mfn(pfn)) {
+
+        /* strip flag off */
+        pfn -= (1UL << FOREIGN_MFN_ORDER);
+
+        /* This hack allows dom0 to map all memory, necessary to
+         * initialize domU state. */
+        if (d->is_privileged && mfn_valid(pfn)) {
+            struct page_info *pg;
+
+            /* page better be allocated to some domain but not the caller */
+            pg = mfn_to_page(pfn);
+            if (!(pg->count_info & PGC_allocated))
+                panic("Foreign page: 0x%lx is not owned by any domain\n",
+                      pfn);
+            if (page_get_owner(pg) == d)
+                panic("Foreign page: 0x%lx is owned by this domain\n",
+                      pfn);
+                
+            /* set type and translate */
+            t = PFN_TYPE_FOREIGN;
+            mfn = pfn;
+
+            goto out;
+        }
+    }
 
     /* quick tests first */
     if (pfn & foreign_map_pfn) {
@@ -438,31 +467,12 @@ ulong pfn2mfn(struct domain *d, ulong pf
 #endif
     }
 
-    if (t == PFN_TYPE_NONE) {
-        /* This hack allows dom0 to map all memory, necessary to
-         * initialize domU state. */
-        if (d->is_privileged && mfn_valid(pfn)) {
-            struct page_info *pg;
-
-            /* page better be allocated to some domain but not the caller */
-            pg = mfn_to_page(pfn);
-            if (!(pg->count_info & PGC_allocated))
-                panic("Foreign page: 0x%lx is not owned by any domain\n",
-                      mfn);
-            if (page_get_owner(pg) == d)
-                panic("Foreign page: 0x%lx is owned by this domain\n",
-                      mfn);
-                
-            t = PFN_TYPE_FOREIGN;
-            mfn = pfn;
-        }
-    }
-
     if (mfn == INVALID_MFN) {
         printk("%s: Dom[%d] pfn 0x%lx is not a valid page\n",
                __func__, d->domain_id, pfn);
     }
 
+out:
     if (type)
         *type = t;
 
diff -r cd4e590ca12d -r 155c212fda16 xen/arch/powerpc/ofd_fixup.c
--- a/xen/arch/powerpc/ofd_fixup.c      Wed Mar 14 12:41:40 2007 -0500
+++ b/xen/arch/powerpc/ofd_fixup.c      Mon Mar 19 14:16:01 2007 -0500
@@ -22,6 +22,7 @@
 #include <xen/lib.h>
 #include <xen/sched.h>
 #include <xen/version.h>
+#include <asm/mm.h>
 #include <public/xen.h>
 #include "of-devtree.h"
 #include "oftree.h"
@@ -372,6 +373,11 @@ static ofdn_t ofd_xen_props(void *m, str
         val[1] = d->arch.foreign_mfn_count;
         ofd_prop_add(m, n, "foreign-map", val, sizeof (val));
 
+        /* tell dom0 how to flag pfns when mapping guest memory pages */
+        val[0] = FOREIGN_MFN_ORDER;
+        val[1] = 0UL;
+        ofd_prop_add(m, n, "mfn-base", val, sizeof (val));
+
         n = ofd_node_add(m, n, console, sizeof (console));
         if (n > 0) {
             val[0] = 0;
diff -r cd4e590ca12d -r 155c212fda16 xen/include/asm-powerpc/mm.h
--- a/xen/include/asm-powerpc/mm.h      Wed Mar 14 12:41:40 2007 -0500
+++ b/xen/include/asm-powerpc/mm.h      Mon Mar 19 14:16:01 2007 -0500
@@ -238,6 +238,13 @@ extern unsigned long paddr_to_maddr(unsi
 #define PFN_TYPE_FOREIGN 4
 #define PFN_TYPE_GNTTAB 5
 
+/* we flag pfns in Linux that are actually mfns from another domain 
+   used when dom0 is constructing a guest.  We detect this flag and
+   understand that the pfn is really an mfn. */
+
+#define FOREIGN_MFN_ORDER (35 - PAGE_SHIFT)
+#define gmfn_is_mfn(g) (g & (1UL << FOREIGN_MFN_ORDER))
+
 extern ulong pfn2mfn(struct domain *d, ulong pfn, int *type);
 static inline unsigned long gmfn_to_mfn(struct domain *d, unsigned long gmfn)
 {

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

<Prev in Thread] Current Thread [Next in Thread>