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

_______________________________________________
freebsd-xen@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-xen
To unsubscribe, send any mail to "freebsd-xen-unsubscr...@freebsd.org"

Reply via email to