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

[Xen-devel] [PATCH v10 19/20] xen: changes to gnttab for PVH



---
 sys/xen/gnttab.c |   26 +++++++++++++++++++++-----
 1 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/sys/xen/gnttab.c b/sys/xen/gnttab.c
index 03c32b7..6949be5 100644
--- a/sys/xen/gnttab.c
+++ b/sys/xen/gnttab.c
@@ -25,6 +25,7 @@ __FBSDID("$FreeBSD$");
 #include <sys/lock.h>
 #include <sys/malloc.h>
 #include <sys/mman.h>
+#include <sys/limits.h>
 
 #include <xen/xen-os.h>
 #include <xen/hypervisor.h>
@@ -607,6 +608,7 @@ gnttab_resume(void)
 {
        int error;
        unsigned int max_nr_gframes, nr_gframes;
+       void *alloc_mem;
 
        nr_gframes = nr_grant_frames;
        max_nr_gframes = max_nr_grant_frames();
@@ -614,11 +616,25 @@ gnttab_resume(void)
                return (ENOSYS);
 
        if (!resume_frames) {
-               error = xenpci_alloc_space(PAGE_SIZE * max_nr_gframes,
-                   &resume_frames);
-               if (error) {
-                       printf("error mapping gnttab share frames\n");
-                       return (error);
+               if (xen_pv_domain()) {
+                       /*
+                        * This is a waste of physical memory,
+                        * we should use ballooned pages instead,
+                        * but it will do for now.
+                        */
+                       alloc_mem = contigmalloc(max_nr_gframes * PAGE_SIZE,
+                                                M_DEVBUF, M_NOWAIT, 0,
+                                                ULONG_MAX, PAGE_SIZE, 0);
+                       KASSERT((alloc_mem != NULL),
+                               ("unable to alloc memory for gnttab"));
+                       resume_frames = vtophys(alloc_mem);
+               } else {
+                       error = xenpci_alloc_space(PAGE_SIZE * max_nr_gframes,
+                           &resume_frames);
+                       if (error) {
+                               printf("error mapping gnttab share frames\n");
+                               return (error);
+                       }
                }
        }
 
-- 
1.7.7.5 (Apple Git-26)


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

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