Attached the updated patches. Please find them

- 13985_4fa9b86d41b8_grow_granttable_acm.patch
        acm part. I did only compile test.

- 13986_cca098fd122c_grow_granttable_ia64.patch
        ia64 part.

- 13987_f5f232aef7bd_grow_granttable_powerpc.patch
        powerpc part. This patch prohibits growing grant table.
        I didn't even compile test.
        It needs review by xen/powerpc developers and they may
        have their own opinions.

Thanks,

On Thu, Feb 15, 2007 at 02:39:37PM +0000, Keir Fraser wrote:
> 
> Hi Isaku,
> 
> The dynamic grant table patch is now in xen-unstable (c/s
> 13952:4bd0ea9c499). Can you update and resend these patches?
> 
>  Thanks,
>  Keir
> 
> 
> On 6/1/07 06:48, "Isaku Yamahata" <[EMAIL PROTECTED]> wrote:
> 
> > On Fri, Jan 05, 2007 at 01:43:10PM +0000, Keir Fraser wrote:
> >> This one is waiting for final review before being checked in. Some people
> >> want the functionality this enables (>3 VIFs per guest) so I'm posting the
> >> patch in advance of applying it to xen-unstable.
> > 
> > I've been working on the same issue so that I have some patches.
> > I attached a part of them. Although they should be adjusted to
> > your patch which is to be commited, I wanted to send these out before
> > checking in.
> > If necessary, I'm willing to update them.
> > 
> > - acm code uses NR_GRANT_ENTRIES.
> >   The attached patch is only compile-tested.
> > 
> > - IA64 code needs a slight domain initialization adjustment.
> > 
> > - PPC code depends on the fact that shared grant table is machine 
> > continguous.
> >   I'm not familiar with PPC code so that I'm not sure how to solve it.
> >   If arch specific code can override maximal grant table size,
> >   Xen/PPC can prohibit growing grant table.
> >   After solving the issue, they can allow to grow grant table.
> 
> 
> _______________________________________________
> Xen-devel mailing list
> [EMAIL PROTECTED]
> http://lists.xensource.com/xen-devel
> 

-- 
yamahata
# HG changeset patch
# User [EMAIL PROTECTED]
# Date 1171867951 -32400
# Node ID 4fa9b86d41b8faeeb4338dabe62956ecb359b475
# Parent  b5fc88aad1b0eb35d12e503982c70fdc27f0544a
acm catch up for expandable grant table.
only compile-test is done.
PATCHNAME: grow_granttable_acm

Signed-off-by: Isaku Yamahata <[EMAIL PROTECTED]>

diff -r b5fc88aad1b0 -r 4fa9b86d41b8 xen/acm/acm_simple_type_enforcement_hooks.c
--- a/xen/acm/acm_simple_type_enforcement_hooks.c	Sun Feb 18 15:29:40 2007 +0000
+++ b/xen/acm/acm_simple_type_enforcement_hooks.c	Mon Feb 19 15:52:31 2007 +0900
@@ -234,18 +234,16 @@ ste_init_state(struct acm_ste_policy_buf
             }
         } 
         /* b) check for grant table conflicts on shared pages */
