Date: Tue, 14 Jan 2014 15:59:41 +0100 From: Roger Pau Monne <roger.pau@citrix.com> To: <freebsd-xen@freebsd.org>, <freebsd-current@freebsd.org>, <xen-devel@lists.xen.org>, <gibbs@freebsd.org>, <jhb@freebsd.org>, <kib@freebsd.org>, <julien.grall@citrix.com> Cc: Roger Pau Monne <roger.pau@citrix.com> Subject: [PATCH v10 19/20] xen: changes to gnttab for PVH Message-ID: <1389711582-66908-20-git-send-email-roger.pau@citrix.com> In-Reply-To: <1389711582-66908-1-git-send-email-roger.pau@citrix.com> References: <1389711582-66908-1-git-send-email-roger.pau@citrix.com>
next in thread | previous in thread | raw e-mail | index | archive | help
--- 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)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1389711582-66908-20-git-send-email-roger.pau>