tools/xenconsoled: Use XC_PAGE_SIZE rather than getpagesize()
authorJulien Grall <julien.grall@linaro.org>
Mon, 11 May 2015 11:55:36 +0000 (12:55 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 7 Jul 2015 14:10:45 +0000 (15:10 +0100)
Linux may not use the same page granularity as Xen. This will result to
a domain crash because it will try to map more page than required.

As the console page size will always be equal to a Xen page size, use
XC_PAGE_SIZE.

Signed-off-by: Julien Grall <julien.grall@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/console/daemon/io.c

index ac08b5b48a6a72c80762d32d6b833ae1748995a2..e246c25eeb962c9165ec4dd7c66515884a85f8d9 100644 (file)
@@ -523,7 +523,7 @@ static void domain_unmap_interface(struct domain *dom)
        if (xcg_handle && dom->ring_ref == -1)
                xc_gnttab_munmap(xcg_handle, dom->interface, 1);
        else
-               munmap(dom->interface, getpagesize());
+               munmap(dom->interface, XC_PAGE_SIZE);
        dom->interface = NULL;
        dom->ring_ref = -1;
 }
@@ -562,7 +562,7 @@ static int domain_create_ring(struct domain *dom)
        if (!dom->interface) {
                /* Fall back to xc_map_foreign_range */
                dom->interface = xc_map_foreign_range(
-                       xc, dom->domid, getpagesize(),
+                       xc, dom->domid, XC_PAGE_SIZE,
                        PROT_READ|PROT_WRITE,
                        (unsigned long)ring_ref);
                if (dom->interface == NULL) {