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-devel

[Xen-devel] [PATCH 5 of 6] [XEN][LINUX] Refactor grant table allocation

To: Keir Fraser <keir.fraser@xxxxxxxxxxxxx>
Subject: [Xen-devel] [PATCH 5 of 6] [XEN][LINUX] Refactor grant table allocation into arch-specific code
From: Hollis Blanchard <hollisb@xxxxxxxxxx>
Date: Thu, 05 Jul 2007 17:27:54 -0500
Cc: xen-devel@xxxxxxxxxxxxxxxxxxx, xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Delivery-date: Thu, 05 Jul 2007 15:27:05 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1183674469@localhost>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
3 files changed, 27 insertions(+), 18 deletions(-)
arch/ia64/xen/hypervisor.c |    5 +++++
drivers/xen/core/gnttab.c  |   38 ++++++++++++++++++++------------------
include/xen/gnttab.h       |    2 ++


# HG changeset patch
# User Hollis Blanchard <hollisb@xxxxxxxxxx>
# Date 1183674347 18000
# Node ID 9def23611685442dc9688ad8f81db9a5031b4b5f
# Parent  790e4d5567dcd8bfb42ae1e67ad1f3dffd29ece1
[XEN][LINUX] Refactor grant table allocation into arch-specific code.
Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx>

diff -r 790e4d5567dc -r 9def23611685 arch/ia64/xen/hypervisor.c
--- a/arch/ia64/xen/hypervisor.c        Thu Jul 05 16:58:26 2007 -0500
+++ b/arch/ia64/xen/hypervisor.c        Thu Jul 05 17:25:47 2007 -0500
@@ -408,6 +408,11 @@ __xen_destroy_contiguous_region(unsigned
 #include <linux/mm.h>
 #include <xen/interface/xen.h>
 #include <xen/gnttab.h>
+
+void *arch_gnttab_alloc_shared(unsigned long *frames)
+{
+       return __va(frames[0] << PAGE_SHIFT);
+}
 
 static void
 gnttab_map_grant_ref_pre(struct gnttab_map_grant_ref *uop)
diff -r 790e4d5567dc -r 9def23611685 drivers/xen/core/gnttab.c
--- a/drivers/xen/core/gnttab.c Thu Jul 05 16:58:26 2007 -0500
+++ b/drivers/xen/core/gnttab.c Thu Jul 05 17:25:47 2007 -0500
@@ -430,7 +430,7 @@ static inline unsigned int max_nr_grant_
 
 #ifdef CONFIG_XEN
 
-#ifndef __ia64__
+#ifdef __x86__
 static int map_pte_fn(pte_t *pte, struct page *pmd_page,
                      unsigned long addr, void *data)
 {
@@ -448,7 +448,22 @@ static int unmap_pte_fn(pte_t *pte, stru
        set_pte_at(&init_mm, addr, pte, __pte(0));
        return 0;
 }
-#endif
+
+void *arch_gnttab_alloc_shared(unsigned long *frames)
+{
+       unsigned long *_frames = frames;
+       struct vm_struct *area;
+
+       area = alloc_vm_area(PAGE_SIZE * max_nr_grant_frames());
+       BUG_ON(area == NULL);
+
+       rc = apply_to_page_range(&init_mm, (unsigned long)area->addr,
+                       PAGE_SIZE * nr_gframes,
+                       map_pte_fn, &_frames);
+       BUG_ON(rc);
+       return area->addr;
+}
+#endif /* __x86__ */
 
 static int gnttab_map(unsigned int start_idx, unsigned int end_idx)
 {
@@ -473,21 +488,8 @@ static int gnttab_map(unsigned int start
 
        BUG_ON(rc || setup.status);
 
-#ifndef __ia64__
-       if (shared == NULL) {
-               struct vm_struct *area;
-               area = alloc_vm_area(PAGE_SIZE * max_nr_grant_frames());
-               BUG_ON(area == NULL);
-               shared = area->addr;
-       }
-       rc = apply_to_page_range(&init_mm, (unsigned long)shared,
-                                PAGE_SIZE * nr_gframes,
-                                map_pte_fn, &frames);
-       BUG_ON(rc);
-        frames -= nr_gframes; /* adjust after map_pte_fn() */
-#else
-       shared = __va(frames[0] << PAGE_SHIFT);
-#endif
+       if (shared == NULL)
+               shared = arch_gnttab_alloc_shared(frames);
 
        kfree(frames);
 
@@ -623,7 +625,7 @@ int gnttab_resume(void)
 
 int gnttab_suspend(void)
 {
-#ifndef __ia64__
+#ifdef CONFIG_X86
        apply_to_page_range(&init_mm, (unsigned long)shared,
                            PAGE_SIZE * nr_grant_frames,
                            unmap_pte_fn, NULL);
diff -r 790e4d5567dc -r 9def23611685 include/xen/gnttab.h
--- a/include/xen/gnttab.h      Thu Jul 05 16:58:26 2007 -0500
+++ b/include/xen/gnttab.h      Thu Jul 05 17:25:47 2007 -0500
@@ -117,6 +117,8 @@ int gnttab_suspend(void);
 int gnttab_suspend(void);
 int gnttab_resume(void);
 
+void *arch_gnttab_alloc_shared(unsigned long *frames);
+
 static inline void
 gnttab_set_map_op(struct gnttab_map_grant_ref *map, maddr_t addr,
                  uint32_t flags, grant_ref_t ref, domid_t domid)

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