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] [xenppc-unstable] [XEN][POWERPC] The VIO rewrite

To: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Subject: [XenPPC] [xenppc-unstable] [XEN][POWERPC] The VIO rewrite
From: Xen patchbot-xenppc-unstable <patchbot-xenppc-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 03 Nov 2006 22:00:53 +0000
Delivery-date: Fri, 03 Nov 2006 14:02:40 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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>
Reply-to: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-ppc-devel-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
# Node ID b30cb72ed5e20d4957207145022e648b913c033b
# Parent  9148f7816d00bc45a8795a5119db9949894a3f89
[XEN][POWERPC] The VIO rewrite

Once you figure it all out, its time to do a rewrite, lots of code I
thougth I needed is now removed and less PPC specific code now exists.

This patch uses the MEMORY_HOTPLUG system to add a region to the
Kernel Linear Mapping that will be used exclusively to map in
Granted/Foreign pages.  This creates "struct page" objects in Linux
which are necessary to perform VIO operations.  When one of these
pages are grant_mapped the pfn2mfn() translation in Xen is updated to
reflect the association and the subsequent H_ENTER() from the domain
will contain the correct mapping.

Signed-off-by: Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
---
 xen/arch/powerpc/domain.c             |    7 +++++++
 xen/arch/powerpc/mm.c                 |   24 +++++++++++++++++++++++-
 xen/arch/powerpc/ofd_fixup.c          |    2 +-
 xen/common/grant_table.c              |    2 +-
 xen/include/asm-powerpc/domain.h      |    3 +++
 xen/include/asm-powerpc/grant_table.h |    4 ----
 xen/include/xen/grant_table.h         |    4 ----
 7 files changed, 35 insertions(+), 11 deletions(-)

diff -r 9148f7816d00 -r b30cb72ed5e2 xen/arch/powerpc/domain.c
--- a/xen/arch/powerpc/domain.c Tue Oct 24 19:11:00 2006 -0400
+++ b/xen/arch/powerpc/domain.c Fri Nov 03 16:53:17 2006 -0500
@@ -88,6 +88,12 @@ int arch_domain_create(struct domain *d)
 
     INIT_LIST_HEAD(&d->arch.extent_list);
 
+    d->arch.foreign_mfn_count = 1024;
+    d->arch.foreign_mfns = xmalloc_array(uint, d->arch.foreign_mfn_count);
+    BUG_ON(d->arch.foreign_mfns == NULL);
+
+    memset(d->arch.foreign_mfns, -1, d->arch.foreign_mfn_count * sizeof(uint));
+
     return 0;
 }
 
@@ -292,6 +298,7 @@ void domain_relinquish_resources(struct 
     relinquish_memory(d, &d->xenpage_list);
     relinquish_memory(d, &d->page_list);
     free_extents(d);
+    xfree(d->arch.foreign_mfns);
     return;
 }
 
diff -r 9148f7816d00 -r b30cb72ed5e2 xen/arch/powerpc/mm.c
--- a/xen/arch/powerpc/mm.c     Tue Oct 24 19:11:00 2006 -0400
+++ b/xen/arch/powerpc/mm.c     Fri Nov 03 16:53:17 2006 -0500
@@ -93,6 +93,26 @@ void share_xen_page_with_privileged_gues
         unimplemented();
 }
 
+static ulong foreign_to_mfn(struct domain *d, ulong pfn)
+{
+
+    pfn -= 1UL << cpu_foreign_map_order();
+
+    BUG_ON(pfn >= d->arch.foreign_mfn_count);
+
+    return d->arch.foreign_mfns[pfn];
+}
+
+static int set_foreign(struct domain *d, ulong pfn, ulong mfn)
+{
+    pfn -= 1UL << cpu_foreign_map_order();
+
+    BUG_ON(pfn >= d->arch.foreign_mfn_count);
+    d->arch.foreign_mfns[pfn] = mfn;
+
+    return 0;
+}
+
 static int create_grant_va_mapping(
     unsigned long va, unsigned long frame, struct vcpu *v)
 {
@@ -101,6 +121,7 @@ static int create_grant_va_mapping(
         BUG();
         return GNTST_permission_denied;
     }
+    set_foreign(v->domain, va >> PAGE_SHIFT, frame);
     return GNTST_okay;
 }
 
@@ -112,6 +133,7 @@ static int destroy_grant_va_mapping(
         BUG();
         return GNTST_permission_denied;
     }
+    set_foreign(d, addr >> PAGE_SHIFT, ~0UL);
     return GNTST_okay;
 }
 
@@ -388,7 +410,7 @@ ulong pfn2mfn(struct domain *d, ulong pf
     /* quick tests first */
     if (pfn & foreign_map_pfn) {
         t = PFN_TYPE_FOREIGN;
-        mfn = pfn & ~(foreign_map_pfn);
+        mfn = foreign_to_mfn(d, pfn);
     } else if (pfn >= max_page && pfn < (max_page + NR_GRANT_FRAMES)) {
         /* Its a grant table access */
         t = PFN_TYPE_GNTTAB;
diff -r 9148f7816d00 -r b30cb72ed5e2 xen/arch/powerpc/ofd_fixup.c
--- a/xen/arch/powerpc/ofd_fixup.c      Tue Oct 24 19:11:00 2006 -0400
+++ b/xen/arch/powerpc/ofd_fixup.c      Fri Nov 03 16:53:17 2006 -0500
@@ -354,7 +354,7 @@ static ofdn_t ofd_xen_props(void *m, str
 
         /* tell dom0 where ranted pages go in the linear map */
         val[0] = cpu_foreign_map_order();
-        val[1] = max_page;
+        val[1] = d->arch.foreign_mfn_count;
         ofd_prop_add(m, n, "foreign-map", val, sizeof (val));
 
         n = ofd_node_add(m, n, console, sizeof (console));
diff -r 9148f7816d00 -r b30cb72ed5e2 xen/common/grant_table.c
--- a/xen/common/grant_table.c  Tue Oct 24 19:11:00 2006 -0400
+++ b/xen/common/grant_table.c  Fri Nov 03 16:53:17 2006 -0500
@@ -280,7 +280,7 @@ __gnttab_map_grant_ref(
     ld->grant_table->maptrack[handle].ref   = op->ref;
     ld->grant_table->maptrack[handle].flags = op->flags;
 
-    op->dev_bus_addr = GNTTAB_DEV_BUS((u64)frame << PAGE_SHIFT);
+    op->dev_bus_addr = (u64)frame << PAGE_SHIFT;
     op->handle       = handle;
     op->status       = GNTST_okay;
 
diff -r 9148f7816d00 -r b30cb72ed5e2 xen/include/asm-powerpc/domain.h
--- a/xen/include/asm-powerpc/domain.h  Tue Oct 24 19:11:00 2006 -0400
+++ b/xen/include/asm-powerpc/domain.h  Fri Nov 03 16:53:17 2006 -0500
@@ -40,6 +40,9 @@ struct arch_domain {
 
     /* list of extents beyond RMA */
     struct list_head extent_list;
+
+    uint foreign_mfn_count;
+    uint *foreign_mfns;
 
     /* I/O-port access bitmap mask. */
     u8 *iobmp_mask;       /* Address of IO bitmap mask, or NULL.      */
diff -r 9148f7816d00 -r b30cb72ed5e2 xen/include/asm-powerpc/grant_table.h
--- a/xen/include/asm-powerpc/grant_table.h     Tue Oct 24 19:11:00 2006 -0400
+++ b/xen/include/asm-powerpc/grant_table.h     Fri Nov 03 16:53:17 2006 -0500
@@ -69,8 +69,4 @@ static inline uint cpu_foreign_map_order
     /* 16 GiB */
     return 34 - PAGE_SHIFT;
 }
-
-#define GNTTAB_DEV_BUS(f) \
-    ((f) | (1UL << (cpu_foreign_map_order() + PAGE_SHIFT)))
-
 #endif  /* __ASM_PPC_GRANT_TABLE_H__ */
diff -r 9148f7816d00 -r b30cb72ed5e2 xen/include/xen/grant_table.h
--- a/xen/include/xen/grant_table.h     Tue Oct 24 19:11:00 2006 -0400
+++ b/xen/include/xen/grant_table.h     Fri Nov 03 16:53:17 2006 -0500
@@ -96,8 +96,4 @@ gnttab_release_mappings(
 gnttab_release_mappings(
     struct domain *d);
 
-#ifndef GNTTAB_DEV_BUS
-#define GNTTAB_DEV_BUS(f) (f)
-#endif
-
 #endif /* __XEN_GRANT_TABLE_H__ */

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

<Prev in Thread] Current Thread [Next in Thread>
  • [XenPPC] [xenppc-unstable] [XEN][POWERPC] The VIO rewrite, Xen patchbot-xenppc-unstable <=