[U-Boot] [PATCH] arm: Allow u-boot to run from offset base address

Darwin Rambo drambo at broadcom.com
Thu May 15 16:21:09 CEST 2014


On 14-05-14 03:41 PM, Jeroen Hofstee wrote:
> Hello Darwin,
>
> On wo, 2014-05-14 at 15:05 -0700, Darwin Rambo wrote:
>
>> +#ifdef CONFIG_ARM64
>> +	/*
>> +	 * Fix relocation if u-boot is not on an aligned address.
>> +	 */
>> +	{
>> +		int offset = CONFIG_SYS_TEXT_BASE % 4096;
>> +		if (offset) {
>> +			addr += offset;
>> +			debug("Relocation Addr bumped to 0x%08lx\n", addr);
>> +		}
>> +	}
>> +#endif
>> +
> Do you really want to check a define at runtime? Placement is typically
> at the end of RAM and allocation goes down, not up as in this patch.
> Aren't you overlapping memory here?

Yes, I wanted the runtime check since the adjustment to the relocation
address is also done at runtime.

There is no overlap here. The reason is that the original masking operation
to mask to a 4K boundary removed the small offset and backed up too far. So
adding the lost offset is guaranteed to not overlap, and furthermore, correct
the relocation offset so that arm64 images can run at smaller alignments than
we normally use. This might even be a generic fix but can't be tested easily
by me.

>
>>   
>>   static int setup_reloc(void)
>>   {
>> +#ifdef CONFIG_ARM64
>> +	/*
>> +	 * Fix relocation if u-boot is not on an aligned address.
>> +	 */
>> +	int offset = CONFIG_SYS_TEXT_BASE % 4096;
>> +	if (offset) {
>> +		gd->relocaddr += offset;
>> +		debug("Relocation Addr bumped to 0x%08lx\n", gd->relocaddr);
>> +	}
>> +#endif
>>   	gd->reloc_off = gd->relocaddr - CONFIG_SYS_TEXT_BASE;
>>   	memcpy(gd->new_gd, (char *)gd, sizeof(gd_t));
>>   
> This is a generic file, hell breaks loose if you start using arch /
> board / pre bootloader specific workarounds here afaiac.

I don't disagree with this statement. Please see my other comments to
Wolfgang on this topic.

>
> lucky for you, I am not a u-boot maintainer, but this looks at least a
> bit weird, glancing at it.
>
> Regards,
> Jeroen
>
Thanks for your comments Jeroen. They are appreciated.
Darwin



More information about the U-Boot mailing list