[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH v2 for-4.11 1/2] libxc/x86: fix mapping of the start_info area



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@xxxxxxxxxx>
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Cc: Ian Jackson <ian.jackson@xxxxxxxxxxxxx>
Cc: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.