From patchwork Thu Apr 21 10:49:54 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 1137 Return-Path: Delivered-To: unknown Received: from imap.gmail.com (74.125.159.109) by localhost6.localdomain6 with IMAP4-SSL; 08 Jun 2011 14:49:34 -0000 Delivered-To: patches@linaro.org Received: by 10.224.67.148 with SMTP id r20cs159377qai; Thu, 21 Apr 2011 03:49:57 -0700 (PDT) Received: by 10.224.9.8 with SMTP id j8mr6209410qaj.391.1303382997833; Thu, 21 Apr 2011 03:49:57 -0700 (PDT) Received: from mho-02-ewr.mailhop.org (mho-04-ewr.mailhop.org [204.13.248.74]) by mx.google.com with ESMTPS id j3si3658261qcu.153.2011.04.21.03.49.57 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 21 Apr 2011 03:49:57 -0700 (PDT) Received-SPF: neutral (google.com: 204.13.248.74 is neither permitted nor denied by best guess record for domain of tony@atomide.com) client-ip=204.13.248.74; Authentication-Results: mx.google.com; spf=neutral (google.com: 204.13.248.74 is neither permitted nor denied by best guess record for domain of tony@atomide.com) smtp.mail=tony@atomide.com Received: from c-98-234-237-12.hsd1.ca.comcast.net ([98.234.237.12] helo=localhost.localdomain) by mho-02-ewr.mailhop.org with esmtpa (Exim 4.72) (envelope-from ) id 1QCrSP-000NH3-1l; Thu, 21 Apr 2011 10:49:57 +0000 Received: from Mutt by mutt-smtp-wrapper.pl 1.2 (www.zdo.com/articles/mutt-smtp-wrapper.shtml) X-Mail-Handler: MailHop Outbound by DynDNS X-Originating-IP: 98.234.237.12 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/mailhop/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX1/bh/qPzAH5DRCCXwA1BNUv Date: Thu, 21 Apr 2011 03:49:54 -0700 From: Tony Lindgren To: Nicolas Pitre Cc: Shawn Guo , linux-arm-kernel@lists.infradead.org, patches@linaro.org, Aaro Koskinen , linux-omap@vger.kernel.org Subject: [PATCH] ARM: Fix relocation if image end past uncompressed kernel end Message-ID: <20110421104954.GH13688@atomide.com> References: <1303272904-31392-1-git-send-email-nicolas.pitre@linaro.org> <20110420072156.GA28679@atomide.com> <20110420165514.GE10402@atomide.com> <20110421055945.GB13688@atomide.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110421055945.GB13688@atomide.com> User-Agent: Mutt/1.5.20 (2009-06-14) Otherwise we end up overwriting ourselves. This fixes booting on n900 after commit 6d7d0ae51574943bf571d269da3243257a2d15db (ARM: 6750/1: improvements to compressed/head.S). Signed-off-by: Tony Lindgren --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -282,6 +282,7 @@ dtb_check_done: /* * Check to see if we will overwrite ourselves. + * r1 = corrupted, temporary uncompressed kernel end * r4 = final kernel address * r5 = start of this image * r9 = size of decompressed image @@ -292,15 +293,24 @@ dtb_check_done: */ cmp r4, r10 bhs wont_overwrite - add r10, r4, r9 - cmp r10, r5 + add r1, r4, r9 + cmp r1, r5 bls wont_overwrite + /* + * Check if the compressed image end is past the uncompressed + * kernel end. In that case, relocate ourselves to the end + * of the compressed image instead of the uncompressed kernel + * end to avoid overwriting ourselves. + */ + cmp r10, r1 + movls r10, r1 + /* * Relocate ourselves past the end of the decompressed kernel. * r5 = start of this image * r6 = _edata - * r10 = end of the decompressed kernel + * r10 = end of the decompressed kernel or end of this image if larger * Because we always copy ahead, we need to do it from the end and go * backward in case the source and destination overlap. */