From: "Jan Beulich" Subject: [PATCH] x86: fix domain cleanup Date: Mon, 27 Oct 2008 11:36:13 +0000 Message-ID: <4905B5BD.76E4.0078.0@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 The preemptable page type handling changes modified free_page_type() behavior without adjusting the call site in relinquish_memory(): Any type reference left pending when leaving hypercall handlers is associated with a page reference, and when successful free_page_type() decrements the type refcount - hence relinquish_memory() must now also drop the page reference. Also, the recursion avoidance during domain shutdown somehow (probably by me when I merged the patch up to a newer snapshot) got screwed up: The avoidance logic in mm.c should short circuit levels below the top one currently being processed, rather than the top one itself. Signed-off-by: Jan Beulich Index: 2008-10-27/xen/arch/x86/domain.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2008-10-27.orig/xen/arch/x86/domain.c 2008-10-24 11:21:38.0000000= 00 +0200 +++ 2008-10-27/xen/arch/x86/domain.c 2008-10-27 11:11:36.000000000 = +0100 @@ -1687,6 +1687,7 @@ static int relinquish_memory( { if ( free_page_type(page, x, 0) !=3D 0 ) BUG(); + put_page(page); break; } } Index: 2008-10-27/xen/arch/x86/mm.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- 2008-10-27.orig/xen/arch/x86/mm.c 2008-10-17 08:29:02.000000000 = +0200 +++ 2008-10-27/xen/arch/x86/mm.c 2008-10-27 11:11:36.000000000 = +0100 @@ -1343,7 +1343,7 @@ static void free_l1_table(struct page_in =20 static int free_l2_table(struct page_info *page, int preemptible) { -#ifdef CONFIG_COMPAT +#if defined(CONFIG_COMPAT) || defined(DOMAIN_DESTRUCT_AVOID_RECURSION) struct domain *d =3D page_get_owner(page); #endif unsigned long pfn =3D page_to_mfn(page); @@ -1351,6 +1351,11 @@ static int free_l2_table(struct page_inf unsigned int i =3D page->nr_validated_ptes - 1; int err =3D 0; =20 +#ifdef DOMAIN_DESTRUCT_AVOID_RECURSION + if ( d->arch.relmem =3D=3D RELMEM_l3 ) + return 0; +#endif + pl2e =3D map_domain_page(pfn); =20 ASSERT(page->nr_validated_ptes); @@ -1381,7 +1386,7 @@ static int free_l3_table(struct page_inf int rc =3D 0; =20 #ifdef DOMAIN_DESTRUCT_AVOID_RECURSION - if ( d->arch.relmem =3D=3D RELMEM_l3 ) + if ( d->arch.relmem =3D=3D RELMEM_l4 ) return 0; #endif =20 @@ -1424,11 +1429,6 @@ static int free_l4_table(struct page_inf unsigned int i =3D page->nr_validated_ptes - !page->partial_pte; int rc =3D 0; =20 -#ifdef DOMAIN_DESTRUCT_AVOID_RECURSION - if ( d->arch.relmem =3D=3D RELMEM_l4 ) - return 0; -#endif - do { if ( is_guest_l4_slot(d, i) ) rc =3D put_page_from_l4e(pl4e[i], pfn, preemptible);