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: 724421 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p3LAo3R5001750 for ; Thu, 21 Apr 2011 10:50:05 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752679Ab1DUKuA (ORCPT ); Thu, 21 Apr 2011 06:50:00 -0400 Received: from mho-04-ewr.mailhop.org ([204.13.248.74]:10863 "EHLO mho-02-ewr.mailhop.org" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752514Ab1DUKt7 (ORCPT ); Thu, 21 Apr 2011 06:49:59 -0400 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) Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 21 Apr 2011 10:50:22 +0000 (UTC) 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 --- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 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. */