Skip to contentSkip to conversation

libxc: correct memory range check in domain builder

PATCH In review Juergen Gross 3 participants 3 messages Feb 8, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 libxc: correct memory range check in domain builder

Commit 81a76e4b12961a9f54f5021809074196dfe6dbba ("libxc: rework of domain builder's page table handler") introduced a regression with checking the required memory size of the domain. The needed maximum pfn of the initial kernel mapping was added to the currently last used pfn resulting in doubling the estimated memory need.

Correct the calculation of the last needed pfn to enable booting of small domains again.

---
 tools/libxc/xc_dom_x86.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
tools/libxc/xc_dom_x86.c +2 -3
index 2a3f64b..ac4dae5 100644
@@ -164,7 +164,7 @@ static int count_pgtables(struct xc_dom_image *dom, xen_vaddr_t from,
 
     for ( l = domx86->params->levels - 1; l >= 0; l-- )
     {
-        map->lvls[l].pfn = pfn + map->area.pgtables;
+        map->lvls[l].pfn = dom->pfn_alloc_end + map->area.pgtables;
         if ( l == domx86->params->levels - 1 )
         {
             /* Top level page table in first mapping only. */
@@ -238,8 +238,7 @@ static int alloc_pgtables(struct xc_dom_image *dom)
         try_virt_end = round_up(dom->virt_alloc_end + pages * PAGE_SIZE_X86,
                                 bits_to_mask(22)); /* 4MB alignment */
 
-        if ( count_pgtables(dom, dom->parms.virt_base, try_virt_end,
-                            dom->pfn_alloc_end) )
+        if ( count_pgtables(dom, dom->parms.virt_base, try_virt_end, 0) )
             return -1;
 
         pages = map->area.pgtables + extra_pages;
Signature · 1 line
2.6.2
Tested-by on v1 1/1
#1 lore raw
Quoted 11 lines · Juergen Gross

Commit 81a76e4b12961a9f54f5021809074196dfe6dbba ("libxc: rework of domain builder's page table handler") introduced a regression with checking the required memory size of the domain. The needed maximum pfn of the initial kernel mapping was added to the currently last used pfn resulting in doubling the estimated memory need.

Correct the calculation of the last needed pfn to enable booting of small domains again.

It works for me, using xl. I have not try with the full stack (openstack/libvirt), but I expect it to work.

Thanks,

Signature · 1 line
Anthony PERARD
#2 lore raw
Quoted 10 lines · Anthony PERARD
Quoted 9 lines · Juergen Gross

Commit 81a76e4b12961a9f54f5021809074196dfe6dbba ("libxc: rework of domain builder's page table handler") introduced a regression with checking the required memory size of the domain. The needed maximum pfn of the initial kernel mapping was added to the currently last used pfn resulting in doubling the estimated memory need.

Correct the calculation of the last needed pfn to enable booting of small domains again.

Quoted 7 lines
Quoted 2 lines

It works for me, using xl. I have not try with the full stack (openstack/libvirt), but I expect it to work.

thanks, acked + applied.