From: Stephen Warren Date: Tue, 9 Jan 2018 12:53:09 -0700 Subject: [U-Boot] [PATCH 3/4] ARMv8: Allow dynamic early stack pointer In-Reply-To: References: <20171220013037.24485-1-swarren@wwwdotorg.org> <20171220013037.24485-3-swarren@wwwdotorg.org> <6cbead42-e5cb-acbc-c269-2c02d358c0c6@wwwdotorg.org> Message-ID: <18cceb12-3d0c-b032-aa4f-e19ae0b09bdc@wwwdotorg.org> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 01/08/2018 03:11 PM, Simon Glass wrote: > Hi Stephen, > > On 8 January 2018 at 11:34, Stephen Warren wrote: >> >> On 01/07/2018 08:40 PM, Simon Glass wrote: >>> >>> Hi Stephen, >>> >>> On 19 December 2017 at 18:30, Stephen Warren wrote: >>>> >>>> From: Stephen Warren >>>> >>>> U-Boot typically uses a hard-coded value for the stack pointer before >>>> relocation. Implement option SYS_INIT_SP_BSS_OFFSET to instead calculate >>>> the initial SP at run-time. This is useful to avoid hard-coding addresses >>>> into U-Boot, so that can be loaded and executed at arbitrary addresses and >>>> thus avoid using arbitrary addresses at runtime. This option's value is >>>> the offset added to &_bss_start in order to calculate the stack pointer. >>>> This offset should be large enough so that the early malloc region, global >>>> data (gd), and early stack usage do not overlap any appended DTB. >>> >>> >>> I don't see why this is an offset from bss_start - shouldn't it be bss_end? >> >> >> BSS can vary in size based on the set of config options enabled, code growth/shrinkage, etc. Thus, basing the initial SP address on bss_end would provide too much variability, and hence would be unsafe, whereas basing the initial SP address on bss_start always provides the exact same amount of available stack space (assuming an identical DTB for the comparison). > > OK. I suppose we are no worse off anyway, since the DTB can vary in size. I've sent a patch to check for overflow.