libxc: Defer initialization of start_page for HVM guests
PATCH 1/1 libxc: Defer initialization of start_page for HVM guests
With commit 8c45adec18e0 ("libxc: create unmapped initrd in domain builder if supported") location of ramdisk may not be available to HVMlite guests by the time alloc_magic_pages_hvm() is invoked if the guest supports unmapped initrd.
So let's move ramdisk info initialization (along with a few other operations that are not directly related to allocating magic/special pages) from alloc_magic_pages_hvm() to bootlate_hvm().
Since we now split allocation and mapping of the start_info segment let's stash it, along with cmdline length, in xc_dom_image so that we can check whether we are mapping correctly-sized range.
We can also stop using xc_dom_image.start_info_pfn and leave it for PV(H) guests only.
---
v4:
* See the last two paragraphs from commit message above
v4.1:
* Inverted testing of start_info_size in bootlate_hvm().
tools/libxc/include/xc_dom.h | 2 + tools/libxc/xc_dom_x86.c | 140 +++++++++++++++++++++++------------------ 2 files changed, 80 insertions(+), 62 deletions(-)
tools/libxc/include/xc_dom.h +2 -0
@@ -71,6 +71,7 @@ struct xc_dom_image {/* arguments and parameters */ char *cmdline; +size_t cmdline_size;uint32_t f_requested[XENFEAT_NR_SUBMAPS ];/* info from (elf) kernel image */
@@ -91,6 +92,7 @@ struct xc_dom_image {struct xc_dom_seg p2m_seg;struct xc_dom_seg pgtables_seg;struct xc_dom_seg devicetree_seg; +struct xc_dom_seg start_info_seg;/* HVMlite only */ xen_pfn_t start_info_pfn;xen_pfn_t console_pfn;xen_pfn_t xenstore_pfn;
tools/libxc/xc_dom_x86.c +78 -62
181 lines not on this page · raw message
Signature · 1 line
1.7.1
Quoted 8 lines · Boris Ostrovsky
With commit
8c45adec18e0("libxc: create unmapped initrd in domain builder if supported") location of ramdisk may not be available to HVMlite guests by the timealloc_magic_pages_hvm()is invoked if the guest supports unmapped initrd.So let's move ramdisk info initialization (along with a few other operations that are not directly related to allocating magic/special pages) from
alloc_magic_pages_hvm()tobootlate_hvm().
The "few other operations" are just the hvm_info init for standard HVM by this iteration?
Quoted 7 lines
tools/libxc/include/xc_dom.h +0
-0@@ -71,6 +71,7 @@ struct xc_dom_image {
/* arguments and parameters */
char *cmdline;
+ size_tcmdline_size;
Perhaps /* Including NULL and padding/alignment */ ?
(That's the sort of thing I don't mind doing on commit if there is agreement and no other changes required)
Quoted 8 lines
tools/libxc/include/xc_dom.h +0
-0@@ -1095,8 +1044,8 @@ static int vcpu_hvm(struct xc_dom_image *dom) /* Set the IP. */ bsp_ctx.cpu.rip = dom->parms.phys_entry;
- if (dom->start_info_pfn)
- bsp_ctx.cpu.rbx =dom->start_info_pfn<<PAGE_SHIFT; + if (dom->start_info_seg.pfn)
+ bsp_ctx.cpu.rbx =dom->start_info_seg.pfn<<PAGE_SHIFT;
Just to check: dom->start_info_pfn is unused/nil in the regular-hvm case, correct (i.e. this code is dm-list specific both before and after)?
Quoted 11 lines
+ else
+ {
+ void*hvm_info_page;
+
+ if ( (hvm_info_page= xc_map_foreign_range(
+ xch, domid,PAGE_SIZE,PROT_READ|PROT_WRITE, + HVM_INFO_PFN)) == NULL )
+ return -1;
+ build_hvm_info(hvm_info_page, dom);
+ munmap(hvm_info_page,PAGE_SIZE);
+ }
Did you test regular HVM guests after this movement?
Ian.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Quoted 11 lines · Ian Campbell
Quoted 8 lines · Boris Ostrovsky
With commit
8c45adec18e0("libxc: create unmapped initrd in domain builder if supported") location of ramdisk may not be available to HVMlite guests by the timealloc_magic_pages_hvm()is invoked if the guest supports unmapped initrd.So let's move ramdisk info initialization (along with a few other operations that are not directly related to allocating magic/special pages) from
alloc_magic_pages_hvm()tobootlate_hvm().The "few other operations" are just the
hvm_infoinit for standard HVM by this iteration?
For HVM yes, but we also move command string initialization for HVMlite.
Quoted 5 lines
Quoted 5 lines
tools/libxc/include/xc_dom.h +0
-0@@ -71,6 +71,7 @@ struct xc_dom_image {
Quoted 7 lines
tools/libxc/include/xc_dom.h struct xc_dom_image { · line 74
Quoted 3 lines
tools/libxc/include/xc_dom.h +1
-0/* arguments and parameters */ char *cmdline; +size_t cmdline_size;Perhaps /* Including NULL and padding/alignment */ ?
(That's the sort of thing I don't mind doing on commit if there is agreement and no other changes required)
Yes, please add this (unless you want to see v5, v5.1 and v5.2)
Quoted 11 lines
tools/libxc/include/xc_dom.h static int vcpu_hvm(struct xc_dom_image *dom) · line 1048
Quoted 9 lines
tools/libxc/include/xc_dom.h +2
-2@@ -1095,8 +1044,8 @@ static int vcpu_hvm(struct xc_dom_image *dom)/* Set the IP. */ bsp_ctx.cpu.rip = dom->parms.phys_entry; -if ( dom->start_info_pfn ) - bsp_ctx.cpu.rbx = dom->start_info_pfn <<PAGE_SHIFT ; +if ( dom->start_info_seg.pfn ) + bsp_ctx.cpu.rbx = dom->start_info_seg.pfn <<PAGE_SHIFT ;Just to check:
dom->start_info_pfnis unused/nil in the regular-hvm case, correct (i.e. this code is dm-list specific both before and after)?
Yes, start_info_pfn is only used by PV(H) and since the structure is memset to zero during allocation the 'if' clause is only executed for HVMlite.
Quoted 12 lines
tools/libxc/include/xc_dom.h static int vcpu_hvm(struct xc_dom_image *dom)
Quoted 12 lines
tools/libxc/include/xc_dom.h +11
-0+else + { +void *hvm_info_page; + +if ( (hvm_info_page =xc_map_foreign_range ( + xch, domid,PAGE_SIZE ,PROT_READ |PROT_WRITE , +HVM_INFO_PFN )) ==NULL ) +return -1 ; +build_hvm_info (hvm_info_page, dom); +munmap (hvm_info_page,PAGE_SIZE ); + }
Quoted 1 line
Did you test regular HVM guests after this movement?
Yes, I did.
-boris