[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [XEN][POWERPC] The VIO rewrite



# HG changeset patch
# User Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
# Node ID a60e804c0a316037079a7e693f8561b4c28265ea
# Parent  b0293bc598358a7850fd397eea1301a907669830
[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>
Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx>
---
 xen/arch/powerpc/domain.c             |    7 +++++++
 xen/arch/powerpc/mm.c                 |   24 +++++++++++++++++++++++-
 xen/arch/powerpc/ofd_fixup.c          |    2 +-
 xen/include/asm-powerpc/domain.h      |    3 +++
 xen/include/asm-powerpc/grant_table.h |    4 ----
 5 files changed, 34 insertions(+), 6 deletions(-)

diff -r b0293bc59835 -r a60e804c0a31 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;
 }
 
@@ -294,6 +300,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 b0293bc59835 -r a60e804c0a31 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 b0293bc59835 -r a60e804c0a31 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 b0293bc59835 -r a60e804c0a31 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 b0293bc59835 -r a60e804c0a31 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__ */

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


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.