diff mbox series

[v10,2/3] ARM: uncompress: Add OF_DT_MAGIC macro

Message ID 20201203121916.2870975-3-geert+renesas@glider.be (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show
Series ARM: uncompress: Validate start of physical memory against passed DTB | expand

Commit Message

Geert Uytterhoeven Dec. 3, 2020, 12:19 p.m. UTC
The DTB magic marker is stored as a 32-bit big-endian value, and thus
depends on the CPU's endianness.  Add a macro to define this value in
native endianness, to reduce #ifdef clutter and (future) duplication.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
v10:
  - New.
---
 arch/arm/boot/compressed/head.S | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

Comments

Ard Biesheuvel Dec. 3, 2020, 12:50 p.m. UTC | #1
On Thu, 3 Dec 2020 at 13:19, Geert Uytterhoeven <geert+renesas@glider.be> wrote:
>
> The DTB magic marker is stored as a 32-bit big-endian value, and thus
> depends on the CPU's endianness.  Add a macro to define this value in
> native endianness, to reduce #ifdef clutter and (future) duplication.
>
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Reviewed-by: Ard Biesheuvel <ardb@kernel.org>

> ---
> v10:
>   - New.
> ---
>  arch/arm/boot/compressed/head.S | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
> index aabdc544c03aafdc..d9cce7238a365081 100644
> --- a/arch/arm/boot/compressed/head.S
> +++ b/arch/arm/boot/compressed/head.S
> @@ -11,6 +11,12 @@
>
>  #include "efi-header.S"
>
> +#ifdef __ARMEB__
> +#define OF_DT_MAGIC 0xd00dfeed
> +#else
> +#define OF_DT_MAGIC 0xedfe0dd0
> +#endif
> +
>   AR_CLASS(     .arch   armv7-a )
>   M_CLASS(      .arch   armv7-m )
>
> @@ -335,11 +341,7 @@ restart:   adr     r0, LC1
>   */
>
>                 ldr     lr, [r6, #0]
> -#ifndef __ARMEB__
> -               ldr     r1, =0xedfe0dd0         @ sig is 0xd00dfeed big endian
> -#else
> -               ldr     r1, =0xd00dfeed
> -#endif
> +               ldr     r1, =OF_DT_MAGIC
>                 cmp     lr, r1
>                 bne     dtb_check_done          @ not found
>
> --
> 2.25.1
>
Nicolas Pitre Dec. 3, 2020, 4:27 p.m. UTC | #2
On Thu, 3 Dec 2020, Geert Uytterhoeven wrote:

> The DTB magic marker is stored as a 32-bit big-endian value, and thus
> depends on the CPU's endianness.  Add a macro to define this value in
> native endianness, to reduce #ifdef clutter and (future) duplication.
> 
> Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>

Reviewed-by: Nicolas Pitre <nico@fluxnic.net>


> ---
> v10:
>   - New.
> ---
>  arch/arm/boot/compressed/head.S | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
> index aabdc544c03aafdc..d9cce7238a365081 100644
> --- a/arch/arm/boot/compressed/head.S
> +++ b/arch/arm/boot/compressed/head.S
> @@ -11,6 +11,12 @@
>  
>  #include "efi-header.S"
>  
> +#ifdef __ARMEB__
> +#define OF_DT_MAGIC 0xd00dfeed
> +#else
> +#define OF_DT_MAGIC 0xedfe0dd0
> +#endif
> +
>   AR_CLASS(	.arch	armv7-a	)
>   M_CLASS(	.arch	armv7-m	)
>  
> @@ -335,11 +341,7 @@ restart:	adr	r0, LC1
>   */
>  
>  		ldr	lr, [r6, #0]
> -#ifndef __ARMEB__
> -		ldr	r1, =0xedfe0dd0		@ sig is 0xd00dfeed big endian
> -#else
> -		ldr	r1, =0xd00dfeed
> -#endif
> +		ldr	r1, =OF_DT_MAGIC
>  		cmp	lr, r1
>  		bne	dtb_check_done		@ not found
>  
> -- 
> 2.25.1
> 
>
Geert Uytterhoeven Dec. 4, 2020, 9:43 a.m. UTC | #3
On Thu, Dec 3, 2020 at 5:27 PM Nicolas Pitre <nico@fluxnic.net> wrote:
> On Thu, 3 Dec 2020, Geert Uytterhoeven wrote:
> > The DTB magic marker is stored as a 32-bit big-endian value, and thus
> > depends on the CPU's endianness.  Add a macro to define this value in
> > native endianness, to reduce #ifdef clutter and (future) duplication.
> >
> > Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
>
> Reviewed-by: Nicolas Pitre <nico@fluxnic.net>

Thanks, submitted to rmk's patch tracker.

Gr{oetje,eeting}s,

                        Geert
diff mbox series

Patch

diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index aabdc544c03aafdc..d9cce7238a365081 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -11,6 +11,12 @@ 
 
 #include "efi-header.S"
 
+#ifdef __ARMEB__
+#define OF_DT_MAGIC 0xd00dfeed
+#else
+#define OF_DT_MAGIC 0xedfe0dd0
+#endif
+
  AR_CLASS(	.arch	armv7-a	)
  M_CLASS(	.arch	armv7-m	)
 
@@ -335,11 +341,7 @@  restart:	adr	r0, LC1
  */
 
 		ldr	lr, [r6, #0]
-#ifndef __ARMEB__
-		ldr	r1, =0xedfe0dd0		@ sig is 0xd00dfeed big endian
-#else
-		ldr	r1, =0xd00dfeed
-#endif
+		ldr	r1, =OF_DT_MAGIC
 		cmp	lr, r1
 		bne	dtb_check_done		@ not found