mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* ARM bootm regression
@ 2020-10-16  8:49 Alexander Shiyan
  2020-10-19  9:05 ` Sascha Hauer
  2020-10-21 14:44 ` Sascha Hauer
  0 siblings, 2 replies; 6+ messages in thread
From: Alexander Shiyan @ 2020-10-16  8:49 UTC (permalink / raw)
  To: barebox

Hello.

Found a regression in arm/lib32/bootm.c after a patch
"ARM: bootm: make sure we place the kernel in free memory".

The initial memory size for the board is set to 8 MB (before reading the real value from DT),
so the stack, malloc_space, etc. are placed in the initial 8M space.
Then get_kernel_addresses() gets the real SDRAM area (for my board it is 64M),
but decreases this size by the first children size (malloc_space),
so mem_end is incorrect in this case.

barebox 2020.05.0-00393-gf5e96a296-dirty #80 Thu Oct 15 13:08:54 MSK 2020
Board: Mega-Milas Informer EP7312
cfi_flash 90000000.nor@0,0.of: found cfi flash at 0x90000000, size 32 MiB
i2c-gpio i2c0.of: using pins 16 (SDA) and 35 (SCL)
Hit any to stop autoboot:    1
Booting entry 'nor'
Loading ARM Linux zImage '/dev/nor0.kernel'
__request_region: 0xbfdc6000:0xc00fca17 outside parent resource 0xc0000000:0xc3ffffff
ERROR: bootm/zImage: failed to request memory at 0xbfdc6000 to 0xc00fca18 (3369496).
ERROR: Booting entry 'nor' failed
Nothing bootable found

---
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ARM bootm regression
  2020-10-16  8:49 ARM bootm regression Alexander Shiyan
@ 2020-10-19  9:05 ` Sascha Hauer
  2020-10-19  9:38   ` Alexander Shiyan
  2020-10-21 14:44 ` Sascha Hauer
  1 sibling, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2020-10-19  9:05 UTC (permalink / raw)
  To: Alexander Shiyan; +Cc: barebox

Hi Alexander,

On Fri, Oct 16, 2020 at 11:49:16AM +0300, Alexander Shiyan wrote:
> Hello.
> 
> Found a regression in arm/lib32/bootm.c after a patch
> "ARM: bootm: make sure we place the kernel in free memory".
> 
> The initial memory size for the board is set to 8 MB (before reading the real value from DT),
> so the stack, malloc_space, etc. are placed in the initial 8M space.
> Then get_kernel_addresses() gets the real SDRAM area (for my board it is 64M),
> but decreases this size by the first children size (malloc_space),
> so mem_end is incorrect in this case.
> 
> barebox 2020.05.0-00393-gf5e96a296-dirty #80 Thu Oct 15 13:08:54 MSK 2020
> Board: Mega-Milas Informer EP7312
> cfi_flash 90000000.nor@0,0.of: found cfi flash at 0x90000000, size 32 MiB
> i2c-gpio i2c0.of: using pins 16 (SDA) and 35 (SCL)
> Hit any to stop autoboot:    1
> Booting entry 'nor'
> Loading ARM Linux zImage '/dev/nor0.kernel'

The problem might be that you have the kernel in a raw flash partition.
I think we have problems where we somewhere use the partition size where
we should really use the zImage size. The zImage size must be taken from
the zImage header while we just make a stat() on the file which happens
to be the whole partition for you.

Could you try and bootm the same zImage from ramfs?

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ARM bootm regression
  2020-10-19  9:05 ` Sascha Hauer
@ 2020-10-19  9:38   ` Alexander Shiyan
  0 siblings, 0 replies; 6+ messages in thread
From: Alexander Shiyan @ 2020-10-19  9:38 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

>Hi Alexander,
>
>On Fri, Oct 16, 2020 at 11:49:16AM +0300, Alexander Shiyan wrote:
>> Hello.
>> 
>> Found a regression in arm/lib32/bootm.c after a patch
>> "ARM: bootm: make sure we place the kernel in free memory".
>> 
>> The initial memory size for the board is set to 8 MB (before reading the real value from DT),
>> so the stack, malloc_space, etc. are placed in the initial 8M space.
>> Then get_kernel_addresses() gets the real SDRAM area (for my board it is 64M),
>> but decreases this size by the first children size (malloc_space),
>> so mem_end is incorrect in this case.
>> 
>> barebox 2020.05.0-00393-gf5e96a296-dirty #80 Thu Oct 15 13:08:54 MSK 2020
>> Board: Mega-Milas Informer EP7312
>> cfi_flash 90000000.nor@0,0.of: found cfi flash at 0x90000000, size 32 MiB
>> i2c-gpio i2c0.of: using pins 16 (SDA) and 35 (SCL)
>> Hit any to stop autoboot:    1
>> Booting entry 'nor'
>> Loading ARM Linux zImage '/dev/nor0.kernel'
>
>The problem might be that you have the kernel in a raw flash partition.
>I think we have problems where we somewhere use the partition size where
>we should really use the zImage size. The zImage size must be taken from
>the zImage header while we just make a stat() on the file which happens
>to be the whole partition for you.
>
>Could you try and bootm the same zImage from ramfs?
I don't understand a little what to do...

zImage size is correct (0xc00fca18-0xbfdc6000=0x336a18=3369496)
__request_region: 0xbfdc6000:0xc00fca17 outside parent resource 0xc0000000:0xc3ffffff
ERROR: bootm/zImage: failed to request memory at 0xbfdc6000 to 0xc00fca18 (3369496).

Reverting "ARM: bootm: make sure we place the kernel in free memory" fix this problem.
---
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ARM bootm regression
  2020-10-16  8:49 ARM bootm regression Alexander Shiyan
  2020-10-19  9:05 ` Sascha Hauer
