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

[Xen-changelog] [xen-unstable] GNTTAB: PowerPC patch for dynamic grant tables.



# HG changeset patch
# User Hollis Blanchard <hollisb@xxxxxxxxxx>
# Date 1171871352 -32400
# Node ID 7e9dc164b5720dbf60929333d33f8d94e981fe5b
# Parent  3ac19fda0bc256bac20a4decf7e13bb086162220
GNTTAB: PowerPC patch for dynamic grant tables.
Grant table expansion is disabled for now, since we currently make assumptions
about grant table MFNs being contiguous.
Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx>
---
 xen/arch/powerpc/mm.c                 |   16 ++++++++++++++--
 xen/common/grant_table.c              |    2 ++
 xen/include/asm-powerpc/config.h      |    9 +++++++++
 xen/include/asm-powerpc/grant_table.h |    4 ++--
 xen/include/xen/grant_table.h         |    4 ++++
 5 files changed, 31 insertions(+), 4 deletions(-)

diff -r 3ac19fda0bc2 -r 7e9dc164b572 xen/arch/powerpc/mm.c
--- a/xen/arch/powerpc/mm.c     Fri Mar 02 12:11:52 2007 +0000
+++ b/xen/arch/powerpc/mm.c     Mon Feb 19 16:49:12 2007 +0900
@@ -416,7 +416,13 @@ ulong pfn2mfn(struct domain *d, ulong pf
     if (pfn & foreign_map_pfn) {
         t = PFN_TYPE_FOREIGN;
         mfn = foreign_to_mfn(d, pfn);
-    } else if (pfn >= max_page && pfn < (max_page + NR_GRANT_FRAMES)) {
+    } else if (pfn >= max_page && pfn <
+              (max_page + nr_grant_frames(d->grant_table))) {
+        /* XXX access d->grant_table->nr_grant_frames without lock.
+         * Currently on powerpc dynamic expanding grant table is
+         * inhibited by setting max_nr_grant_frames = INITIAL_NR_GRANT_FRAMES
+         * so that this access is safe.
+         */
         /* Its a grant table access */
         t = PFN_TYPE_GNTTAB;
         mfn = gnttab_shared_mfn(d, d->grant_table, (pfn - max_page));
@@ -494,9 +500,15 @@ unsigned long mfn_to_gmfn(struct domain 
     ulong gnttab_mfn;
     ulong rma_mfn;
 
+    /* XXX access d->grant_table->nr_grant_frames without lock.
+     * Currently on powerpc dynamic expanding grant table is
+     * inhibited by setting max_nr_grant_frames = INITIAL_NR_GRANT_FRAMES
+     * so that this access is safe.
+     */
     /* grant? */
     gnttab_mfn = gnttab_shared_mfn(d, d->grant_table, 0);
-    if (mfn >= gnttab_mfn && mfn < (gnttab_mfn + NR_GRANT_FRAMES))
+    if (mfn >= gnttab_mfn && mfn <
+       (gnttab_mfn + nr_grant_frames(d->grant_table)))
         return max_page + (mfn - gnttab_mfn);
 
     /* IO? */
diff -r 3ac19fda0bc2 -r 7e9dc164b572 xen/common/grant_table.c
--- a/xen/common/grant_table.c  Fri Mar 02 12:11:52 2007 +0000
+++ b/xen/common/grant_table.c  Mon Feb 19 16:49:12 2007 +0900
@@ -35,8 +35,10 @@
 #include <xen/domain_page.h>
 #include <acm/acm_hooks.h>
 
+#ifndef max_nr_grant_frames
 unsigned int max_nr_grant_frames = DEFAULT_MAX_NR_GRANT_FRAMES;
 integer_param("gnttab_max_nr_frames", max_nr_grant_frames);
+#endif
 
 /* The maximum number of grant mappings is defined as a multiplier of the
  * maximum number of grant table entries. This defines the multiplier used.
diff -r 3ac19fda0bc2 -r 7e9dc164b572 xen/include/asm-powerpc/config.h
--- a/xen/include/asm-powerpc/config.h  Fri Mar 02 12:11:52 2007 +0000
+++ b/xen/include/asm-powerpc/config.h  Mon Feb 19 16:49:12 2007 +0900
@@ -73,4 +73,13 @@ extern char __bss_start[];
 
 #include <asm/powerpc64/config.h>
 
+/*
+ * Disallow grant table growing tempralily because pfn2mfn() and
+ * mfn_to_gmfn() depends on the fact that grant table is machine-address
+ * contiguous. Grant table growing breaks the assumption.
+ */
+#ifndef max_nr_grant_frames
+#define max_nr_grant_frames INITIAL_NR_GRANT_FRAMES
 #endif
+
+#endif
diff -r 3ac19fda0bc2 -r 7e9dc164b572 xen/include/asm-powerpc/grant_table.h
--- a/xen/include/asm-powerpc/grant_table.h     Fri Mar 02 12:11:52 2007 +0000
+++ b/xen/include/asm-powerpc/grant_table.h     Mon Feb 19 16:49:12 2007 +0900
@@ -41,11 +41,11 @@ int destroy_grant_host_mapping(
 #define gnttab_create_shared_page(d, t, i)                               \
     do {                                                                 \
         share_xen_page_with_guest(                                       \
-            virt_to_page((char *)(t)->shared + ((i) * PAGE_SIZE)),       \
+            virt_to_page((t)->shared[(i)]),                       \
             (d), XENSHARE_writable);                                     \
     } while ( 0 )
 
-#define gnttab_shared_mfn(d, t, i) (((ulong)((t)->shared) >> PAGE_SHIFT) + (i))
+#define gnttab_shared_mfn(d, t, i) (virt_to_mfn((t)->shared[(i)]))
 
 #define gnttab_shared_gmfn(d, t, i)                     \
     (mfn_to_gmfn(d, gnttab_shared_mfn(d, t, i)))
diff -r 3ac19fda0bc2 -r 7e9dc164b572 xen/include/xen/grant_table.h
--- a/xen/include/xen/grant_table.h     Fri Mar 02 12:11:52 2007 +0000
+++ b/xen/include/xen/grant_table.h     Mon Feb 19 16:49:12 2007 +0900
@@ -56,10 +56,14 @@ struct active_grant_entry {
 #define INITIAL_NR_GRANT_ENTRIES ((INITIAL_NR_GRANT_FRAMES << PAGE_SHIFT) / \
                                      sizeof(grant_entry_t))
 
+#ifndef DEFAULT_MAX_NR_GRANT_FRAMES /* to allow arch to override */
 /* Default maximum size of a grant table. [POLICY] */
 #define DEFAULT_MAX_NR_GRANT_FRAMES   32
+#endif
+#ifndef max_nr_grant_frames /* to allow arch to override */
 /* The maximum size of a grant table. */
 extern unsigned int max_nr_grant_frames;
+#endif
 
 /*
  * Tracks a mapping of another domain's grant reference. Each domain has a

_______________________________________________
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®.