From patchwork Wed Apr 27 22:16:09 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Pitre X-Patchwork-Id: 737851 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 p3RMGEL1031720 for ; Wed, 27 Apr 2011 22:16:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754378Ab1D0WQN (ORCPT ); Wed, 27 Apr 2011 18:16:13 -0400 Received: from mail-vx0-f174.google.com ([209.85.220.174]:37437 "EHLO mail-vx0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753971Ab1D0WQN (ORCPT ); Wed, 27 Apr 2011 18:16:13 -0400 Received: by vxi39 with SMTP id 39so1647429vxi.19 for ; Wed, 27 Apr 2011 15:16:12 -0700 (PDT) Received: by 10.52.172.2 with SMTP id ay2mr619365vdc.50.1303942571864; Wed, 27 Apr 2011 15:16:11 -0700 (PDT) Received: from xanadu.home (modemcable092.28-130-66.mc.videotron.ca [66.130.28.92]) by mx.google.com with ESMTPS id 15sm275382vdh.27.2011.04.27.15.16.09 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 27 Apr 2011 15:16:10 -0700 (PDT) Date: Wed, 27 Apr 2011 18:16:09 -0400 (EDT) From: Nicolas Pitre X-X-Sender: nico@xanadu.home To: Tony Lindgren cc: Shawn Guo , linux-arm-kernel@lists.infradead.org, patches@linaro.org, Aaro Koskinen , linux-omap@vger.kernel.org Subject: Re: [PATCH] ARM: Fix relocation if image end past uncompressed kernel end In-Reply-To: <20110427125631.GF3755@atomide.com> Message-ID: References: <1303272904-31392-1-git-send-email-nicolas.pitre@linaro.org> <20110420072156.GA28679@atomide.com> <20110420165514.GE10402@atomide.com> <20110421055945.GB13688@atomide.com> <20110421104954.GH13688@atomide.com> <20110427124726.GE3755@atomide.com> <20110427125631.GF3755@atomide.com> User-Agent: Alpine 2.00 (LFD 1167 2008-08-23) MIME-Version: 1.0 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]); Wed, 27 Apr 2011 22:16:14 +0000 (UTC) On Wed, 27 Apr 2011, Tony Lindgren wrote: > * Tony Lindgren [110427 05:44]: > > We can't overwrite the running code when relocating only a small amount, > > say 0x100 or so. > > > > There's no need to relocate all the way past the compressed kernel, > > we just need to relocate past the size of the code in head.o. > > > > Updated patch below using the GOT end instead of the compressed > > image end. > > Oops, the mov should be movle of course. Updated patch below. This is wrong. You're using r12 before it is fixed up with the proper offset. And this could simply be fixed with a big enough constant like this: --- 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 diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index 8dab5e3..71fc1d9 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -250,8 +250,11 @@ restart: adr r0, LC0 * Because we always copy ahead, we need to do it from the end and go * backward in case the source and destination overlap. */ - /* Round up to next 256-byte boundary. */ - add r10, r10, #256 + /* + * Round to a 256-byte boundary on the next page. This + * avoids overwriting ourself if the offset is small. + */ + add r10, r10, #4096 bic r10, r10, #255 sub r9, r6, r5 @ size to copy