diff mbox

N900 v3.19-rc5 arm atags_to_fdt.c is broken

Message ID 201501232336.36187@pali (mailing list archive)
State New, archived
Headers show

Commit Message

Pali Rohár Jan. 23, 2015, 10:36 p.m. UTC
On Friday 23 January 2015 22:39:55 Pali Rohár wrote:
> Hello,
> 
> when I boot zImage with appended DT n900 in qemu
> fdt_open_into() function called from file
> arch/arm/boot/compressed/atags_to_fdt.c (in function
> atags_to_fdt) always returns -FDT_ERR_NOSPACE.
> 
> It means that all ATAGS (including cmdline arguments) passed
> by bootloader are ignored.
> 
> On real n900 device I see that booted DT version also ignore
> cmdline arguments from bootloader. I cannot debug decompress
> code on real device, but I think it is same problem as in
> qemu.

Looks like this quick patch is fixing above problem:

Comments

Pavel Machek Jan. 23, 2015, 11:48 p.m. UTC | #1
On Fri 2015-01-23 23:36:36, Pali Rohár wrote:
> On Friday 23 January 2015 22:39:55 Pali Rohár wrote:
> > Hello,
> > 
> > when I boot zImage with appended DT n900 in qemu
> > fdt_open_into() function called from file
> > arch/arm/boot/compressed/atags_to_fdt.c (in function
> > atags_to_fdt) always returns -FDT_ERR_NOSPACE.
> > 
> > It means that all ATAGS (including cmdline arguments) passed
> > by bootloader are ignored.
> > 
> > On real n900 device I see that booted DT version also ignore
> > cmdline arguments from bootloader. I cannot debug decompress
> > code on real device, but I think it is same problem as in
> > qemu.
> 
> Looks like this quick patch is fixing above problem:

So... something overruns stack, and bigger stack fixes it...?

							Pavel

> diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
> index 68be901..4a7d75b 100644
> --- a/arch/arm/boot/compressed/head.S
> +++ b/arch/arm/boot/compressed/head.S
> @@ -268,7 +268,7 @@ restart:	adr	r0, LC0
>  		 * area.  No GOT fixup has occurred yet, but none of the
>  		 * code we're about to call uses any global variable.
>  		*/
> -		add	sp, sp, #0x10000
> +		add	sp, sp, #0x20000
>  		stmfd	sp!, {r0-r3, ip, lr}
>  		mov	r0, r8
>  		mov	r1, r6
> @@ -289,7 +289,7 @@ restart:	adr	r0, LC0
>  		bleq	atags_to_fdt
>  
>  		ldmfd	sp!, {r0-r3, ip, lr}
> -		sub	sp, sp, #0x10000
> +		sub	sp, sp, #0x20000
>  #endif
>  
>  		mov	r8, r6			@ use the appended device tree
> 
>
Pali Rohár Jan. 24, 2015, 9:04 a.m. UTC | #2
On Saturday 24 January 2015 00:48:55 Pavel Machek wrote:
> On Fri 2015-01-23 23:36:36, Pali Rohár wrote:
> > On Friday 23 January 2015 22:39:55 Pali Rohár wrote:
> > > Hello,
> > > 
> > > when I boot zImage with appended DT n900 in qemu
> > > fdt_open_into() function called from file
> > > arch/arm/boot/compressed/atags_to_fdt.c (in function
> > > atags_to_fdt) always returns -FDT_ERR_NOSPACE.
> > > 
> > > It means that all ATAGS (including cmdline arguments)
> > > passed by bootloader are ignored.
> > > 
> > > On real n900 device I see that booted DT version also
> > > ignore cmdline arguments from bootloader. I cannot debug
> > > decompress code on real device, but I think it is same
> > > problem as in qemu.
> > 
> > Looks like this quick patch is fixing above problem:
> So... something overruns stack, and bigger stack fixes it...?
> 
> 							Pavel
> 

Yes, it looks like that DTB file for n900 is too big and 
atags_to_fdt.c cannot append anything to it (kernel cmdline)...

