From: "Jan Beulich" Subject: [PATCH] x86-64: also handle virtual aliases of Xen imiage pages Date: Wed, 20 May 2009 14:33:19 +0100 Message-ID: <4A1422BF0200007800001CB4@vpn.id2.novell.com> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Return-path: Content-Disposition: inline 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 With the unification of the heaps, the pages freed from the Xen boot image now can also end up being allocated to a domain, and hence the respective aliases need handling when such pages get their cacheability attributes changed. Rather than establishing multiple mappings with non-WB attributes (which temporarily still can cause aliasing issues), simply unmap those pages from the Xen virtual space, and re-map them (to allow re- establishing of eventual large page mappings) when the cachability attribute for them gets restored to normal (WB). Signed-off-by: Jan Beulich --- 2009-05-19.orig/xen/arch/x86/mm.c 2009-05-20 12:56:01.000000000 = +0200 +++ 2009-05-19/xen/arch/x86/mm.c 2009-05-20 14:10:20.000000000 = +0200 @@ -709,6 +709,23 @@ int is_iomem_page(unsigned long mfn) return (page_get_owner(page) =3D=3D dom_io); } =20 +static void update_xen_mappings(unsigned long mfn, unsigned long = cacheattr) +{ +#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); + unsigned long xen_va =3D + XEN_VIRT_START + ((mfn - PFN_DOWN(xen_phys_start)) << PAGE_SHIFT);= + + if ( unlikely(alias) && cacheattr ) + map_pages_to_xen(xen_va, mfn, 1, 0); + map_pages_to_xen((unsigned long)mfn_to_virt(mfn), mfn, 1, + PAGE_HYPERVISOR | cacheattr_to_pte_flags(cacheattr));= + if ( unlikely(alias) && !cacheattr ) + map_pages_to_xen(xen_va, mfn, 1, PAGE_HYPERVISOR); +#endif +} + =20 int get_page_from_l1e( @@ -796,10 +813,7 @@ get_page_from_l1e( y =3D cmpxchg(&page->count_info, x, nx); } =20 -#ifdef __x86_64__ - map_pages_to_xen((unsigned long)mfn_to_virt(mfn), mfn, 1, - PAGE_HYPERVISOR | cacheattr_to_pte_flags(cacheatt= r)); -#endif + update_xen_mappings(mfn, cacheattr); } =20 return 1; @@ -857,12 +871,6 @@ get_page_from_l2e( return -EINVAL; } } while ( m++ < (mfn + (L1_PAGETABLE_ENTRIES-1)) ); - -#ifdef __x86_64__ - map_pages_to_xen( - (unsigned long)mfn_to_virt(mfn), mfn, L1_PAGETABLE_ENTRIES, - PAGE_HYPERVISOR | l2e_get_flags(l2e)); -#endif } =20 return rc; @@ -2405,10 +2413,7 @@ void cleanup_page_cacheattr(struct page_ =20 BUG_ON(is_xen_heap_page(page)); =20 -#ifdef __x86_64__ - map_pages_to_xen((unsigned long)page_to_virt(page), page_to_mfn(page),= - 1, PAGE_HYPERVISOR); -#endif + update_xen_mappings(page_to_mfn(page), 0); } =20 =20