Don't allocate dom->p2m_host[] for translated domains
cover Don't allocate dom->p2m_host[] for translated domains
Vastly drop xl's memory usage for HVM (x86 and ARM) guest construction.
See
https://lore.kernel.org/xen-devel/[email protected]/T/#u
for the origins of this work, but ultimately I think this is a far cleaner solution to the problem.
Andrew Cooper (4):
tools/dombuilder: xc_dom_x86 cleanup tools/dombuilder: Remove PV-only, mandatory hooks tools/dombuilder: Remove p2m_guest from the common interface tools/dombuilder: Don't allocate dom->p2m_host[] for translated
domains
stubdom/grub/kexec.c | 36 ++++------ tools/libxc/include/xc_dom.h | 24 +++---- tools/libxc/xc_dom_arm.c | 30 -------- tools/libxc/xc_dom_boot.c | 6 +- tools/libxc/xc_dom_core.c | 43 +---------- tools/libxc/xc_dom_x86.c | 166 ++++++++++++++++++++++--------------------- 6 files changed, 114 insertions(+), 191 deletions(-)
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 1/4 tools/dombuilder: xc_dom_x86 cleanup
The two xc_dom_params structures for PV pagetables are never modified and can live in .rodata. Reduce their scope to the alloc_pgtable_*() functions which construct xc_dom_image_x86 appropriately.
Rename {alloc,setup}_pgtables() to {alloc,setup}_pgtables_pv() to highlight that they are PV only, and drop some _x86() suffixes from static helpers.
No functional change.
---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Varad Gautam <[email protected]>
--- tools/libxc/xc_dom_x86.c | 60 ++++++++++++++++++++++-------------------------- 1 file changed, 28 insertions(+), 32 deletions(-)
tools/libxc/xc_dom_x86.c +28 -32
@@ -103,7 +103,7 @@ struct xc_dom_image_x86 {unsigned n_mappings;#define MAPPING_MAX 2struct xc_dom_x86_mapping maps[MAPPING_MAX ]; -struct xc_dom_params *params; +const struct xc_dom_params *params; };/* get guest IO ABI protocol */
@@ -235,7 +235,7 @@ static int count_pgtables(struct xc_dom_image *dom, xen_vaddr_t from,return 0 ; } -static int alloc_pgtables (struct xc_dom_image *dom) +static int alloc_pgtables_pv (struct xc_dom_image *dom) {int pages, extra_pages;xen_vaddr_t try_virt_end;
@@ -268,20 +268,20 @@ static int alloc_pgtables(struct xc_dom_image *dom)/* ------------------------------------------------------------------------ */ /* i386 pagetables */ -static struct xc_dom_params x86_32_params = { - .levels =PGTBL_LEVELS_I386 , - .vaddr_mask =bits_to_mask (VIRT_BITS_I386 ), - .lvl_prot[0 ] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED, - .lvl_prot[1 ] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER, - .lvl_prot[2 ] = _PAGE_PRESENT, -}; -static int alloc_pgtables_x86_32_pae (struct xc_dom_image *dom) { +static const struct xc_dom_params x86_32_params = { + .levels =PGTBL_LEVELS_I386 , + .vaddr_mask =bits_to_mask (VIRT_BITS_I386 ), + .lvl_prot[0 ] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED, + .lvl_prot[1 ] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER, + .lvl_prot[2 ] = _PAGE_PRESENT, + };struct xc_dom_image_x86 *domx86 = dom->arch_private; domx86->params = &x86_32_params; -return alloc_pgtables (dom); + +return alloc_pgtables_pv (dom); }#define pfn_to_paddr (pfn) ((xen_paddr_t)(pfn) << PAGE_SHIFT_X86)
@@ -355,7 +355,7 @@ static xen_pfn_t move_l3_below_4G(struct xc_dom_image *dom,return l3mfn; } -static x86_pgentry_t *get_pg_table_x86 (struct xc_dom_image *dom,int m,int l) +static x86_pgentry_t *get_pg_table (struct xc_dom_image *dom,int m,int l) {struct xc_dom_image_x86 *domx86 = dom->arch_private;struct xc_dom_x86_mapping *map;
@@ -371,8 +371,7 @@ static x86_pgentry_t *get_pg_table_x86(struct xc_dom_image *dom, int m, int l)return NULL ; } -static x86_pgentry_t get_pg_prot_x86 (struct xc_dom_image *dom,int l, -xen_pfn_t pfn) +static x86_pgentry_t get_pg_prot (struct xc_dom_image *dom,int l,xen_pfn_t pfn) {struct xc_dom_image_x86 *domx86 = dom->arch_private;struct xc_dom_x86_mapping *map;
@@ -396,7 +395,7 @@ static x86_pgentry_t get_pg_prot_x86(struct xc_dom_image *dom, int l,return prot; } -static int setup_pgtables_x86 (struct xc_dom_image *dom) +static int setup_pgtables_pv (struct xc_dom_image *dom) {struct xc_dom_image_x86 *domx86 = dom->arch_private;struct xc_dom_x86_mapping *map1, *map2;
@@ -413,7 +412,7 @@ static int setup_pgtables_x86(struct xc_dom_image *dom) map1 = domx86->maps + m1; from = map1->lvls[l].from; to = map1->lvls[l].to; - pg =get_pg_table_x86 (dom, m1, l); + pg =get_pg_table (dom, m1, l);if ( !pg )return -1 ;for ( m2 =0 ; m2 < domx86->n_mappings; m2++ )
@@ -433,7 +432,7 @@ static int setup_pgtables_x86(struct xc_dom_image *dom)for ( p = p_s; p <= p_e; p++ ) { pg[p] =pfn_to_paddr (xc_dom_p2m (dom, pfn)) | -get_pg_prot_x86 (dom, l, pfn); +get_pg_prot (dom, l, pfn); pfn++; } }
@@ -464,32 +463,32 @@ static int setup_pgtables_x86_32_pae(struct xc_dom_image *dom) } } -return setup_pgtables_x86 (dom); +return setup_pgtables_pv (dom); }/* ------------------------------------------------------------------------ */ /* x86_64 pagetables */ -static struct xc_dom_params x86_64_params = { - .levels =PGTBL_LEVELS_X86_64 , - .vaddr_mask =bits_to_mask (VIRT_BITS_X86_64 ), - .lvl_prot[0 ] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED, - .lvl_prot[1 ] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER, - .lvl_prot[2 ] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER, - .lvl_prot[3 ] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER, -}; -static int alloc_pgtables_x86_64 (struct xc_dom_image *dom) { +const static struct xc_dom_params x86_64_params = { + .levels =PGTBL_LEVELS_X86_64 , + .vaddr_mask =bits_to_mask (VIRT_BITS_X86_64 ), + .lvl_prot[0 ] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED, + .lvl_prot[1 ] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER, + .lvl_prot[2 ] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER, + .lvl_prot[3 ] = _PAGE_PRESENT|_PAGE_RW|_PAGE_ACCESSED|_PAGE_DIRTY|_PAGE_USER, + };struct xc_dom_image_x86 *domx86 = dom->arch_private; domx86->params = &x86_64_params; -return alloc_pgtables (dom); + +return alloc_pgtables_pv (dom); }static int setup_pgtables_x86_64 (struct xc_dom_image *dom) { -return setup_pgtables_x86 (dom); +return setup_pgtables_pv (dom); }/* ------------------------------------------------------------------------ */
@@ -1908,9 +1907,6 @@ static struct xc_dom_arch xc_hvm_32 = { .sizeof_pfn = 4, .alloc_magic_pages = alloc_magic_pages_hvm, .alloc_pgtables = alloc_pgtables_hvm, - .setup_pgtables = NULL, - .start_info = NULL, - .shared_info = NULL, .vcpu = vcpu_hvm, .meminit = meminit_hvm, .bootearly = bootearly,
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 2/4 tools/dombuilder: Remove PV-only, mandatory hooks
In reply to Andrew CooperCurrently, the setup_pgtable() hook is optional, but alloc_pgtable() hook is not. Both are specific to x86 PV guests, and stubbed in various ways by the dombuilders for translated guests (x86 HVM, ARM).
Make alloc_pgtables() optional, and drop all the stubs for translated guest types.
No change in the constructed guests.
---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Varad Gautam <[email protected]>
--- tools/libxc/include/xc_dom.h | 3 ++- tools/libxc/xc_dom_arm.c | 21 --------------------- tools/libxc/xc_dom_boot.c | 6 +++--- tools/libxc/xc_dom_core.c | 3 ++- tools/libxc/xc_dom_x86.c | 7 ------- 5 files changed, 7 insertions(+), 33 deletions(-)
tools/libxc/include/xc_dom.h +2 -1
@@ -253,8 +253,9 @@ void xc_dom_register_loader(struct xc_dom_loader *loader);/* --- arch specific hooks ----------------------------------------- */ struct xc_dom_arch { -/* pagetable setup */ int (*alloc_magic_pages) (struct xc_dom_image * dom); + +/* pagetable setup - x86 PV only */ int (*alloc_pgtables) (struct xc_dom_image * dom);int (*alloc_p2m_list) (struct xc_dom_image * dom);int (*setup_pgtables) (struct xc_dom_image * dom);
tools/libxc/xc_dom_arm.c +0 -21
@@ -47,23 +47,6 @@ const char *xc_domain_get_native_protocol(xc_interface *xch, }/* ------------------------------------------------------------------------ */ -/* -* arm guests are hybrid and start off with paging disabled, therefore no -* pagetables and nothing to do here. -*/ -static int alloc_pgtables_arm (struct xc_dom_image *dom) -{ -DOMPRINTF_CALLED (dom->xch); -return 0 ; -} - -static int setup_pgtables_arm (struct xc_dom_image *dom) -{ -DOMPRINTF_CALLED (dom->xch); -return 0 ; -} - -/* ------------------------------------------------------------------------ */ static int alloc_magic_pages (struct xc_dom_image *dom) {
@@ -539,8 +522,6 @@ static struct xc_dom_arch xc_dom_32 = { .page_shift = PAGE_SHIFT_ARM, .sizeof_pfn = 8, .alloc_magic_pages = alloc_magic_pages, - .alloc_pgtables = alloc_pgtables_arm, - .setup_pgtables = setup_pgtables_arm, .start_info = start_info_arm, .shared_info = shared_info_arm, .vcpu = vcpu_arm32,
@@ -555,8 +536,6 @@ static struct xc_dom_arch xc_dom_64 = { .page_shift = PAGE_SHIFT_ARM, .sizeof_pfn = 8, .alloc_magic_pages = alloc_magic_pages, - .alloc_pgtables = alloc_pgtables_arm, - .setup_pgtables = setup_pgtables_arm, .start_info = start_info_arm, .shared_info = shared_info_arm, .vcpu = vcpu_arm64,
tools/libxc/xc_dom_boot.c +3 -3
@@ -199,9 +199,9 @@ int xc_dom_boot_image(struct xc_dom_image *dom)/* initial mm setup */ if ( (rc =xc_dom_update_guest_p2m (dom)) !=0 )return rc; -if ( dom->arch_hooks->setup_pgtables ) -if ( (rc = dom->arch_hooks->setup_pgtables (dom)) !=0 ) -return rc; +if ( dom->arch_hooks->setup_pgtables && + (rc = dom->arch_hooks->setup_pgtables (dom)) !=0 ) +return rc;/* start info page */ if ( dom->arch_hooks->start_info )
tools/libxc/xc_dom_core.c +2 -1
@@ -1247,7 +1247,8 @@ int xc_dom_build_image(struct xc_dom_image *dom) goto err;if ( dom->arch_hooks->alloc_magic_pages (dom) !=0 ) goto err; -if ( dom->arch_hooks->alloc_pgtables (dom) !=0 ) +if ( dom->arch_hooks->alloc_pgtables && + dom->arch_hooks->alloc_pgtables (dom) !=0 ) goto err;if ( dom->alloc_bootstack ) {
tools/libxc/xc_dom_x86.c +0 -7
@@ -1690,12 +1690,6 @@ static int bootlate_pv(struct xc_dom_image *dom)return 0 ; } -static int alloc_pgtables_hvm (struct xc_dom_image *dom) -{ -DOMPRINTF ("%s: doing nothing" , __func__); -return 0 ; -} -/* * The memory layout of the start_info page and the modules, and where the * addresses are stored:
@@ -1906,7 +1900,6 @@ static struct xc_dom_arch xc_hvm_32 = { .page_shift = PAGE_SHIFT_X86, .sizeof_pfn = 4, .alloc_magic_pages = alloc_magic_pages_hvm, - .alloc_pgtables = alloc_pgtables_hvm, .vcpu = vcpu_hvm, .meminit = meminit_hvm, .bootearly = bootearly,
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH 2/4] tools/dombuilder: Remove PV-only, mandatory hooks
Hi Andrew,
Quoted 10 lines · Andrew Cooper
Currently, the
setup_pgtable()hook is optional, butalloc_pgtable()hook is not. Both are specific to x86 PV guests, and stubbed in various ways by the dombuilders for translated guests (x86 HVM, ARM).Make
alloc_pgtables()optional, and drop all the stubs for translated guest types.No change in the constructed guests.
Signed-off-by Andrew Cooper <[email protected]>
Cheers,
Quoted 133 lines
---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Varad Gautam <[email protected]>--- tools/libxc/include/xc_dom.h | 3 ++- tools/libxc/xc_dom_arm.c | 21 --------------------- tools/libxc/xc_dom_boot.c | 6 +++--- tools/libxc/xc_dom_core.c | 3 ++- tools/libxc/xc_dom_x86.c | 7 ------- 5 files changed, 7 insertions(+), 33 deletions(-)tools/libxc/include/xc_dom.h +2
-1@@ -253,8 +253,9 @@ void xc_dom_register_loader(struct xc_dom_loader *loader);/* --- arch specific hooks ----------------------------------------- */ struct xc_dom_arch { -/* pagetable setup */ int (*alloc_magic_pages) (struct xc_dom_image * dom); + +/* pagetable setup - x86 PV only */ int (*alloc_pgtables) (struct xc_dom_image * dom);int (*alloc_p2m_list) (struct xc_dom_image * dom);int (*setup_pgtables) (struct xc_dom_image * dom);tools/libxc/xc_dom_arm.c +0
-21@@ -47,23 +47,6 @@ const char *xc_domain_get_native_protocol(xc_interface *xch, }/* ------------------------------------------------------------------------ */ -/* -* arm guests are hybrid and start off with paging disabled, therefore no -* pagetables and nothing to do here. -*/ -static int alloc_pgtables_arm (struct xc_dom_image *dom) -{ -DOMPRINTF_CALLED (dom->xch); -return 0 ; -} - -static int setup_pgtables_arm (struct xc_dom_image *dom) -{ -DOMPRINTF_CALLED (dom->xch); -return 0 ; -} - -/* ------------------------------------------------------------------------ */ static int alloc_magic_pages (struct xc_dom_image *dom) {@@ -539,8 +522,6 @@ static struct xc_dom_arch xc_dom_32 = { .page_shift = PAGE_SHIFT_ARM, .sizeof_pfn = 8, .alloc_magic_pages = alloc_magic_pages, - .alloc_pgtables = alloc_pgtables_arm, - .setup_pgtables = setup_pgtables_arm, .start_info = start_info_arm, .shared_info = shared_info_arm, .vcpu = vcpu_arm32,@@ -555,8 +536,6 @@ static struct xc_dom_arch xc_dom_64 = { .page_shift = PAGE_SHIFT_ARM, .sizeof_pfn = 8, .alloc_magic_pages = alloc_magic_pages, - .alloc_pgtables = alloc_pgtables_arm, - .setup_pgtables = setup_pgtables_arm, .start_info = start_info_arm, .shared_info = shared_info_arm, .vcpu = vcpu_arm64,tools/libxc/xc_dom_boot.c +3
-3@@ -199,9 +199,9 @@ int xc_dom_boot_image(struct xc_dom_image *dom)/* initial mm setup */ if ( (rc =xc_dom_update_guest_p2m (dom)) !=0 )return rc; -if ( dom->arch_hooks->setup_pgtables ) -if ( (rc = dom->arch_hooks->setup_pgtables (dom)) !=0 ) -return rc; +if ( dom->arch_hooks->setup_pgtables && + (rc = dom->arch_hooks->setup_pgtables (dom)) !=0 ) +return rc;/* start info page */ if ( dom->arch_hooks->start_info )tools/libxc/xc_dom_core.c +2
-1@@ -1247,7 +1247,8 @@ int xc_dom_build_image(struct xc_dom_image *dom) goto err;if ( dom->arch_hooks->alloc_magic_pages (dom) !=0 ) goto err; -if ( dom->arch_hooks->alloc_pgtables (dom) !=0 ) +if ( dom->arch_hooks->alloc_pgtables && + dom->arch_hooks->alloc_pgtables (dom) !=0 ) goto err;if ( dom->alloc_bootstack ) {tools/libxc/xc_dom_x86.c +0
-7@@ -1690,12 +1690,6 @@ static int bootlate_pv(struct xc_dom_image *dom)return 0 ; } -static int alloc_pgtables_hvm (struct xc_dom_image *dom) -{ -DOMPRINTF ("%s: doing nothing" , __func__); -return 0 ; -} -/* * The memory layout of the start_info page and the modules, and where the * addresses are stored: @@ -1906,7 +1900,6 @@ static struct xc_dom_arch xc_hvm_32 = { .page_shift = PAGE_SHIFT_X86, .sizeof_pfn = 4, .alloc_magic_pages = alloc_magic_pages_hvm, - .alloc_pgtables = alloc_pgtables_hvm, .vcpu = vcpu_hvm, .meminit = meminit_hvm, .bootearly = bootearly,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 3/4 tools/dombuilder: Remove p2m_guest from the common interface
In reply to Andrew CooperIn-guest p2m's are a concept specific to x86 PV guests. alloc_p2m_list() is the only hook which initialises dom->p2m_guest, making xc_dom_update_guest_p2m() a nop for non-PV guests.
Move p2m_guest into xc_dom_image_x86 and adjust alloc_p2m_list() to match.
Drop xc_dom_update_guest_p2m() entirely.
One caller, move_l3_below_4G(), only uses it to modify a single entry, so rewriting the whole guest p2m is wasteful - opencode the single update instead. The other caller is common code. Instead, move the logic into the setup_pgtables() hooks, which know their own sizeof_pfn and can do away with the switch statement.
No change in the constructed guests.
---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Varad Gautam <[email protected]>
--- stubdom/grub/kexec.c | 8 -------- tools/libxc/include/xc_dom.h | 2 -- tools/libxc/xc_dom_boot.c | 2 -- tools/libxc/xc_dom_core.c | 40 ---------------------------------------- tools/libxc/xc_dom_x86.c | 41 +++++++++++++++++++++++++++++++++++------ 5 files changed, 35 insertions(+), 58 deletions(-)
stubdom/grub/kexec.c +0 -8
@@ -320,14 +320,6 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, chardo_exchange (dom,PHYS_PFN (_boot_target - dom->parms.virt_base),virt_to_mfn (&_boot_page)); -/* Make sure the bootstrap page table does not RW-map any of our current -* page table frames */ -if ( (rc =xc_dom_update_guest_p2m (dom))) { -printk ("xc_dom_update_guest_p2m returned %d\n" , rc); - errnum =ERR_BOOT_FAILURE ; - goto out; - } -if ( dom->arch_hooks->setup_pgtables )if ( (rc = dom->arch_hooks->setup_pgtables (dom))) {printk ("setup_pgtables returned %d\n" , rc);
tools/libxc/include/xc_dom.h +0 -2
@@ -133,7 +133,6 @@ struct xc_dom_image {* Note that the input is offset by rambase. */ xen_pfn_t *p2m_host; -void *p2m_guest;/* physical memory *
@@ -331,7 +330,6 @@ int xc_dom_devicetree_mem(struct xc_dom_image *dom, const void *mem,int xc_dom_parse_image (struct xc_dom_image *dom);int xc_dom_set_arch_hooks (struct xc_dom_image *dom);int xc_dom_build_image (struct xc_dom_image *dom); -int xc_dom_update_guest_p2m (struct xc_dom_image *dom);int xc_dom_boot_xen_init (struct xc_dom_image *dom,xc_interface *xch,uint32_t domid);
tools/libxc/xc_dom_boot.c +0 -2
@@ -197,8 +197,6 @@ int xc_dom_boot_image(struct xc_dom_image *dom)return -1 ;/* initial mm setup */ -if ( (rc =xc_dom_update_guest_p2m (dom)) !=0 ) -return rc;if ( dom->arch_hooks->setup_pgtables && (rc = dom->arch_hooks->setup_pgtables (dom)) !=0 )return rc;
tools/libxc/xc_dom_core.c +0 -40
@@ -969,46 +969,6 @@ int xc_dom_mem_init(struct xc_dom_image *dom, unsigned int mem_mb)return 0 ; } -int xc_dom_update_guest_p2m (struct xc_dom_image *dom) -{ -uint32_t *p2m_32; -uint64_t *p2m_64; -xen_pfn_t i; - -if ( !dom->p2m_guest ) -return 0 ; - -switch ( dom->arch_hooks->sizeof_pfn ) - { -case 4 : -DOMPRINTF ("%s: dst 32bit, pages 0x%" PRIpfn"" , - __FUNCTION__, dom->p2m_size); - p2m_32 = dom->p2m_guest; -for ( i =0 ; i < dom->p2m_size; i++ ) -if ( dom->p2m_host[i] !=INVALID_PFN ) - p2m_32[i] = dom->p2m_host[i]; -else - p2m_32[i] = (uint32_t ) -1 ; -break ; -case 8 : -DOMPRINTF ("%s: dst 64bit, pages 0x%" PRIpfn"" , - __FUNCTION__, dom->p2m_size); - p2m_64 = dom->p2m_guest; -for ( i =0 ; i < dom->p2m_size; i++ ) -if ( dom->p2m_host[i] !=INVALID_PFN ) - p2m_64[i] = dom->p2m_host[i]; -else - p2m_64[i] = (uint64_t ) -1 ; -break ; -default : -xc_dom_panic (dom->xch,XC_INTERNAL_ERROR , -"sizeof_pfn is invalid (is %d, can be 4 or 8)" , - dom->arch_hooks->sizeof_pfn); -return -1 ; - } -return 0 ; -} -static int xc_dom_build_module (struct xc_dom_image *dom,unsigned int mod) {size_t unziplen, modulelen;
tools/libxc/xc_dom_x86.c +35 -6
80 lines not on this page · raw message
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
PATCH 4/4 tools/dombuilder: Don't allocate dom->p2m_host[] for translated domains
In reply to Andrew Cooperxc_dom_p2m() and dom->p2m_host[] implement a linear transform for translated domains, but waste a substantial chunk of RAM doing so.
ARM literally never reads dom->p2m_host[] (because of the xc_dom_translated() short circuit in xc_dom_p2m()). Drop it all.
x86 HVM does use dom->p2m_host[] for xc_domain_populate_physmap_exact() calls when populating 4k pages. Reuse the same tactic from 2M/1G ranges and use an on-stack array instead. Drop the memory allocation.
x86 PV guests do use dom->p2m_host[] as a non-identity transform. Rename the field to pv_p2m to make it clear it is PV-only.
No change in the constructed guests.
---
CC: Ian Jackson <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Varad Gautam <[email protected]>
--- stubdom/grub/kexec.c | 28 ++++++++--------- tools/libxc/include/xc_dom.h | 19 ++++++------ tools/libxc/xc_dom_arm.c | 9 ------ tools/libxc/xc_dom_x86.c | 72 ++++++++++++++++++-------------------------- 4 files changed, 52 insertions(+), 76 deletions(-)
stubdom/grub/kexec.c +14 -14
@@ -87,17 +87,17 @@ static void do_exchange(struct xc_dom_image *dom, xen_pfn_t target_pfn, xen_pfn_xen_pfn_t target_mfn;for (source_pfn =0 ; source_pfn < start_info.nr_pages; source_pfn++) -if (dom->p2m_host[source_pfn] == source_mfn) +if (dom->pv_p2m[source_pfn] == source_mfn)break ;ASSERT (source_pfn < start_info.nr_pages); - target_mfn = dom->p2m_host[target_pfn]; + target_mfn = dom->pv_p2m[target_pfn];/* Put target MFN at source PFN */ - dom->p2m_host[source_pfn] = target_mfn; + dom->pv_p2m[source_pfn] = target_mfn;/* Put source MFN at target PFN */ - dom->p2m_host[target_pfn] = source_mfn; + dom->pv_p2m[target_pfn] = source_mfn; }int kexec_allocate (struct xc_dom_image *dom)
@@ -110,7 +110,7 @@ int kexec_allocate(struct xc_dom_image *dom) pages_moved2pfns =realloc (pages_moved2pfns, new_allocated *sizeof (*pages_moved2pfns));for (i = allocated; i < new_allocated; i++) {/* Exchange old page of PFN i with a newly allocated page. */ -xen_pfn_t old_mfn = dom->p2m_host[i]; +xen_pfn_t old_mfn = dom->pv_p2m[i];xen_pfn_t new_pfn;xen_pfn_t new_mfn;
@@ -122,7 +122,7 @@ int kexec_allocate(struct xc_dom_image *dom)/* * If PFN of newly allocated page (new_pfn) is less then currently * requested PFN (i) then look for relevant PFN/MFN pair. In this -* situation dom->p2m_host[new_pfn] no longer contains proper MFN +* situation dom->pv_p2m[new_pfn] no longer contains proper MFN * because original page with new_pfn was moved earlier * to different location. */
@@ -132,10 +132,10 @@ int kexec_allocate(struct xc_dom_image *dom) pages_moved2pfns[i] = new_pfn;/* Put old page at new PFN */ - dom->p2m_host[new_pfn] = old_mfn; + dom->pv_p2m[new_pfn] = old_mfn;/* Put new page at PFN i */ - dom->p2m_host[i] = new_mfn; + dom->pv_p2m[i] = new_mfn; } allocated = new_allocated;
@@ -282,11 +282,11 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, char dom->p2m_size = dom->total_pages;/* setup initial p2m */ - dom->p2m_host =malloc (sizeof (*dom->p2m_host) * dom->p2m_size); + dom->pv_p2m =malloc (sizeof (*dom->pv_p2m) * dom->p2m_size);/* Start with our current P2M */ for (i =0 ; i < dom->p2m_size; i++) - dom->p2m_host[i] =pfn_to_mfn (i); + dom->pv_p2m[i] =pfn_to_mfn (i);if ( (rc =xc_dom_build_image (dom)) !=0 ) {printk ("xc_dom_build_image returned %d\n" , rc);
@@ -373,7 +373,7 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, char _boot_oldpdmfn =virt_to_mfn (start_info.pt_base);DEBUG ("boot old pd mfn %lx\n" , _boot_oldpdmfn);DEBUG ("boot pd virt %lx\n" , dom->pgtables_seg.vstart); - _boot_pdmfn = dom->p2m_host[PHYS_PFN (dom->pgtables_seg.vstart - dom->parms.virt_base)]; + _boot_pdmfn = dom->pv_p2m[PHYS_PFN (dom->pgtables_seg.vstart - dom->parms.virt_base)];DEBUG ("boot pd mfn %lx\n" , _boot_pdmfn); _boot_stack = _boot_target +PAGE_SIZE ;DEBUG ("boot stack %lx\n" , _boot_stack);
@@ -384,13 +384,13 @@ void kexec(void *kernel, long kernel_size, void *module, long module_size, char/* Keep only useful entries */ for (nr_m2p_updates = pfn =0 ; pfn < start_info.nr_pages; pfn++) -if (dom->p2m_host[pfn] !=pfn_to_mfn (pfn)) +if (dom->pv_p2m[pfn] !=pfn_to_mfn (pfn)) nr_m2p_updates++; m2p_updates =malloc (sizeof (*m2p_updates) * nr_m2p_updates);for (i = pfn =0 ; pfn < start_info.nr_pages; pfn++) -if (dom->p2m_host[pfn] !=pfn_to_mfn (pfn)) { - m2p_updates[i].ptr =PFN_PHYS (dom->p2m_host[pfn]) |MMU_MACHPHYS_UPDATE ; +if (dom->pv_p2m[pfn] !=pfn_to_mfn (pfn)) { + m2p_updates[i].ptr =PFN_PHYS (dom->pv_p2m[pfn]) |MMU_MACHPHYS_UPDATE ; m2p_updates[i].val = pfn; i++; }
tools/libxc/include/xc_dom.h +9 -10
@@ -123,16 +123,12 @@ struct xc_dom_image {/* other state info */ uint32_t f_active[XENFEAT_NR_SUBMAPS ]; +/* -* p2m_host maps guest physical addresses an offset from -* rambase_pfn (see below) into gfns. -* -* For a pure PV guest this means that it maps GPFNs into MFNs for -* a hybrid guest this means that it maps GPFNs to GPFNS. -* -* Note that the input is offset by rambase. +* pv_p2m is specific to x86 PV guests, and maps GFNs to MFNs. It is +* eventually copied into guest context. */ -xen_pfn_t *p2m_host; +xen_pfn_t *pv_p2m;/* physical memory *
@@ -433,9 +429,12 @@ static inline xen_pfn_t xc_dom_p2m(struct xc_dom_image *dom, xen_pfn_t pfn) {if (xc_dom_translated (dom) )return pfn; -if (pfn < dom->rambase_pfn || pfn >= dom->rambase_pfn + dom->total_pages) + +/* x86 PV only now. */ +if ( pfn >= dom->total_pages )return INVALID_MFN ; -return dom->p2m_host[pfn - dom->rambase_pfn]; + +return dom->pv_p2m[pfn]; }#endif /* _XC_DOM_H */
tools/libxc/xc_dom_arm.c +0 -9
@@ -348,9 +348,6 @@ static int populate_guest_memory(struct xc_dom_image *dom, } } -for ( pfn =0 ; pfn < nr_pfns; pfn++ ) - dom->p2m_host[pfn] = base_pfn + pfn; - out:free (extents);return rc <0 ? rc :0 ;
@@ -359,7 +356,6 @@ static int populate_guest_memory(struct xc_dom_image *dom,static int meminit (struct xc_dom_image *dom) {int i, rc; -xen_pfn_t pfn;uint64_t modbase;uint64_t ramsize = (uint64_t )dom->total_pages <<XC_PAGE_SHIFT ;
@@ -423,11 +419,6 @@ static int meminit(struct xc_dom_image *dom)assert (ramsize ==0 );/* Too much RAM is rejected above */ dom->p2m_size = p2m_size; - dom->p2m_host =xc_dom_malloc (dom,sizeof (xen_pfn_t) * p2m_size); -if ( dom->p2m_host ==NULL ) -return -EINVAL ; -for ( pfn =0 ; pfn < p2m_size; pfn++ ) - dom->p2m_host[pfn] =INVALID_PFN ;/* setup initial p2m and allocate guest memory */ for ( i =0 ; i <GUEST_RAM_BANKS && dom->rambank_size[i]; i++ )
tools/libxc/xc_dom_x86.c +29 -43
167 lines not on this page · raw message
Signature · 7 lines
2.11.0 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH 4/4] tools/dombuilder: Don't allocate dom->p2m_host[] for translated domains
Hi,
Quoted 6 lines · Andrew Cooper
xc_dom_p2m()and dom->p2m_host[] implement a linear transform for translated domains, but waste a substantial chunk of RAM doing so.ARM literally never reads dom->p2m_host[] (because of the
xc_dom_translated()short circuit inxc_dom_p2m()). Drop it all.
Quoted 6 lines
x86 HVM does use dom->p2m_host[] for
xc_domain_populate_physmap_exact()calls when populating 4k pages. Reuse the same tactic from 2M/1G ranges and use an on-stack array instead. Drop the memory allocation.x86 PV guests do use dom->p2m_host[] as a non-identity transform. Rename the field to
pv_p2mto make it clear it is PV-only.
Nice cleanup! This will probably make slightly faster guest boot :).
tools/libxc/xc_dom_arm.c static int meminit(struct xc_dom_image *dom) · line 421
Quoted 12 lines
tools/libxc/xc_dom_arm.c +0
-1@@ -359,7 +356,6 @@ static int populate_guest_memory(struct xc_dom_image *dom,static int meminit (struct xc_dom_image *dom) {int i, rc; -xen_pfn_t pfn;uint64_t modbase;uint64_t ramsize = (uint64_t )dom->total_pages <<XC_PAGE_SHIFT ;@@ -423,11 +419,6 @@ static int meminit(struct xc_dom_image *dom)assert (ramsize ==0 );/* Too much RAM is rejected above */ dom->p2m_size = p2m_size;
Do we need to keep p2m_size?
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH 4/4] tools/dombuilder: Don't allocate dom->p2m_host[] for translated domains
Quoted 23 lines · Julien Grall
Hi,
Quoted 14 lines · Andrew Cooper
xc_dom_p2m()and dom->p2m_host[] implement a linear transform for translated
domains, but waste a substantial chunk of RAM doing so.ARM literally never reads dom->p2m_host[] (because of the
xc_dom_translated()
short circuit in xc_dom_p2m()). Drop it all.x86 HVM does use dom->p2m_host[] for
xc_domain_populate_physmap_exact()calls
when populating 4k pages. Reuse the same tactic from 2M/1G ranges and use an
on-stack array instead. Drop the memory allocation.Quoted 3 lines
x86 PV guests do use dom->p2m_host[] as a non-identity transform. Rename the
field topv_p2mto make it clear it is PV-only.Nice cleanup! This will probably make slightly faster guest boot :).
Quoted 13 lines
Quoted 11 lines
tools/libxc/xc_dom_arm.c +0
-1@@ -359,7 +356,6 @@ static int populate_guest_memory(structxc_dom_image *dom, static int meminit(struct xc_dom_image *dom) { int i, rc; - xen_pfn_t pfn; uint64_t modbase; uint64_t ramsize = (uint64_t)dom->total_pages << XC_PAGE_SHIFT;@@ -423,11 +419,6 @@ static int meminit(struct xc_dom_image *dom)assert(ramsize == 0); /* Too much RAM is rejected above */
dom->p2m_size=p2m_size;Do we need to keep
p2m_size?
Yes, I think so.
There are some common checks which would fail if it becomes 0, and importantly, it is used to locate safe gfns for temporary physmap mappings.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH 4/4] tools/dombuilder: Don't allocate dom->p2m_host[] for translated domains
Hi Andrew,
Quoted 38 lines · Andrew Cooper
Quoted 23 lines · Julien Grall
Hi,
Quoted 14 lines · Andrew Cooper
xc_dom_p2m()and dom->p2m_host[] implement a linear transform for translated
domains, but waste a substantial chunk of RAM doing so.ARM literally never reads dom->p2m_host[] (because of the
xc_dom_translated()
short circuit in xc_dom_p2m()). Drop it all.x86 HVM does use dom->p2m_host[] for
xc_domain_populate_physmap_exact()calls
when populating 4k pages. Reuse the same tactic from 2M/1G ranges and use an
on-stack array instead. Drop the memory allocation.Quoted 3 lines
x86 PV guests do use dom->p2m_host[] as a non-identity transform. Rename the
field topv_p2mto make it clear it is PV-only.Nice cleanup! This will probably make slightly faster guest boot :).
Quoted 13 lines
tools/libxc/xc_dom_arm.c static int meminit(struct xc_dom_image *dom) · line 420
Quoted 11 lines
tools/libxc/xc_dom_arm.c +0
-1@@ -359,7 +356,6 @@ static int populate_guest_memory(structxc_dom_image *dom, static int meminit(struct xc_dom_image *dom) { int i, rc; - xen_pfn_t pfn; uint64_t modbase; uint64_t ramsize = (uint64_t)dom->total_pages << XC_PAGE_SHIFT;@@ -423,11 +419,6 @@ static int meminit(struct xc_dom_image *dom) assert(ramsize == 0); /* Too much RAM is rejected above */ dom->p2m_size = p2m_size;Do we need to keep
p2m_size?
Quoted 4 lines
Yes, I think so.
There are some common checks which would fail if it becomes 0, and importantly, it is used to locate safe gfns for temporary physmap mappings.
Do you mean the scratch page? If so, on Arm we use a fix address in the memory map rather than p2m_size.
I have looked at the usage of the p2m_size in the common code and I didn't spot any path that can be used by Arm and using p2m_size.
Also, I don't think p2m_size is calculated correctly on Arm. It only englobe the RAM and doesn't take into account the rest of the mappings (e.g MMIO...). So I am not sure how this could be used in common code.
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Julien Grall
Acked-byRe: [Xen-devel] [PATCH 4/4] tools/dombuilder: Don't allocate dom->p2m_host[] for translated domains
Hi,
Quoted 43 lines · Julien Grall
Hi Andrew,
Quoted 40 lines · Andrew Cooper
Quoted 23 lines · Julien Grall
Hi,
Quoted 14 lines · Andrew Cooper
xc_dom_p2m()and dom->p2m_host[] implement a linear transform for translated
domains, but waste a substantial chunk of RAM doing so.ARM literally never reads dom->p2m_host[] (because of the
xc_dom_translated()
short circuit in xc_dom_p2m()). Drop it all.x86 HVM does use dom->p2m_host[] for
xc_domain_populate_physmap_exact()calls
when populating 4k pages. Reuse the same tactic from 2M/1G ranges and use an
on-stack array instead. Drop the memory allocation.Quoted 3 lines
x86 PV guests do use dom->p2m_host[] as a non-identity transform. Rename the
field topv_p2mto make it clear it is PV-only.Nice cleanup! This will probably make slightly faster guest boot :).
Quoted 13 lines
Quoted 11 lines
tools/libxc/xc_dom_arm.c +0
-1@@ -359,7 +356,6 @@ static int populate_guest_memory(structxc_dom_image *dom, static int meminit(struct xc_dom_image *dom) { int i, rc; - xen_pfn_t pfn; uint64_t modbase; uint64_t ramsize = (uint64_t)dom->total_pages << XC_PAGE_SHIFT;@@ -423,11 +419,6 @@ static int meminit(struct xc_dom_image *dom)assert(ramsize == 0); /* Too much RAM is rejected above */
dom->p2m_size=p2m_size;Do we need to keep
p2m_size?Yes, I think so.
Quoted 8 lines
Quoted 2 lines
There are some common checks which would fail if it becomes 0, and importantly, it is used to locate safe gfns for temporary physmap mappings.
Do you mean the scratch page? If so, on Arm we use a fix address in the memory map rather than
p2m_size.I have looked at the usage of the
p2m_sizein the common code and I didn't spot any path that can be used by Arm and usingp2m_size.Also, I don't think
p2m_sizeis calculated correctly on Arm. It only englobe the RAM and doesn't take into account the rest of the mappings (e.g MMIO...). So I am not sure how this could be used in common code.
Thinking a bit more of this. As the p2m_size was IHMO already buggy, it should not make any difference after this series. Therefore removing p2m_size can be probably done on a follow-up patch.
So I am happy with the patch as-is:
Cheers,
Signature · 6 lines
Julien Grall _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH 4/4] tools/dombuilder: Don't allocate dom->p2m_host[] for translated domains
In reply to Andrew Coopertools/libxc/include/xc_dom.h struct xc_dom_image { · line 128
Quoted 10 lines · Andrew Cooper
tools/libxc/include/xc_dom.h +1
-2@@ -123,16 +123,12 @@ struct xc_dom_image {/* other state info */ uint32_t f_active[XENFEAT_NR_SUBMAPS ]; +/* -* p2m_host maps guest physical addresses an offset from -* rambase_pfn (see below) into gfns.
The removal of this part of the comment and ...
Quoted 15 lines
tools/libxc/include/xc_dom.h +3
-5-* For a pure PV guest this means that it maps GPFNs into MFNs for -* a hybrid guest this means that it maps GPFNs to GPFNS. -* -* Note that the input is offset by rambase. +* pv_p2m is specific to x86 PV guests, and maps GFNs to MFNs. It is +* eventually copied into guest context. */ -xen_pfn_t *p2m_host; +xen_pfn_t *pv_p2m;/* physical memory * @@ -433,9 +429,12 @@ static inline xen_pfn_t xc_dom_p2m(struct xc_dom_image *dom, xen_pfn_t pfn) {if (xc_dom_translated (dom) )
tools/libxc/include/xc_dom.h static inline xen_pfn_t xc_dom_p2m(struct xc_dom_image *dom, xen_pfn_t pfn) · line 438
Quoted 10 lines
tools/libxc/include/xc_dom.h +5
-2return pfn; -if (pfn < dom->rambase_pfn || pfn >= dom->rambase_pfn + dom->total_pages) + +/* x86 PV only now. */ +if ( pfn >= dom->total_pages )return INVALID_MFN ; -return dom->p2m_host[pfn - dom->rambase_pfn]; + +return dom->pv_p2m[pfn]; }
... the dropping of all uses of rambase_pfn here make it look like you're doing away with that concept altogether. Is this really correct? If so, I guess you want to
- say a word in this regard in the description, the more that you don't fully get rid of this (the structure field and some uses elsewhere remain),
- drop/adjust the respective comment fragment next to the field a little further down in the structure.
tools/libxc/include/xc_dom.h static int meminit_pv(struct xc_dom_image *dom) · line 1248
Quoted 7 lines
tools/libxc/include/xc_dom.h +1
-2@@ -1245,11 +1245,11 @@ static int meminit_pv(struct xc_dom_image *dom)return -EINVAL ; } - dom->p2m_host =xc_dom_malloc (dom,sizeof (xen_pfn_t) * dom->p2m_size); -if ( dom->p2m_host ==NULL ) + dom->pv_p2m =xc_dom_malloc (dom,sizeof (xen_pfn_t) * dom->p2m_size);
Since you're touching the line anyway, perhaps better sizeof(*dom->pv_p2m)?
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH 4/4] tools/dombuilder: Don't allocate dom->p2m_host[] for translated domains
Quoted 33 lines · Jan Beulich
tools/libxc/include/xc_dom.h struct xc_dom_image { · line 128
Quoted 10 lines · Andrew Cooper
tools/libxc/include/xc_dom.h +1
-2@@ -123,16 +123,12 @@ struct xc_dom_image {/* other state info */ uint32_t f_active[XENFEAT_NR_SUBMAPS ]; +/* -* p2m_host maps guest physical addresses an offset from -* rambase_pfn (see below) into gfns. The removal of this part of the comment and ...
Quoted 20 lines
tools/libxc/include/xc_dom.h +6
-6-* For a pure PV guest this means that it maps GPFNs into MFNs for -* a hybrid guest this means that it maps GPFNs to GPFNS. -* -* Note that the input is offset by rambase. +* pv_p2m is specific to x86 PV guests, and maps GFNs to MFNs. It is +* eventually copied into guest context. */ -xen_pfn_t *p2m_host; +xen_pfn_t *pv_p2m;/* physical memory * @@ -433,9 +429,12 @@ static inline xen_pfn_t xc_dom_p2m(struct xc_dom_image *dom, xen_pfn_t pfn) {if (xc_dom_translated (dom) )return pfn; -if (pfn < dom->rambase_pfn || pfn >= dom->rambase_pfn + dom->total_pages) + +/* x86 PV only now. */ +if ( pfn >= dom->total_pages )
Quoted 8 lines
tools/libxc/include/xc_dom.h static inline xen_pfn_t xc_dom_p2m(struct xc_dom_image *dom, xen_pfn_t pfn) · line 438
Quoted 5 lines
tools/libxc/include/xc_dom.h +2
-1return INVALID_MFN ; -return dom->p2m_host[pfn - dom->rambase_pfn]; + +return dom->pv_p2m[pfn]; }... the dropping of all uses of
rambase_pfnhere make it look like you're doing away with that concept altogether. Is this really correct?
Well - it is effectively dead code here, because of the xc_dom_translated() in context above, and it being 0 outside of ARM.
The (nonzero) value is used by other bits of ARM code.
Quoted 6 lines
If so, I guess you want to
- say a word in this regard in the description, the more that you don't fully get rid of this (the structure field and some uses elsewhere remain),
- drop/adjust the respective comment fragment next to the field a little further down in the structure.
The domain builder is made almost exclusively of bitrot, but I don't have an ARM system to do any testing on. Given how fragile the code is, I'm not comfortable doing speculative deletion of code I'm not certain is unused.
Quoted 10 lines
tools/libxc/include/xc_dom.h static int meminit_pv(struct xc_dom_image *dom) · line 1248
Quoted 8 lines
tools/libxc/include/xc_dom.h +1
-2@@ -1245,11 +1245,11 @@ static int meminit_pv(struct xc_dom_image *dom)return -EINVAL ; } - dom->p2m_host =xc_dom_malloc (dom,sizeof (xen_pfn_t) * dom->p2m_size); -if ( dom->p2m_host ==NULL ) + dom->pv_p2m =xc_dom_malloc (dom,sizeof (xen_pfn_t) * dom->p2m_size);Since you're touching the line anyway, perhaps better
sizeof(*dom->pv_p2m)?
Will fix.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Re: [Xen-devel] [PATCH 4/4] tools/dombuilder: Don't allocate dom->p2m_host[] for translated domains
Quoted 55 lines · Andrew Cooper
Quoted 33 lines · Jan Beulich
tools/libxc/include/xc_dom.h struct xc_dom_image { · line 128
Quoted 10 lines · Andrew Cooper
tools/libxc/include/xc_dom.h +1
-2@@ -123,16 +123,12 @@ struct xc_dom_image {/* other state info */ uint32_t f_active[XENFEAT_NR_SUBMAPS ]; +/* -* p2m_host maps guest physical addresses an offset from -* rambase_pfn (see below) into gfns. The removal of this part of the comment and ...
Quoted 20 lines
tools/libxc/include/xc_dom.h +6
-6-* For a pure PV guest this means that it maps GPFNs into MFNs for -* a hybrid guest this means that it maps GPFNs to GPFNS. -* -* Note that the input is offset by rambase. +* pv_p2m is specific to x86 PV guests, and maps GFNs to MFNs. It is +* eventually copied into guest context. */ -xen_pfn_t *p2m_host; +xen_pfn_t *pv_p2m;/* physical memory * @@ -433,9 +429,12 @@ static inline xen_pfn_t xc_dom_p2m(struct xc_dom_image *dom, xen_pfn_t pfn) {if (xc_dom_translated (dom) )return pfn; -if (pfn < dom->rambase_pfn || pfn >= dom->rambase_pfn + dom->total_pages) + +/* x86 PV only now. */ +if ( pfn >= dom->total_pages )Quoted 8 lines
tools/libxc/include/xc_dom.h static inline xen_pfn_t xc_dom_p2m(struct xc_dom_image *dom, xen_pfn_t pfn) · line 438
Quoted 5 lines
tools/libxc/include/xc_dom.h +2
-1return INVALID_MFN ; -return dom->p2m_host[pfn - dom->rambase_pfn]; + +return dom->pv_p2m[pfn]; }... the dropping of all uses of
rambase_pfnhere make it look like you're doing away with that concept altogether. Is this really correct?Well - it is effectively dead code here, because of the
xc_dom_translated()in context above, and it being 0 outside of ARM.The (nonzero) value is used by other bits of ARM code.
Quoted 6 lines
If so, I guess you want to
- say a word in this regard in the description, the more that you don't fully get rid of this (the structure field and some uses elsewhere remain),
- drop/adjust the respective comment fragment next to the field a little further down in the structure.
Quoted 4 lines
The domain builder is made almost exclusively of bitrot, but I don't have an ARM system to do any testing on. Given how fragile the code is, I'm not comfortable doing speculative deletion of code I'm not certain is unused.
My remark was about this (non-Arm) part of the comment:
* An x86 PV guest has one or more blocks of physical RAM,
* consisting of total_pages starting at rambase_pfn. The start
* address and size of each block is controlled by vNUMA
* structures.
I did in no way mean to ask for speculative deletion of code.
Jan
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 7 lines · Andrew Cooper
Vastly drop xl's memory usage for HVM (x86 and ARM) guest construction.
See
https://lore.kernel.org/xen-devel/[email protected]/T/#u
for the origins of this work, but ultimately I think this is a far cleaner solution to the problem.
Quoted 6 lines
Andrew Cooper (4):
tools/dombuilder:xc_dom_x86cleanuptools/dombuilder: Remove PV-only, mandatory hookstools/dombuilder: Removep2m_guestfrom the common interfacetools/dombuilder: Don't allocate dom->p2m_host[] for translated
domains
The code looks good to me.
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel