]> xenbits.xensource.com Git - people/iwj/xen.git/commitdiff
libxc/x86: fix mapping of the start_info area
authorRoger Pau Monne <roger.pau@citrix.com>
Wed, 28 Mar 2018 11:55:15 +0000 (12:55 +0100)
committerWei Liu <wei.liu2@citrix.com>
Wed, 28 Mar 2018 12:54:46 +0000 (13:54 +0100)
The start_info size calculated in bootlate_hvm is wrong. It should use
HVMLOADER_MODULE_MAX_COUNT instead of dom->num_modules and it doesn't
take into account the size of the modules command line.

This is not a problem so far because the actually used amount of
memory doesn't cross a page boundary, and so no page-fault is
triggered.

Instead of fixing the size calculation done in bootlate_hvm just map
the amount of memory allocated in alloc_magic_pages_hvm.

Suggested-by: Wei Liu <wei.liu2@citrix.com>
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Wei Liu <wei.liu2@citrix.com>
tools/libxc/xc_dom_x86.c

index 0b65dab4bca7e5cb161cb136756ddf953433fd44..f4bacb9e285f5b62a205751d39db22e392062f77 100644 (file)
@@ -1666,21 +1666,11 @@ static int bootlate_hvm(struct xc_dom_image *dom)
     uint32_t domid = dom->guest_domid;
     xc_interface *xch = dom->xch;
     struct hvm_start_info *start_info;
-    size_t start_info_size;
     struct hvm_modlist_entry *modlist;
     unsigned int i;
 
-    start_info_size = sizeof(*start_info) + dom->cmdline_size;
-    start_info_size += sizeof(struct hvm_modlist_entry) * dom->num_modules;
-
-    if ( start_info_size >
-         dom->start_info_seg.pages << XC_DOM_PAGE_SHIFT(dom) )
-    {
-        DOMPRINTF("Trying to map beyond start_info_seg");
-        return -1;
-    }
-
-    start_info = xc_map_foreign_range(xch, domid, start_info_size,
+    start_info = xc_map_foreign_range(xch, domid, dom->start_info_seg.pages <<
+                                                  XC_DOM_PAGE_SHIFT(dom),
                                       PROT_READ | PROT_WRITE,
                                       dom->start_info_seg.pfn);
     if ( start_info == NULL )
@@ -1733,7 +1723,7 @@ static int bootlate_hvm(struct xc_dom_image *dom)
 
     start_info->magic = XEN_HVM_START_MAGIC_VALUE;
 
-    munmap(start_info, start_info_size);
+    munmap(start_info, dom->start_info_seg.pages << XC_DOM_PAGE_SHIFT(dom));
 
     if ( dom->device_model )
     {