From: "Jan Beulich" Subject: [PATCH] xmalloc: make whole pages xfree() clear the order field (ab)used by xmalloc() Date: Tue, 27 Aug 2013 08:47:23 +0100 Message-ID: <521C75AB02000078000EEA15@nat28.tlf.novell.com> References: <1377511404-3365-1-git-send-email-tomasz.wroblewski@citrix.com> <521B543902000078000EE55D@nat28.tlf.novell.com> <521B48FF.1040904@citrix.com> <521B6D7302000078000EE64E@nat28.tlf.novell.com> <521B89AC.1040509@citrix.com> <521C6DBC02000078000EE9D6@nat28.tlf.novell.com> <521C53E9.9070003@citrix.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=__PartE4D7A79B.1__=" Return-path: Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1VEDzu-0000fP-NO for xen-devel@lists.xenproject.org; Tue, 27 Aug 2013 07:47:31 +0000 In-Reply-To: <521C53E9.9070003@citrix.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Tomasz Wroblewski Cc: Andrew Cooper , dgdegra@tycho.nsa.gov, Keir Fraser , xen-devel@lists.xenproject.org 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. --=__PartE4D7A79B.1__= Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Not doing this was found to cause problems with sequences of allocation (multi-page), freeing, and then again allocation of the same page upon boot when interrupts are still disabled (causing the owner field to be non-zero, thus making the allocator attempt a TLB flush and, in its processing, triggering an assertion). Reported-by: Tomasz Wroblewski Signed-off-by: Jan Beulich Tested-by: Tomasz Wroblewski --- a/xen/common/xmalloc_tlsf.c +++ b/xen/common/xmalloc_tlsf.c @@ -629,6 +629,7 @@ void xfree(void *p) unsigned int i, order =3D get_order_from_pages(size); =20 BUG_ON((unsigned long)p & ((PAGE_SIZE << order) - 1)); + PFN_ORDER(virt_to_page(p)) =3D 0; for ( i =3D 0; ; ++i ) { if ( !(size & (1 << i)) ) --=__PartE4D7A79B.1__= Content-Type: text/plain; name="xfree-whole-pages.patch" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="xfree-whole-pages.patch" xmalloc: make whole pages xfree() clear the order field (ab)used by = xmalloc()=0A=0ANot doing this was found to cause problems with sequences = of allocation=0A(multi-page), freeing, and then again allocation of the = same page upon=0Aboot when interrupts are still disabled (causing the = owner field to be=0Anon-zero, thus making the allocator attempt a TLB = flush and, in its=0Aprocessing, triggering an assertion).=0A=0AReported-by:= Tomasz Wroblewski =0ASigned-off-by: Jan = Beulich =0ATested-by: Tomasz Wroblewski =0A=0A--- a/xen/common/xmalloc_tlsf.c=0A+++ b/xen/common/xmal= loc_tlsf.c=0A@@ -629,6 +629,7 @@ void xfree(void *p)=0A unsigned = int i, order =3D get_order_from_pages(size);=0A =0A BUG_ON((unsigne= d long)p & ((PAGE_SIZE << order) - 1));=0A+ PFN_ORDER(virt_to_page(p= )) =3D 0;=0A for ( i =3D 0; ; ++i )=0A {=0A if = ( !(size & (1 << i)) )=0A --=__PartE4D7A79B.1__= 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 --=__PartE4D7A79B.1__=--