libxc/x86: fix mapping of the start_info area
PATCH v2 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.
---
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
--- tools/libxc/xc_dom_x86.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-)
tools/libxc/xc_dom_x86.c +3 -13
@@ -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 ) {
Signature · 7 lines
2.16.3 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH v2 2/2 libxc/x86: do not unconditionally set the module cmdline address
This will lead to writing a wrong module command line physical memory address if no command line is actually provided.
This hasn't caused problems so far because hvmloader is the only consumer of the modules command line, and it's unconditionally set in that case.
---
Cc: Ian Jackson <[email protected]>
Cc: Wei Liu <[email protected]>
--- tools/libxc/xc_dom_x86.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
tools/libxc/xc_dom_x86.c +2 -3
@@ -1653,11 +1653,10 @@ static void add_module_to_list(struct xc_dom_image *dom, < HVMLOADER_MODULE_CMDLINE_SIZE);strncpy (modules_cmdline_start +HVMLOADER_MODULE_CMDLINE_SIZE * index, cmdline,HVMLOADER_MODULE_CMDLINE_SIZE ); + modlist[index].cmdline_paddr = modules_cmdline_paddr + +HVMLOADER_MODULE_CMDLINE_SIZE * index; } - modlist[index].cmdline_paddr = - modules_cmdline_paddr +HVMLOADER_MODULE_CMDLINE_SIZE * index; - start_info->nr_modules++; }
Signature · 7 lines
2.16.3 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 8 lines · Roger Pau Monne
The
start_infosize calculated inbootlate_hvmis wrong. It should useHVMLOADER_MODULE_MAX_COUNTinstead ofdom->num_modulesand 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.
Quoted 5 lines
Instead of fixing the size calculation done in
bootlate_hvmjust map the amount of memory allocated inalloc_magic_pages_hvm.Suggested-by Wei Liu <[email protected]>Signed-off-by Roger Pau Monné <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel