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.l...@citrix.com>
Signed-off-by: Roger Pau Monné <roger....@citrix.com>
---
Cc: Ian Jackson <ian.jack...@eu.citrix.com>
Cc: Wei Liu <wei.l...@citrix.com>
---
 tools/libxc/xc_dom_x86.c | 16 +++-------------
 1 file changed, 3 insertions(+), 13 deletions(-)

diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c
index 0b65dab4bc..f4bacb9e28 100644
--- a/tools/libxc/xc_dom_x86.c
+++ b/tools/libxc/xc_dom_x86.c
@@ -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 )
     {
-- 
2.16.3


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to