> > diff --git a/arch/arm/boot/compressed/head.S
> > b/arch/arm/boot/compressed/head.S index 68be901..4a7d75b
> > 100644
> > --- a/arch/arm/boot/compressed/head.S
> > +++ b/arch/arm/boot/compressed/head.S
> > @@ -268,7 +268,7 @@ restart:	adr	r0, LC0
> > 
> >  		 * area.  No GOT fixup has occurred yet, but none of 
the
> >  		 * code we're about to call uses any global variable.
> >  		
> >  		*/
> > 
> > -		add	sp, sp, #0x10000
> > +		add	sp, sp, #0x20000
> > 
> >  		stmfd	sp!, {r0-r3, ip, lr}
> >  		mov	r0, r8
> >  		mov	r1, r6
> > 
> > @@ -289,7 +289,7 @@ restart:	adr	r0, LC0
> > 
> >  		bleq	atags_to_fdt
> >  		
> >  		ldmfd	sp!, {r0-r3, ip, lr}
> > 
> > -		sub	sp, sp, #0x10000
> > +		sub	sp, sp, #0x20000
> > 
> >  #endif
> >  
> >  		mov	r8, r6			@ use the appended device tree
Tony Lindgren Jan. 26, 2015, 4:14 p.m. UTC | #3
* Pali Rohár <pali.rohar@gmail.com> [150123 14:39]:
> On Friday 23 January 2015 22:39:55 Pali Rohár wrote:
> > Hello,
> > 
> > when I boot zImage with appended DT n900 in qemu
> > fdt_open_into() function called from file
> > arch/arm/boot/compressed/atags_to_fdt.c (in function
> > atags_to_fdt) always returns -FDT_ERR_NOSPACE.
> > 
> > It means that all ATAGS (including cmdline arguments) passed
> > by bootloader are ignored.
> > 
> > On real n900 device I see that booted DT version also ignore
> > cmdline arguments from bootloader. I cannot debug decompress
> > code on real device, but I think it is same problem as in
> > qemu.
> 
> Looks like this quick patch is fixing above problem:
> 
> diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
> index 68be901..4a7d75b 100644
> --- a/arch/arm/boot/compressed/head.S
> +++ b/arch/arm/boot/compressed/head.S
> @@ -268,7 +268,7 @@ restart:	adr	r0, LC0
>  		 * area.  No GOT fixup has occurred yet, but none of the
>  		 * code we're about to call uses any global variable.
>  		*/
> -		add	sp, sp, #0x10000
> +		add	sp, sp, #0x20000
>  		stmfd	sp!, {r0-r3, ip, lr}
>  		mov	r0, r8
>  		mov	r1, r6
> @@ -289,7 +289,7 @@ restart:	adr	r0, LC0
>  		bleq	atags_to_fdt
>  
>  		ldmfd	sp!, {r0-r3, ip, lr}
> -		sub	sp, sp, #0x10000
> +		sub	sp, sp, #0x20000
>  #endif
>  
>  		mov	r8, r6			@ use the appended device tree

Nico, got any ideas about this one? This seems like a regression
somewhere..

Regards,

Tony
Pali Rohár Jan. 26, 2015, 4:23 p.m. UTC | #4
On Monday 26 January 2015 17:14:55 Tony Lindgren wrote:
> * Pali Rohár <pali.rohar@gmail.com> [150123 14:39]:
> > On Friday 23 January 2015 22:39:55 Pali Rohár wrote:
> > > Hello,
> > > 
> > > when I boot zImage with appended DT n900 in qemu
> > > fdt_open_into() function called from file
> > > arch/arm/boot/compressed/atags_to_fdt.c (in function
> > > atags_to_fdt) always returns -FDT_ERR_NOSPACE.
> > > 
> > > It means that all ATAGS (including cmdline arguments)
> > > passed by bootloader are ignored.
> > > 
> > > On real n900 device I see that booted DT version also
> > > ignore cmdline arguments from bootloader. I cannot debug
> > > decompress code on real device, but I think it is same
> > > problem as in qemu.
> > 
> > Looks like this quick patch is fixing above problem:
> > 
> > diff --git a/arch/arm/boot/compressed/head.S
> > b/arch/arm/boot/compressed/head.S index 68be901..4a7d75b
> > 100644
> > --- a/arch/arm/boot/compressed/head.S
> > +++ b/arch/arm/boot/compressed/head.S
> > @@ -268,7 +268,7 @@ restart:	adr	r0, LC0
> > 
> >  		 * area.  No GOT fixup has occurred yet, but none of 
the
> >  		 * code we're about to call uses any global variable.
> >  		
> >  		*/
> > 
> > -		add	sp, sp, #0x10000
> > +		add	sp, sp, #0x20000
> > 
> >  		stmfd	sp!, {r0-r3, ip, lr}
> >  		mov	r0, r8
> >  		mov	r1, r6
> > 
> > @@ -289,7 +289,7 @@ restart:	adr	r0, LC0
> > 
> >  		bleq	atags_to_fdt
> >  		
> >  		ldmfd	sp!, {r0-r3, ip, lr}
> > 
> > -		sub	sp, sp, #0x10000
> > +		sub	sp, sp, #0x20000
> > 
> >  #endif
> >  
> >  		mov	r8, r6			@ use the appended device tree
> 
> Nico, got any ideas about this one? This seems like a
> regression somewhere..
> 
> Regards,
> 
> Tony