@ 2020-10-21 14:44 ` Sascha Hauer
  2020-10-22  6:13   ` Alexander Shiyan
  1 sibling, 1 reply; 6+ messages in thread
From: Sascha Hauer @ 2020-10-21 14:44 UTC (permalink / raw)
  To: Alexander Shiyan; +Cc: barebox

On Fri, Oct 16, 2020 at 11:49:16AM +0300, Alexander Shiyan wrote:
> Hello.
> 
> Found a regression in arm/lib32/bootm.c after a patch
> "ARM: bootm: make sure we place the kernel in free memory".
> 
> The initial memory size for the board is set to 8 MB (before reading the real value from DT),

You could read the real value from DT earlier using libfdt, see
arch/arm/cpu/board-dt-2nd.c for usage examples. That doesn't solve it of
course when your board really has only 8MB memory.

> so the stack, malloc_space, etc. are placed in the initial 8M space.
> Then get_kernel_addresses() gets the real SDRAM area (for my board it is 64M),
> but decreases this size by the first children size (malloc_space),
> so mem_end is incorrect in this case.

Does an additional:

	if (kaddr < mem_start)
		kaddr = mem_start;

help?

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ARM bootm regression
  2020-10-21 14:44 ` Sascha Hauer
@ 2020-10-22  6:13   ` Alexander Shiyan
  2020-10-22  7:26     ` Sascha Hauer
  0 siblings, 1 reply; 6+ messages in thread
From: Alexander Shiyan @ 2020-10-22  6:13 UTC (permalink / raw)
  To: Sascha Hauer; +Cc: barebox

>Среда, 21 октября 2020, 17:44 +03:00 от Sascha Hauer <s.hauer@pengutronix.de>:
>
>On Fri, Oct 16, 2020 at 11:49:16AM +0300, Alexander Shiyan wrote:
>> Hello.
>> 
>> Found a regression in arm/lib32/bootm.c after a patch
>> "ARM: bootm: make sure we place the kernel in free memory".
>> 
>> The initial memory size for the board is set to 8 MB (before reading the real value from DT),
>You could read the real value from DT earlier using libfdt, see
>arch/arm/cpu/board-dt-2nd.c for usage examples. That doesn't solve it of
>course when your board really has only 8MB memory.
>
>> so the stack, malloc_space, etc. are placed in the initial 8M space.
>> Then get_kernel_addresses() gets the real SDRAM area (for my board it is 64M),
>> but decreases this size by the first children size (malloc_space),
>> so mem_end is incorrect in this case.
>
>Does an additional:
>
>if (kaddr < mem_start)
>kaddr = mem_start;
>
>help?

Works fine with the following modification:

		/*
		 * Make sure we do not place the image outside of the
		 * available memory.
		 */
		if (((kaddr + image_size + spacing) > mem_end) &&
		    ((mem_end - image_size - spacing) >= mem_start))
			kaddr = mem_end - image_size - spacing;

---
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ARM bootm regression
  2020-10-22  6:13   ` Alexander Shiyan
@ 2020-10-22  7:26     ` Sascha Hauer
  0 siblings, 0 replies; 6+ messages in thread
From: Sascha Hauer @ 2020-10-22  7:26 UTC (permalink / raw)
  To: Alexander Shiyan; +Cc: barebox

On Thu, Oct 22, 2020 at 09:13:27AM +0300, Alexander Shiyan wrote:
> >Среда, 21 октября 2020, 17:44 +03:00 от Sascha Hauer <s.hauer@pengutronix.de>:
> >
> >On Fri, Oct 16, 2020 at 11:49:16AM +0300, Alexander Shiyan wrote:
> >> Hello.
> >> 
> >> Found a regression in arm/lib32/bootm.c after a patch
> >> "ARM: bootm: make sure we place the kernel in free memory".
> >> 
> >> The initial memory size for the board is set to 8 MB (before reading the real value from DT),
> >You could read the real value from DT earlier using libfdt, see
> >arch/arm/cpu/board-dt-2nd.c for usage examples. That doesn't solve it of
> >course when your board really has only 8MB memory.
> >
> >> so the stack, malloc_space, etc. are placed in the initial 8M space.
> >> Then get_kernel_addresses() gets the real SDRAM area (for my board it is 64M),
> >> but decreases this size by the first children size (malloc_space),
> >> so mem_end is incorrect in this case.
> >
> >Does an additional:
> >
> >if (kaddr < mem_start)
> >kaddr = mem_start;
> >
> >help?
> 
> Works fine with the following modification:
> 
> 		/*
> 		 * Make sure we do not place the image outside of the
> 		 * available memory.
> 		 */
> 		if (((kaddr + image_size + spacing) > mem_end) &&
> 		    ((mem_end - image_size - spacing) >= mem_start))
> 			kaddr = mem_end - image_size - spacing;

Ok, nice. Can you send a formal patch for inclusion?

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-10-22  7:27 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-16  8:49 ARM bootm regression Alexander Shiyan
2020-10-19  9:05 ` Sascha Hauer
2020-10-19  9:38   ` Alexander Shiyan
2020-10-21 14:44 ` Sascha Hauer
2020-10-22  6:13   ` Alexander Shiyan
2020-10-22  7:26     ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox