From: "Jan Beulich" Subject: [PATCH] x86/32-on-64: adjust Dom0 initial page table layout Date: Mon, 03 Sep 2012 07:58:07 +0100 Message-ID: <5044711F020000780009821F@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartC7F6DEEF.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: xen-devel Cc: Konrad Rzeszutek Wilk List-Id: xen-devel@lists.xenproject.org This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=__PartC7F6DEEF.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Drop the unnecessary reservation of the L4 page for 32on64 Dom0, and allocate its L3 first (to match behavior when running identical bit- width hypervisor and Dom0 kernel). Reported-by: Konrad Rzeszutek Wilk Signed-off-by: Jan Beulich --- a/xen/arch/x86/domain_build.c +++ b/xen/arch/x86/domain_build.c @@ -510,7 +510,7 @@ int __init construct_dom0( #define NR(_l,_h,_s) \ (((((_h) + ((1UL<<(_s))-1)) & ~((1UL<<(_s))-1)) - \ ((_l) & ~((1UL<<(_s))-1))) >> (_s)) - if ( (1 + /* # L4 */ + if ( (!is_pv_32on64_domain(d) + /* # L4 */ NR(v_start, v_end, L4_PAGETABLE_SHIFT) + /* # L3 */ (!is_pv_32on64_domain(d) ? NR(v_start, v_end, L3_PAGETABLE_SHIFT) : /* # L2 */ @@ -756,6 +756,8 @@ int __init construct_dom0( panic("Not enough RAM for domain 0 PML4.\n"); page->u.inuse.type_info =3D PGT_l4_page_table|PGT_validated|1; l4start =3D l4tab =3D page_to_virt(page); + maddr_to_page(mpt_alloc)->u.inuse.type_info =3D PGT_l3_page_table;= + l3start =3D __va(mpt_alloc); mpt_alloc +=3D PAGE_SIZE; } copy_page(l4tab, idle_pg_table); l4tab[0] =3D l4e_empty(); /* zap trampoline mapping */ @@ -787,9 +789,13 @@ int __init construct_dom0( l2tab +=3D l2_table_offset(v_start); if ( !((unsigned long)l3tab & (PAGE_SIZE-1)) ) { - maddr_to_page(mpt_alloc)->u.inuse.type_info =3D - PGT_l3_page_table; - l3start =3D l3tab =3D __va(mpt_alloc); mpt_alloc +=3D = PAGE_SIZE; + if ( count || !l3start ) + { + maddr_to_page(mpt_alloc)->u.inuse.type_info =3D + PGT_l3_page_table; + l3start =3D __va(mpt_alloc); mpt_alloc +=3D = PAGE_SIZE; + } + l3tab =3D l3start; clear_page(l3tab); if ( count =3D=3D 0 ) l3tab +=3D l3_table_offset(v_start); @@ -938,7 +944,7 @@ int __init construct_dom0( if ( !vinitrd_start && initrd_len ) si->flags |=3D SIF_MOD_START_PFN; si->flags |=3D (xen_processor_pmbits << 8) & SIF_PM_MASK; - si->pt_base =3D vpt_start + 2 * PAGE_SIZE * !!is_pv_32on64_domain= (d); + si->pt_base =3D vpt_start; si->nr_pt_frames =3D nr_pt_pages; si->mfn_list =3D vphysmap_start; snprintf(si->magic, sizeof(si->magic), "xen-3.0-x86_%d%s", --=__PartC7F6DEEF.0__= Content-Type: text/plain; name="32on64-bogus-pt_base-adjust.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="32on64-bogus-pt_base-adjust.patch" x86/32-on-64: adjust Dom0 initial page table layout=0A=0ADrop the = unnecessary reservation of the L4 page for 32on64 Dom0, and=0Aallocate its = L3 first (to match behavior when running identical bit-=0Awidth hypervisor = and Dom0 kernel).=0A=0AReported-by: Konrad Rzeszutek Wilk =0ASigned-off-by: Jan Beulich =0A=0A--- = a/xen/arch/x86/domain_build.c=0A+++ b/xen/arch/x86/domain_build.c=0A@@ = -510,7 +510,7 @@ int __init construct_dom0(=0A #define NR(_l,_h,_s) \=0A = (((((_h) + ((1UL<<(_s))-1)) & ~((1UL<<(_s))-1)) - \=0A ((_l) & = ~((1UL<<(_s))-1))) >> (_s))=0A- if ( (1 + /* # L4 */=0A+ if = ( (!is_pv_32on64_domain(d) + /* # L4 */=0A NR(v_start, = v_end, L4_PAGETABLE_SHIFT) + /* # L3 */=0A (!is_pv_32on64_dom= ain(d) ?=0A NR(v_start, v_end, L3_PAGETABLE_SHIFT) : /* # = L2 */=0A@@ -756,6 +756,8 @@ int __init construct_dom0(=0A = panic("Not enough RAM for domain 0 PML4.\n");=0A page->u.inuse.type= _info =3D PGT_l4_page_table|PGT_validated|1;=0A l4start =3D l4tab = =3D page_to_virt(page);=0A+ maddr_to_page(mpt_alloc)->u.inuse.type_i= nfo =3D PGT_l3_page_table;=0A+ l3start =3D __va(mpt_alloc); = mpt_alloc +=3D PAGE_SIZE;=0A }=0A copy_page(l4tab, idle_pg_table);= =0A l4tab[0] =3D l4e_empty(); /* zap trampoline mapping */=0A@@ -787,9 = +789,13 @@ int __init construct_dom0(=0A l2tab +=3D = l2_table_offset(v_start);=0A if ( !((unsigned long)l3tab & = (PAGE_SIZE-1)) )=0A {=0A- maddr_to_page(= mpt_alloc)->u.inuse.type_info =3D=0A- PGT_l3_page_ta= ble;=0A- l3start =3D l3tab =3D __va(mpt_alloc); = mpt_alloc +=3D PAGE_SIZE;=0A+ if ( count || !l3start = )=0A+ {=0A+ maddr_to_page(mpt_all= oc)->u.inuse.type_info =3D=0A+ PGT_l3_page_table= ;=0A+ l3start =3D __va(mpt_alloc); mpt_alloc +=3D = PAGE_SIZE;=0A+ }=0A+ l3tab =3D = l3start;=0A clear_page(l3tab);=0A = if ( count =3D=3D 0 )=0A l3tab +=3D l3_table_offset= (v_start);=0A@@ -938,7 +944,7 @@ int __init construct_dom0(=0A if ( = !vinitrd_start && initrd_len )=0A si->flags |=3D SIF_MOD_START_PF= N;=0A si->flags |=3D (xen_processor_pmbits << 8) & SIF_PM_MASK;= =0A- si->pt_base =3D vpt_start + 2 * PAGE_SIZE * !!is_pv_32on64_dom= ain(d);=0A+ si->pt_base =3D vpt_start;=0A si->nr_pt_frames =3D = nr_pt_pages;=0A si->mfn_list =3D vphysmap_start;=0A snprintf(si= ->magic, sizeof(si->magic), "xen-3.0-x86_%d%s",=0A --=__PartC7F6DEEF.0__= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel --=__PartC7F6DEEF.0__=--