From: "Jan Beulich" Subject: [PATCH] x86-64: properly handle alias mappings beyond _end Date: Tue, 12 Jul 2011 16:18:07 +0100 Message-ID: <4E1C81CF020000780004D2E4@nat28.tlf.novell.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartE0CFBFBF.0__=" Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "xen-devel@lists.xensource.com" 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. --=__PartE0CFBFBF.0__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Changeset 19632:b0966b6f5180 wasn't really complete: The Xen image mapping doesn't end at _end, but a full 16Mb gets mapped during boot (and never got unmapped so far), hence all of this space was subject to alias mappings when it comes to cache attribute changes. Unmap all full large pages between _end and the 16Mb boundary, and include all other pages beyond _end when checking for aliases. Signed-off-by: Jan Beulich --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -805,7 +805,7 @@ static int update_xen_mappings(unsigned=20 int err =3D 0; #ifdef __x86_64__ bool_t alias =3D mfn >=3D PFN_DOWN(xen_phys_start) && - mfn < PFN_UP(xen_phys_start + (unsigned long)_end - XEN_VIRT_STAR= T); + mfn < PFN_UP(xen_phys_start + xen_virt_end - XEN_VIRT_START); unsigned long xen_va =3D XEN_VIRT_START + ((mfn - PFN_DOWN(xen_phys_start)) << PAGE_SHIFT);= =20 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -94,6 +94,8 @@ unsigned long __read_mostly xen_phys_sta /* Limits of Xen heap, used to initialise the allocator. */ unsigned long __initdata xenheap_initial_phys_start; unsigned long __read_mostly xenheap_phys_end; +#else +unsigned long __read_mostly xen_virt_end; #endif =20 DEFINE_PER_CPU(struct tss_struct, init_tss); @@ -1094,6 +1096,9 @@ void __init __start_xen(unsigned long mb map_pages_to_xen((unsigned long)__va(kexec_crash_area.start), kexec_crash_area.start >> PAGE_SHIFT, PFN_UP(kexec_crash_area.size), PAGE_HYPERVISOR); + xen_virt_end =3D ((unsigned long)_end + (1UL << L2_PAGETABLE_SHIFT) - = 1) & + ~((1UL << L2_PAGETABLE_SHIFT) - 1); + destroy_xen_mappings(xen_virt_end, XEN_VIRT_START + BOOTSTRAP_MAP_BASE= ); #endif =20 memguard_init(); --- a/xen/include/asm-x86/x86_64/page.h +++ b/xen/include/asm-x86/x86_64/page.h @@ -35,6 +35,8 @@ #include #include =20 +extern unsigned long xen_virt_end; + extern unsigned long max_pdx; extern unsigned long pfn_pdx_bottom_mask, ma_va_bottom_mask; extern unsigned int pfn_pdx_hole_shift; --=__PartE0CFBFBF.0__= Content-Type: text/plain; name="x86_64-image-map-bounds.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="x86_64-image-map-bounds.patch" Changeset 19632:b0966b6f5180 wasn't really complete: The Xen image=0Amappin= g doesn't end at _end, but a full 16Mb gets mapped during boot=0A(and = never got unmapped so far), hence all of this space was subject=0Ato alias = mappings when it comes to cache attribute changes. Unmap all=0Afull large = pages between _end and the 16Mb boundary, and include all=0Aother pages = beyond _end when checking for aliases.=0A=0ASigned-off-by: Jan Beulich = =0A=0A--- a/xen/arch/x86/mm.c=0A+++ b/xen/arch/x86/mm.= c=0A@@ -805,7 +805,7 @@ static int update_xen_mappings(unsigned =0A = int err =3D 0;=0A #ifdef __x86_64__=0A bool_t alias =3D mfn >=3D = PFN_DOWN(xen_phys_start) &&=0A- mfn < PFN_UP(xen_phys_start + = (unsigned long)_end - XEN_VIRT_START);=0A+ mfn < PFN_UP(xen_phys_st= art + xen_virt_end - XEN_VIRT_START);=0A unsigned long xen_va =3D=0A = XEN_VIRT_START + ((mfn - PFN_DOWN(xen_phys_start)) << PAGE_SHIFT);=0A= =0A--- a/xen/arch/x86/setup.c=0A+++ b/xen/arch/x86/setup.c=0A@@ -94,6 = +94,8 @@ unsigned long __read_mostly xen_phys_sta=0A /* Limits of Xen = heap, used to initialise the allocator. */=0A unsigned long __initdata = xenheap_initial_phys_start;=0A unsigned long __read_mostly xenheap_phys_end= ;=0A+#else=0A+unsigned long __read_mostly xen_virt_end;=0A #endif=0A =0A = DEFINE_PER_CPU(struct tss_struct, init_tss);=0A@@ -1094,6 +1096,9 @@ void = __init __start_xen(unsigned long mb=0A map_pages_to_xen((unsigned = long)__va(kexec_crash_area.start),=0A kexec_crash_area= .start >> PAGE_SHIFT,=0A PFN_UP(kexec_crash_area.size)= , PAGE_HYPERVISOR);=0A+ xen_virt_end =3D ((unsigned long)_end + (1UL << = L2_PAGETABLE_SHIFT) - 1) &=0A+ ~((1UL << L2_PAGETABLE_SHI= FT) - 1);=0A+ destroy_xen_mappings(xen_virt_end, XEN_VIRT_START + = BOOTSTRAP_MAP_BASE);=0A #endif=0A =0A memguard_init();=0A--- a/xen/incl= ude/asm-x86/x86_64/page.h=0A+++ b/xen/include/asm-x86/x86_64/page.h=0A@@ = -35,6 +35,8 @@=0A #include =0A #include =0A = =0A+extern unsigned long xen_virt_end;=0A+=0A extern unsigned long = max_pdx;=0A extern unsigned long pfn_pdx_bottom_mask, ma_va_bottom_mask;=0A= extern unsigned int pfn_pdx_hole_shift;=0A --=__PartE0CFBFBF.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.xensource.com http://lists.xensource.com/xen-devel --=__PartE0CFBFBF.0__=--