From: "Jan Beulich" Subject: Ping: [PATCH] libxc/x86: fix page table creation for huge guests Date: Mon, 09 Sep 2013 09:37:09 +0100 Message-ID: <522DA4D502000078000F162B@nat28.tlf.novell.com> References: <20120801155040.GB15812@phenom.dumpdata.com> <501A5EF7020000780009219C@nat28.tlf.novell.com> <20120802141710.GF16749@phenom.dumpdata.com> <20120802160403.02de484e@mantra.us.oracle.com> <20120803133001.GA13750@andromeda.dapyr.net> <501BF44602000078000928B4@nat28.tlf.novell.com> <5028CEE70200007800094623@nat28.tlf.novell.com> <20130827203430.GA16578@phenom.dumpdata.com> <521DC91B02000078000EEFD9@nat28.tlf.novell.com> <20130828144419.GA16368@phenom.dumpdata.com> <521E2C4402000078000EF223@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VIwyB-0004hb-Vl for xen-devel@lists.xenproject.org; Mon, 09 Sep 2013 08:37:16 +0000 In-Reply-To: <521E2C4402000078000EF223@nat28.tlf.novell.com> Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Campbell , Ian Jackson Cc: xen-devel List-Id: xen-devel@lists.xenproject.org Ping? >>> On 28.08.13 at 16:58, "Jan Beulich" wrote: > The switch-over logic from one page directory to the next was wrong; > it needs to be deferred until we actually reach the last page within > a given region, instead of being done when the last entry of a page > directory gets started with. > > Signed-off-by: Jan Beulich > Tested-by: Konrad Rzeszutek Wilk > > --- a/tools/libxc/xc_dom_x86.c > +++ b/tools/libxc/xc_dom_x86.c > @@ -251,7 +251,7 @@ static int setup_pgtables_x86_32_pae(str > l3_pgentry_64_t *l3tab; > l2_pgentry_64_t *l2tab = NULL; > l1_pgentry_64_t *l1tab = NULL; > - unsigned long l3off, l2off, l1off; > + unsigned long l3off, l2off = 0, l1off; > xen_vaddr_t addr; > xen_pfn_t pgpfn; > xen_pfn_t l3mfn = xc_dom_p2m_guest(dom, l3pfn); > @@ -299,8 +299,6 @@ static int setup_pgtables_x86_32_pae(str > l2off = l2_table_offset_pae(addr); > l2tab[l2off] = > pfn_to_paddr(xc_dom_p2m_guest(dom, l1pfn)) | L2_PROT; > - if ( l2off == (L2_PAGETABLE_ENTRIES_PAE - 1) ) > - l2tab = NULL; > l1pfn++; > } > > @@ -312,8 +310,13 @@ static int setup_pgtables_x86_32_pae(str > if ( (addr >= dom->pgtables_seg.vstart) && > (addr < dom->pgtables_seg.vend) ) > l1tab[l1off] &= ~_PAGE_RW; /* page tables are r/o */ > + > if ( l1off == (L1_PAGETABLE_ENTRIES_PAE - 1) ) > + { > l1tab = NULL; > + if ( l2off == (L2_PAGETABLE_ENTRIES_PAE - 1) ) > + l2tab = NULL; > + } > } > > if ( dom->virt_pgtab_end <= 0xc0000000 ) > @@ -360,7 +363,7 @@ static int setup_pgtables_x86_64(struct > l3_pgentry_64_t *l3tab = NULL; > l2_pgentry_64_t *l2tab = NULL; > l1_pgentry_64_t *l1tab = NULL; > - uint64_t l4off, l3off, l2off, l1off; > + uint64_t l4off, l3off = 0, l2off = 0, l1off; > uint64_t addr; > xen_pfn_t pgpfn; > > @@ -391,8 +394,6 @@ static int setup_pgtables_x86_64(struct > l3off = l3_table_offset_x86_64(addr); > l3tab[l3off] = > pfn_to_paddr(xc_dom_p2m_guest(dom, l2pfn)) | L3_PROT; > - if ( l3off == (L3_PAGETABLE_ENTRIES_X86_64 - 1) ) > - l3tab = NULL; > l2pfn++; > } > > @@ -405,8 +406,6 @@ static int setup_pgtables_x86_64(struct > l2off = l2_table_offset_x86_64(addr); > l2tab[l2off] = > pfn_to_paddr(xc_dom_p2m_guest(dom, l1pfn)) | L2_PROT; > - if ( l2off == (L2_PAGETABLE_ENTRIES_X86_64 - 1) ) > - l2tab = NULL; > l1pfn++; > } > > @@ -418,8 +417,17 @@ static int setup_pgtables_x86_64(struct > if ( (addr >= dom->pgtables_seg.vstart) && > (addr < dom->pgtables_seg.vend) ) > l1tab[l1off] &= ~_PAGE_RW; /* page tables are r/o */ > + > if ( l1off == (L1_PAGETABLE_ENTRIES_X86_64 - 1) ) > + { > l1tab = NULL; > + if ( l2off == (L2_PAGETABLE_ENTRIES_X86_64 - 1) ) > + { > + l2tab = NULL; > + if ( l3off == (L3_PAGETABLE_ENTRIES_X86_64 - 1) ) > + l3tab = NULL; > + } > + } > } > return 0; >