$ du -b arch/arm/boot/dts/omap3-n900.dtb 
70212   arch/arm/boot/dts/omap3-n900.dtb

$ echo $((0x10000))
65536

I would say, problem is because omap3-n900 binary DT is too large
Tony Lindgren Jan. 26, 2015, 5:03 p.m. UTC | #5
* Pali Rohár <pali.rohar@gmail.com> [150126 08:26]:
> On Monday 26 January 2015 17:14:55 Tony Lindgren wrote:
> > * Pali Rohár <pali.rohar@gmail.com> [150123 14:39]:
> > > On Friday 23 January 2015 22:39:55 Pali Rohár wrote:
> > > > Hello,
> > > > 
> > > > when I boot zImage with appended DT n900 in qemu
> > > > fdt_open_into() function called from file
> > > > arch/arm/boot/compressed/atags_to_fdt.c (in function
> > > > atags_to_fdt) always returns -FDT_ERR_NOSPACE.
> > > > 
> > > > It means that all ATAGS (including cmdline arguments)
> > > > passed by bootloader are ignored.
> > > > 
> > > > On real n900 device I see that booted DT version also
> > > > ignore cmdline arguments from bootloader. I cannot debug
> > > > decompress code on real device, but I think it is same
> > > > problem as in qemu.
> > > 
> > > Looks like this quick patch is fixing above problem:
> > > 
> > > diff --git a/arch/arm/boot/compressed/head.S
> > > b/arch/arm/boot/compressed/head.S index 68be901..4a7d75b
> > > 100644
> > > --- a/arch/arm/boot/compressed/head.S
> > > +++ b/arch/arm/boot/compressed/head.S
> > > @@ -268,7 +268,7 @@ restart:	adr	r0, LC0
> > > 
> > >  		 * area.  No GOT fixup has occurred yet, but none of 
> the
> > >  		 * code we're about to call uses any global variable.
> > >  		
> > >  		*/
> > > 
> > > -		add	sp, sp, #0x10000
> > > +		add	sp, sp, #0x20000
> > > 
> > >  		stmfd	sp!, {r0-r3, ip, lr}
> > >  		mov	r0, r8
> > >  		mov	r1, r6
> > > 
> > > @@ -289,7 +289,7 @@ restart:	adr	r0, LC0
> > > 
> > >  		bleq	atags_to_fdt
> > >  		
> > >  		ldmfd	sp!, {r0-r3, ip, lr}
> > > 
> > > -		sub	sp, sp, #0x10000
> > > +		sub	sp, sp, #0x20000
> > > 
> > >  #endif
> > >  
> > >  		mov	r8, r6			@ use the appended device tree
> > 
> > Nico, got any ideas about this one? This seems like a
> > regression somewhere..
> > 
> > Regards,
> > 
> > Tony
> 
> $ du -b arch/arm/boot/dts/omap3-n900.dtb 
> 70212   arch/arm/boot/dts/omap3-n900.dtb
> 
> $ echo $((0x10000))
> 65536
> 
> I would say, problem is because omap3-n900 binary DT is too large

OK if that's the case, then your patch makes sense to me. It also
seems we can have the temporary stack be larger than the initial
stack just for atags_to_fdt.

Regards,

Tony
diff mbox

Patch

diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 68be901..4a7d75b 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -268,7 +268,7 @@  restart:	adr	r0, LC0
 		 * area.  No GOT fixup has occurred yet, but none of the
 		 * code we're about to call uses any global variable.
 		*/
-		add	sp, sp, #0x10000
+		add	sp, sp, #0x20000
 		stmfd	sp!, {r0-r3, ip, lr}
 		mov	r0, r8
 		mov	r1, r6
@@ -289,7 +289,7 @@  restart:	adr	r0, LC0
 		bleq	atags_to_fdt
 
 		ldmfd	sp!, {r0-r3, ip, lr}
-		sub	sp, sp, #0x10000
+		sub	sp, sp, #0x20000
 #endif
 
 		mov	r8, r6			@ use the appended device tree