-        if ((*pd)->grant_table->shared == NULL) {
-            printkd("%s: Grant ... sharing for domain %x not setup!\n", __func__, (*pd)->domain_id);
-            continue;
-        }
-        for ( i = 0; i < NR_GRANT_ENTRIES; i++ ) {
-            sha_copy =  (*pd)->grant_table->shared[i];
+        spin_lock(&(*pd)->grant_table->lock);
+        for ( i = 0; i < nr_grant_entries((*pd)->grant_table); i++ ) {
+            sha_copy = shared_entry((*pd)->grant_table, i);
             if ( sha_copy.flags ) {
                 printkd("%s: grant dom (%hu) SHARED (%d) flags:(%hx) dom:(%hu) frame:(%lx)\n",
                         __func__, (*pd)->domain_id, i, sha_copy.flags, sha_copy.domid, 
                         (unsigned long)sha_copy.frame);
                 rdomid = sha_copy.domid;
                 if ((rdom = get_domain_by_id(rdomid)) == NULL) {
+                    spin_unlock(&(*pd)->grant_table->lock);
                     printkd("%s: domain not found ERROR!\n", __func__);
                     goto out;
                 };
@@ -253,14 +251,17 @@ ste_init_state(struct acm_ste_policy_buf
                 ste_rssid = GET_SSIDP(ACM_SIMPLE_TYPE_ENFORCEMENT_POLICY, 
                                       (struct acm_ssid_domain *)(rdom->ssid));
                 ste_rssidref = ste_rssid->ste_ssidref;
-                put_domain(rdom);
                 if (!have_common_type(ste_ssidref, ste_rssidref)) {
+                    spin_unlock(&(*pd)->grant_table->lock);
                     printkd("%s: Policy violation in grant table sharing domain %x -> domain %x.\n",
                             __func__, (*pd)->domain_id, rdomid);
+                    put_domain(rdom);
                     goto out;
                 }
+                put_domain(rdom);
             }
         }
+        spin_unlock(&(*pd)->grant_table->lock);
     }
     violation = 0;
  out:
diff -r b5fc88aad1b0 -r 4fa9b86d41b8 xen/common/grant_table.c
--- a/xen/common/grant_table.c	Sun Feb 18 15:29:40 2007 +0000
+++ b/xen/common/grant_table.c	Mon Feb 19 15:52:31 2007 +0900
@@ -100,9 +100,6 @@ nr_active_grant_frames(struct grant_tabl
     return num_act_frames_from_sha_frames(nr_grant_frames(gt));
 }
 
-#define SHGNT_PER_PAGE (PAGE_SIZE / sizeof(grant_entry_t))
-#define shared_entry(t, e) \
-    ((t)->shared[(e)/SHGNT_PER_PAGE][(e)%SHGNT_PER_PAGE])
 #define ACGNT_PER_PAGE (PAGE_SIZE / sizeof(struct active_grant_entry))
 #define active_entry(t, e) \
     ((t)->active[(e)/ACGNT_PER_PAGE][(e)%ACGNT_PER_PAGE])
diff -r b5fc88aad1b0 -r 4fa9b86d41b8 xen/include/xen/grant_table.h
--- a/xen/include/xen/grant_table.h	Sun Feb 18 15:29:40 2007 +0000
+++ b/xen/include/xen/grant_table.h	Mon Feb 19 15:52:31 2007 +0900
@@ -120,4 +120,9 @@ static inline unsigned int nr_grant_entr
     return (nr_grant_frames(gt) << PAGE_SHIFT) / sizeof(grant_entry_t);
 }
 
+/* for acm_cimple_type_enforcement_hooks.c */
+#define SHGNT_PER_PAGE (PAGE_SIZE / sizeof(grant_entry_t))
+#define shared_entry(t, e) \
+    ((t)->shared[(e)/SHGNT_PER_PAGE][(e)%SHGNT_PER_PAGE])
+
 #endif /* __XEN_GRANT_TABLE_H__ */
# HG changeset patch
# User [EMAIL PROTECTED]
# Date 1171869376 -32400
# Node ID cca098fd122c9568b67e4ffec5d0c992003e37b9
# Parent  4fa9b86d41b8faeeb4338dabe62956ecb359b475
GNTTAB: ia64 part expandable grant table
PATCHNAME: grow_granttable_ia64

Signed-off-by: Isaku Yamahata <[EMAIL PROTECTED]>

diff -r 4fa9b86d41b8 -r cca098fd122c xen/arch/ia64/xen/domain.c
--- a/xen/arch/ia64/xen/domain.c	Mon Feb 19 15:52:31 2007 +0900
+++ b/xen/arch/ia64/xen/domain.c	Mon Feb 19 16:16:16 2007 +0900
@@ -521,6 +521,16 @@ int arch_domain_create(struct domain *d)
 	if ((d->arch.mm.pgd = pgd_alloc(&d->arch.mm)) == NULL)
 	    goto fail_nomem;
 
+	/*
+	 * grant_table_create() can't fully initialize grant table for domain
+	 * because it is called before arch_domain_create().
+	 * Here we complete the initialization which requires p2m table.
+	 */
+	spin_lock(&d->grant_table->lock);
+	for (i = 0; i < nr_grant_frames(d->grant_table); i++)
+		ia64_gnttab_create_shared_page(d, d->grant_table, i);
+	spin_unlock(&d->grant_table->lock);
+
 	d->arch.ioport_caps = rangeset_new(d, "I/O Ports",
 	                                   RANGESETF_prettyprint_hex);
 
