diff mbox series

[U-Boot,1/2] rpi: Fix fdt_high & initrd_high for 64-bit builds

Message ID 20180420100349.27194-2-tuomas@tuxera.com
State Accepted, archived
Delegated to: Alexander Graf
Headers show
Series [U-Boot,1/2] rpi: Fix fdt_high & initrd_high for 64-bit builds | expand

Commit Message

Tuomas Tynkkynen April 20, 2018, 10:03 a.m. UTC
The magic value that disables relocation is dependent on the CPU word
size, so the current 'ffffffff' is doing the wrong thing on aarch64.

Signed-off-by: Tuomas Tynkkynen <tuomas@tuxera.com>
---
 include/configs/rpi.h | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

Comments

Alexander Graf May 24, 2018, 7:51 a.m. UTC | #1
On 20.04.18 12:03, Tuomas Tynkkynen wrote:
> The magic value that disables relocation is dependent on the CPU word
> size, so the current 'ffffffff' is doing the wrong thing on aarch64.
> 
> Signed-off-by: Tuomas Tynkkynen <tuomas@tuxera.com>

The BCM283x series of SOCs is limited to 32bit address space, so I don't
quite see why the current (int)-1 is wrong?


Alex

> ---
>  include/configs/rpi.h | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/include/configs/rpi.h b/include/configs/rpi.h
> index 325e52a019..f1189a27f3 100644
> --- a/include/configs/rpi.h
> +++ b/include/configs/rpi.h
> @@ -91,6 +91,14 @@
>  	"stdout=serial,vidconsole\0" \
>  	"stderr=serial,vidconsole\0"
>  
> +#ifdef CONFIG_ARM64
> +#define FDT_HIGH "ffffffffffffffff"
> +#define INITRD_HIGH "ffffffffffffffff"
> +#else
> +#define FDT_HIGH "ffffffff"
> +#define INITRD_HIGH "ffffffff"
> +#endif
> +
>  /*
>   * Memory layout for where various images get loaded by boot scripts:
>   *
> @@ -122,8 +130,8 @@
>   *   for any boot script to be up to 1M, which is hopefully plenty.
>   */
>  #define ENV_MEM_LAYOUT_SETTINGS \
> -	"fdt_high=ffffffff\0" \
> -	"initrd_high=ffffffff\0" \
> +	"fdt_high=" FDT_HIGH "\0" \
> +	"initrd_high=" INITRD_HIGH "\0" \
>  	"fdt_addr_r=0x00000100\0" \
>  	"pxefile_addr_r=0x00100000\0" \
>  	"kernel_addr_r=0x01000000\0" \
>
Tuomas Tynkkynen May 24, 2018, 2:57 p.m. UTC | #2
Hi Alex,

On Thu, 24 May 2018 09:51:57 +0200
Alexander Graf <agraf@suse.de> wrote:

> On 20.04.18 12:03, Tuomas Tynkkynen wrote:
> > The magic value that disables relocation is dependent on the CPU word
> > size, so the current 'ffffffff' is doing the wrong thing on aarch64.
> > 
> > Signed-off-by: Tuomas Tynkkynen <tuomas@tuxera.com>  
> 
> The BCM283x series of SOCs is limited to 32bit address space, so I don't
> quite see why the current (int)-1 is wrong?
> 
> 

The comparison for the magic "don't relocate value" is done by parsing
the variable as ulong and then comparing to ~0. So on 64-bit, ffffffff
gets interpreted as literal 0xffffffff limit for the relocation (which
I think in practice is the same as not specifying initrd_high at all
since the end of DRAM is lower than that) instead.
Alexander Graf May 24, 2018, 3:22 p.m. UTC | #3
On 24.05.18 16:57, Tuomas Tynkkynen wrote:
> Hi Alex,
> 
> On Thu, 24 May 2018 09:51:57 +0200
> Alexander Graf <agraf@suse.de> wrote:
> 
>> On 20.04.18 12:03, Tuomas Tynkkynen wrote:
>>> The magic value that disables relocation is dependent on the CPU word
>>> size, so the current 'ffffffff' is doing the wrong thing on aarch64.
>>>
>>> Signed-off-by: Tuomas Tynkkynen <tuomas@tuxera.com>  
>>
>> The BCM283x series of SOCs is limited to 32bit address space, so I don't
>> quite see why the current (int)-1 is wrong?
>>
>>
> 
> The comparison for the magic "don't relocate value" is done by parsing
> the variable as ulong and then comparing to ~0. So on 64-bit, ffffffff
> gets interpreted as literal 0xffffffff limit for the relocation (which
> I think in practice is the same as not specifying initrd_high at all
> since the end of DRAM is lower than that) instead.

Ouch, that logic is terrible. But it means your patch is correct. I'll
apply it.


Thanks,

Alex
diff mbox series

Patch

diff --git a/include/configs/rpi.h b/include/configs/rpi.h
index 325e52a019..f1189a27f3 100644
--- a/include/configs/rpi.h
+++ b/include/configs/rpi.h
@@ -91,6 +91,14 @@ 
 	"stdout=serial,vidconsole\0" \
 	"stderr=serial,vidconsole\0"
 
+#ifdef CONFIG_ARM64
+#define FDT_HIGH "ffffffffffffffff"
+#define INITRD_HIGH "ffffffffffffffff"
+#else
+#define FDT_HIGH "ffffffff"
+#define INITRD_HIGH "ffffffff"
+#endif
+
 /*
  * Memory layout for where various images get loaded by boot scripts:
  *
@@ -122,8 +130,8 @@ 
  *   for any boot script to be up to 1M, which is hopefully plenty.
  */
 #define ENV_MEM_LAYOUT_SETTINGS \
-	"fdt_high=ffffffff\0" \
-	"initrd_high=ffffffff\0" \
+	"fdt_high=" FDT_HIGH "\0" \
+	"initrd_high=" INITRD_HIGH "\0" \
 	"fdt_addr_r=0x00000100\0" \
 	"pxefile_addr_r=0x00100000\0" \
 	"kernel_addr_r=0x01000000\0" \