From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH] libxc: x86: ensure that the initial mapping fits into the guest's memory Date: Mon, 7 Jan 2013 11:39:40 +0000 Message-ID: <1357558780.7989.43.camel@zakaz.uk.xensource.com> References: <1357318360.14291.93.camel@zakaz.uk.xensource.com> <50EAB2F402000078000B352B@nat28.tlf.novell.com> <1357555056.14291.142.camel@zakaz.uk.xensource.com> <50EABA2302000078000B357F@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <50EABA2302000078000B357F@nat28.tlf.novell.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Jan Beulich Cc: Ian Jackson , Wei Liu , "xen-devel@lists.xen.org" List-Id: xen-devel@lists.xenproject.org On Mon, 2013-01-07 at 11:05 +0000, Jan Beulich wrote: > >> The 4.1.3 xl doesn't really want to work > >> for me, so I can't directly cross check whether there's a behavioral > >> difference between the two, but looking at an older log the virtual > >> addresses reported for virt_alloc_end look similar. Afaict you need > >> to subtract dom->parms.virt_base from try_virt_end. > > > > I bet virt_base == 0 for the mini-os kernel I tried. I'll respin and > > retest. > > This is what works for me (also added printing of the relevant value, > and dropping the unchanged parts of the patch): This looks sensible to me, thanks. I shall respin the complete patch shortly. Ian. > > --- a/tools/libxc/xc_dom_x86.c > +++ b/tools/libxc/xc_dom_x86.c > @@ -82,6 +82,7 @@ static int count_pgtables(struct xc_dom_ > { > int pages, extra_pages; > xen_vaddr_t try_virt_end; > + xen_pfn_t try_pfn_end; > > extra_pages = dom->alloc_bootstack ? 1 : 0; > extra_pages += dom->extra_pages; > @@ -91,6 +92,16 @@ static int count_pgtables(struct xc_dom_ > { > try_virt_end = round_up(dom->virt_alloc_end + pages * PAGE_SIZE_X86, > bits_to_mask(22)); /* 4MB alignment */ > + try_pfn_end = (try_virt_end - dom->parms.virt_base) >> PAGE_SHIFT_X86; > + > + if ( try_pfn_end > dom->total_pages ) > + { > + xc_dom_panic(dom->xch, XC_OUT_OF_MEMORY, > + "%s: not enough memory for initial mapping (%#"PRIpfn" > %#"PRIpfn")", > + __FUNCTION__, try_pfn_end, dom->total_pages); > + return -ENOMEM; > + } > + > dom->pg_l4 = > nr_page_tables(dom, dom->parms.virt_base, try_virt_end, l4_bits); > dom->pg_l3 = > > Jan >