diff -r 4fa9b86d41b8 -r cca098fd122c xen/include/asm-ia64/grant_table.h
--- a/xen/include/asm-ia64/grant_table.h	Mon Feb 19 15:52:31 2007 +0900
+++ b/xen/include/asm-ia64/grant_table.h	Mon Feb 19 16:16:16 2007 +0900
@@ -13,15 +13,6 @@ int destroy_grant_host_mapping(unsigned 
 
 // for grant transfer
 void guest_physmap_add_page(struct domain *d, unsigned long gpfn, unsigned long mfn);
-
-// for grant table shared page
-#define gnttab_create_shared_page(d, t, i)                              \
-    do {                                                                \
-        share_xen_page_with_guest(                                      \
-            virt_to_page((char *)(t)->shared + ((i) << PAGE_SHIFT)),    \
-            (d), XENSHARE_writable);                                    \
-    } while (0)
-
 
 /* XXX
  * somewhere appropriate
@@ -39,14 +30,32 @@ void guest_physmap_add_page(struct domai
 /* Guest physical address of the grant table.  */
 #define IA64_GRANT_TABLE_PADDR  IA64_XMAPPEDREGS_PADDR(NR_CPUS)
 
-#define gnttab_shared_maddr(d, t, i)                        \
-    virt_to_maddr((char*)(t)->shared + ((i) << PAGE_SHIFT))
+#define gnttab_shared_maddr(t, i)       (virt_to_maddr((t)->shared[(i)]))
+#define gnttab_shared_page(t, i)        (virt_to_page((t)->shared[(i)]))
 
-# define gnttab_shared_gmfn(d, t, i)                                    \
-    ({ assign_domain_page((d),                                          \
-                          IA64_GRANT_TABLE_PADDR + ((i) << PAGE_SHIFT), \
-                          gnttab_shared_maddr((d), (t), (i)));          \
-        (IA64_GRANT_TABLE_PADDR >> PAGE_SHIFT) + (i);})
+#define ia64_gnttab_create_shared_page(d, t, i)                         \
+    do {                                                                \
+        BUG_ON((d)->arch.mm.pgd == NULL);                               \
+        assign_domain_page((d),                                         \
+                           IA64_GRANT_TABLE_PADDR + ((i) << PAGE_SHIFT), \
+                           gnttab_shared_maddr((t), (i)));              \
+    } while (0)
+
+/*
+ * for grant table shared page
+ * grant_table_create() might call this macro before allocating the p2m table.
+ * In such case, arch_domain_create() completes the initialization.
+ */
+#define gnttab_create_shared_page(d, t, i)                      \
+    do {                                                        \
+        share_xen_page_with_guest(gnttab_shared_page((t), (i)), \
+                                  (d), XENSHARE_writable);      \
+        if ((d)->arch.mm.pgd)                                   \
+            ia64_gnttab_create_shared_page((d), (t), (i));      \
+    } while (0)
+
+#define gnttab_shared_gmfn(d, t, i)                 \
+    ((IA64_GRANT_TABLE_PADDR >> PAGE_SHIFT) + (i))
 
 #define gnttab_mark_dirty(d, f) ((void)f)
 
# HG changeset patch
# User [EMAIL PROTECTED]
# Date 1171871352 -32400
# Node ID f5f232aef7bdfabd4997f45d88620dc45b50c185
# Parent  cca098fd122c9568b67e4ffec5d0c992003e37b9
GNTTAB: powerpc part expandable grant table.
Currently it is inhibited to grow grant table on powerpc.
Patch only. Even compilation isn't tested.
PATCHNAME: grow_granttable_powerpc

Signed-off-by: Isaku Yamahata <[EMAIL PROTECTED]>

diff -r cca098fd122c -r f5f232aef7bd xen/arch/powerpc/mm.c
--- a/xen/arch/powerpc/mm.c	Mon Feb 19 16:16:16 2007 +0900
+++ b/xen/arch/powerpc/mm.c	Mon Feb 19 16:49:12 2007 +0900
@@ -412,7 +412,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));
@@ -490,9 +496,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 cca098fd122c -r f5f232aef7bd xen/common/grant_table.c
--- a/xen/common/grant_table.c	Mon Feb 19 16:16:16 2007 +0900
+++ 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 cca098fd122c -r f5f232aef7bd xen/include/asm-powerpc/config.h
--- a/xen/include/asm-powerpc/config.h	Mon Feb 19 16:16:16 2007 +0900
+++ 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 cca098fd122c -r f5f232aef7bd xen/include/asm-powerpc/grant_table.h
--- a/xen/include/asm-powerpc/grant_table.h	Mon Feb 19 16:16:16 2007 +0900
+++ 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_frames[(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_frames[(i)]))
 
 #define gnttab_shared_gmfn(d, t, i)                     \
     (mfn_to_gmfn(d, gnttab_shared_mfn(d, t, i)))
diff -r cca098fd122c -r f5f232aef7bd xen/include/xen/grant_table.h
--- a/xen/include/xen/grant_table.h	Mon Feb 19 16:16:16 2007 +0900
+++ 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-ppc-devel mailing list
Xen-ppc-devel@lists.xensource.com
http://lists.xensource.com/xen-ppc-devel

Reply via email to