linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] Change the default link address for pSeries zImage kernels.
@ 2008-06-23  8:13 Tony Breeds
  2008-06-23  8:16 ` Tony Breeds
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Tony Breeds @ 2008-06-23  8:13 UTC (permalink / raw)
  To: Paul Mackerras, linuxppc-dev

Currently we set the start of the .text section to be 4Mb for pSeries.
In situations where the zImage is > 8Mb we'll fail to boot (due to
overlapping with OF).  Move .text in a zImage from 4MB to 64MB (well past OF).

We still will not be able to load large zImage unless we also move OF,
to that end, add a note to the zImage ELF to move OF to 32Mb.  If this
is the very first kernel booted then we'll need to moev OF manually by
setting real-base.

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
---
 arch/powerpc/boot/addnote.c         |    2 +-
 arch/powerpc/boot/oflib.c           |   15 +++++++++++++--
 arch/powerpc/boot/wrapper           |   14 ++++++++++++--
 arch/powerpc/boot/zImage.coff.lds.S |    1 -
 arch/powerpc/boot/zImage.lds.S      |    1 -
 5 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/boot/addnote.c b/arch/powerpc/boot/addnote.c
index 8041a98..b1e5611 100644
--- a/arch/powerpc/boot/addnote.c
+++ b/arch/powerpc/boot/addnote.c
@@ -25,7 +25,7 @@ char arch[] = "PowerPC";
 #define N_DESCR	6
 unsigned int descr[N_DESCR] = {
 	0xffffffff,		/* real-mode = true */
-	0x00c00000,		/* real-base, i.e. where we expect OF to be */
+	0x02000000,		/* real-base, i.e. where we expect OF to be */
 	0xffffffff,		/* real-size */
 	0xffffffff,		/* virt-base */
 	0xffffffff,		/* virt-size */
diff --git a/arch/powerpc/boot/oflib.c b/arch/powerpc/boot/oflib.c
index 95b8fd6..93a1a84 100644
--- a/arch/powerpc/boot/oflib.c
+++ b/arch/powerpc/boot/oflib.c
@@ -168,8 +168,19 @@ void *of_claim(unsigned long virt, unsigned long size, unsigned long align)
 
 void *of_vmlinux_alloc(unsigned long size)
 {
-	void *p = malloc(size);
-
+	unsigned long start = (unsigned long)_start, end = (unsigned long)_end;
+	void *addr;
+	void *p;
+
+	/* With some older POWER4 firmware the we need to claim the area
+	 * the kernel will reside in.  Newer firmwares don't need this so we
+	 * just ignore the return value.
+	 */
+	addr = of_claim(start, end - start, 0);
+	printf("Trying to claim from 0x%lx to 0x%lx (0x%lx) got %p\r\n",
+	       start, end, end - start, addr);
+
+	p = malloc(size);
 	if (!p)
 		fatal("Can't allocate memory for kernel image!\n\r");
 
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index d6c96d9..22bc26e 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -138,14 +138,20 @@ objflags=-S
 tmp=$tmpdir/zImage.$$.o
 ksection=.kernel:vmlinux.strip
 isection=.kernel:initrd
+link_address='0x400000'
 
 case "$platform" in
-pmac|pseries|chrp)
+pseries)
+    platformo=$object/of.o
+    link_address='0x4000000'
+    ;;
+pmac|chrp)
     platformo=$object/of.o
     ;;
 coff)
     platformo=$object/of.o
     lds=$object/zImage.coff.lds
+    link_address='0x500000'
     ;;
 miboot|uboot)
     # miboot and U-boot want just the bare bits, not an ELF binary
@@ -190,6 +196,7 @@ ps3)
     objflags="-O binary --set-section-flags=.bss=contents,alloc,load,data"
     ksection=.kernel:vmlinux.bin
     isection=.kernel:initrd
+    link_address=''
     ;;
 ep88xc|ep405|ep8248e)
     platformo="$object/fixed-head.o $object/$platform.o"
@@ -268,7 +275,10 @@ if [ -n "$dtb" ]; then
 fi
 
 if [ "$platform" != "miboot" ]; then
-    ${CROSS}ld -m elf32ppc -T $lds -o "$ofile" \
+    if [ -n "$link_address" ] ; then
+        text_start="-Ttext $link_address --defsym _start=$link_address"
+    fi
+    ${CROSS}ld -m elf32ppc -T $lds $text_start -o "$ofile" \
 	$platformo $tmp $object/wrapper.a
     rm $tmp
 fi
diff --git a/arch/powerpc/boot/zImage.coff.lds.S b/arch/powerpc/boot/zImage.coff.lds.S
index fe87a90..856dc78 100644
--- a/arch/powerpc/boot/zImage.coff.lds.S
+++ b/arch/powerpc/boot/zImage.coff.lds.S
@@ -3,7 +3,6 @@ ENTRY(_zimage_start_opd)
 EXTERN(_zimage_start_opd)
 SECTIONS
 {
-  . = (5*1024*1024);
   _start = .;
   .text      :
   {
diff --git a/arch/powerpc/boot/zImage.lds.S b/arch/powerpc/boot/zImage.lds.S
index f6e380f..0962d62 100644
--- a/arch/powerpc/boot/zImage.lds.S
+++ b/arch/powerpc/boot/zImage.lds.S
@@ -3,7 +3,6 @@ ENTRY(_zimage_start)
 EXTERN(_zimage_start)
 SECTIONS
 {
-  . = (4*1024*1024);
   _start = .;
   .text      :
   {
-- 
1.5.5.4

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

* Re: [PATCH 1/1] Change the default link address for pSeries zImage kernels.
  2008-06-23  8:13 [PATCH 1/1] Change the default link address for pSeries zImage kernels Tony Breeds
@ 2008-06-23  8:16 ` Tony Breeds
  2008-06-23  9:30 ` Adrian Reber
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Tony Breeds @ 2008-06-23  8:16 UTC (permalink / raw)
  To: Paul Mackerras, linuxppc-dev

On Mon, Jun 23, 2008 at 06:13:23PM +1000, Tony Breeds wrote:
> Currently we set the start of the .text section to be 4Mb for pSeries.
> In situations where the zImage is > 8Mb we'll fail to boot (due to
> overlapping with OF).  Move .text in a zImage from 4MB to 64MB (well past OF).
> 
> We still will not be able to load large zImage unless we also move OF,
> to that end, add a note to the zImage ELF to move OF to 32Mb.  If this
> is the very first kernel booted then we'll need to moev OF manually by
> setting real-base.
> 
> Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
> ---

Ooops should have said that this has been boot tested on power
3,4,5,5+,6 and JS20.  POWER4 firmware seems to have aproblem manually
reloacting realbase but asside from that it booted.

Yours Tony

  linux.conf.au    http://www.marchsouth.org/
  Jan 19 - 24 2009 The Australian Linux Technical Conference!

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

* Re: [PATCH 1/1] Change the default link address for pSeries zImage kernels.
  2008-06-23  8:13 [PATCH 1/1] Change the default link address for pSeries zImage kernels Tony Breeds
  2008-06-23  8:16 ` Tony Breeds
@ 2008-06-23  9:30 ` Adrian Reber
  2008-06-23  9:57   ` Benjamin Herrenschmidt
  2008-06-23 12:20 ` Michael Ellerman
  2008-06-24  4:20 ` [PATCH v2] " Tony Breeds
  3 siblings, 1 reply; 8+ messages in thread
From: Adrian Reber @ 2008-06-23  9:30 UTC (permalink / raw)
  To: Tony Breeds; +Cc: linuxppc-dev, Paul Mackerras

On Mon, Jun 23, 2008 at 06:13:23PM +1000, Tony Breeds wrote:
> Currently we set the start of the .text section to be 4Mb for pSeries.
> In situations where the zImage is > 8Mb we'll fail to boot (due to
> overlapping with OF).  Move .text in a zImage from 4MB to 64MB (well past OF).
> 
> We still will not be able to load large zImage unless we also move OF,
> to that end, add a note to the zImage ELF to move OF to 32Mb.  If this
> is the very first kernel booted then we'll need to moev OF manually by
> setting real-base.

Does this change also affect kernels for SLOF based systems (JS20, JS21,
Bimini/Powerstation, QS21, QS22)?

To avoid exactly that problem SLOF moved to a bit below 256MB on all
those platforms (about 220MB). There should be still enough space
between 64MB and 220MB to boot large kernels. It is, however, decreased
by 60MB.

		Adrian

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

* Re: [PATCH 1/1] Change the default link address for pSeries zImage kernels.
  2008-06-23  9:30 ` Adrian Reber
@ 2008-06-23  9:57   ` Benjamin Herrenschmidt
  0 siblings, 0 replies; 8+ messages in thread
From: Benjamin Herrenschmidt @ 2008-06-23  9:57 UTC (permalink / raw)
  To: Adrian Reber; +Cc: linuxppc-dev, Paul Mackerras

On Mon, 2008-06-23 at 11:30 +0200, Adrian Reber wrote:
> On Mon, Jun 23, 2008 at 06:13:23PM +1000, Tony Breeds wrote:
> > Currently we set the start of the .text section to be 4Mb for pSeries.
> > In situations where the zImage is > 8Mb we'll fail to boot (due to
> > overlapping with OF).  Move .text in a zImage from 4MB to 64MB (well past OF).
> > 
> > We still will not be able to load large zImage unless we also move OF,
> > to that end, add a note to the zImage ELF to move OF to 32Mb.  If this
> > is the very first kernel booted then we'll need to moev OF manually by
> > setting real-base.
> 
> Does this change also affect kernels for SLOF based systems (JS20, JS21,
> Bimini/Powerstation, QS21, QS22)?

Yes, they use the same zImage.

> To avoid exactly that problem SLOF moved to a bit below 256MB on all
> those platforms (about 220MB). There should be still enough space
> between 64MB and 220MB to boot large kernels. It is, however, decreased
> by 60MB.

That should leave plenty of space...

Cheers,
Ben.

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

* Re: [PATCH 1/1] Change the default link address for pSeries zImage kernels.
  2008-06-23  8:13 [PATCH 1/1] Change the default link address for pSeries zImage kernels Tony Breeds
  2008-06-23  8:16 ` Tony Breeds
  2008-06-23  9:30 ` Adrian Reber
@ 2008-06-23 12:20 ` Michael Ellerman
  2008-06-24  4:20 ` [PATCH v2] " Tony Breeds
  3 siblings, 0 replies; 8+ messages in thread
From: Michael Ellerman @ 2008-06-23 12:20 UTC (permalink / raw)
  To: Tony Breeds; +Cc: linuxppc-dev, Paul Mackerras

[-- Attachment #1: Type: text/plain, Size: 1149 bytes --]

On Mon, 2008-06-23 at 18:13 +1000, Tony Breeds wrote:
> Currently we set the start of the .text section to be 4Mb for pSeries.
> In situations where the zImage is > 8Mb we'll fail to boot (due to
> overlapping with OF).  Move .text in a zImage from 4MB to 64MB (well past OF).
...
> diff --git a/arch/powerpc/boot/oflib.c b/arch/powerpc/boot/oflib.c
> index 95b8fd6..93a1a84 100644
> --- a/arch/powerpc/boot/oflib.c
> +++ b/arch/powerpc/boot/oflib.c
> @@ -168,8 +168,19 @@ void *of_claim(unsigned long virt, unsigned long size, unsigned long align)
>  
>  void *of_vmlinux_alloc(unsigned long size)
>  {
> -	void *p = malloc(size);
> -
> +	unsigned long start = (unsigned long)_start, end = (unsigned long)_end;
> +	void *addr;
> +	void *p;
> +
> +	/* With some older POWER4 firmware the we need to claim the area

Sorry, typo/grammaro :/                     ^^^^^^

cheers

-- 
Michael Ellerman
OzLabs, IBM Australia Development Lab

wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)

We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]

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

* [PATCH v2] Change the default link address for pSeries zImage kernels.
  2008-06-23  8:13 [PATCH 1/1] Change the default link address for pSeries zImage kernels Tony Breeds
                   ` (2 preceding siblings ...)
  2008-06-23 12:20 ` Michael Ellerman
@ 2008-06-24  4:20 ` Tony Breeds
  2008-07-02 15:04   ` Olaf Hering
  3 siblings, 1 reply; 8+ messages in thread
From: Tony Breeds @ 2008-06-24  4:20 UTC (permalink / raw)
  To: Paul Mackerras, linuxppc-dev

Currently we set the start of the .text section to be 4Mb for pSeries.
In situations where the zImage is > 8Mb we'll fail to boot (due to
overlapping with OF).  Move .text in a zImage from 4MB to 64MB (well past OF).

We still will not be able to load large zImage unless we also move OF,
to that end, add a note to the zImage ELF to move OF to 32Mb.  If this
is the very first kernel booted then we'll need to move OF manually by
setting real-base.

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
---
Booted on:
	3,4,5,5+,6,JS20 and JS21 (running slof 1.7.0-1)
Changes since v1:
	typo fixes in commit message and comments

 arch/powerpc/boot/addnote.c         |    2 +-
 arch/powerpc/boot/oflib.c           |   15 +++++++++++++--
 arch/powerpc/boot/wrapper           |   14 ++++++++++++--
 arch/powerpc/boot/zImage.coff.lds.S |    1 -
 arch/powerpc/boot/zImage.lds.S      |    1 -
 5 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/arch/powerpc/boot/addnote.c b/arch/powerpc/boot/addnote.c
index 8041a98..b1e5611 100644
--- a/arch/powerpc/boot/addnote.c
+++ b/arch/powerpc/boot/addnote.c
@@ -25,7 +25,7 @@ char arch[] = "PowerPC";
 #define N_DESCR	6
 unsigned int descr[N_DESCR] = {
 	0xffffffff,		/* real-mode = true */
-	0x00c00000,		/* real-base, i.e. where we expect OF to be */
+	0x02000000,		/* real-base, i.e. where we expect OF to be */
 	0xffffffff,		/* real-size */
 	0xffffffff,		/* virt-base */
 	0xffffffff,		/* virt-size */
diff --git a/arch/powerpc/boot/oflib.c b/arch/powerpc/boot/oflib.c
index 95b8fd6..b0ec9cf 100644
--- a/arch/powerpc/boot/oflib.c
+++ b/arch/powerpc/boot/oflib.c
@@ -168,8 +168,19 @@ void *of_claim(unsigned long virt, unsigned long size, unsigned long align)
 
 void *of_vmlinux_alloc(unsigned long size)
 {
-	void *p = malloc(size);
-
+	unsigned long start = (unsigned long)_start, end = (unsigned long)_end;
+	void *addr;
+	void *p;
+
+	/* With some older POWER4 firmware we need to claim the area the kernel
+	 * will reside in.  Newer firmwares don't need this so we just ignore
+	 * the return value.
+	 */
+	addr = of_claim(start, end - start, 0);
+	printf("Trying to claim from 0x%lx to 0x%lx (0x%lx) got %p\r\n",
+	       start, end, end - start, addr);
+
+	p = malloc(size);
 	if (!p)
 		fatal("Can't allocate memory for kernel image!\n\r");
 
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index d6c96d9..22bc26e 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -138,14 +138,20 @@ objflags=-S
 tmp=$tmpdir/zImage.$$.o
 ksection=.kernel:vmlinux.strip
 isection=.kernel:initrd
+link_address='0x400000'
 
 case "$platform" in
-pmac|pseries|chrp)
+pseries)
+    platformo=$object/of.o
+    link_address='0x4000000'
+    ;;
+pmac|chrp)
     platformo=$object/of.o
     ;;
 coff)
     platformo=$object/of.o
     lds=$object/zImage.coff.lds
+    link_address='0x500000'
     ;;
 miboot|uboot)
     # miboot and U-boot want just the bare bits, not an ELF binary
@@ -190,6 +196,7 @@ ps3)
     objflags="-O binary --set-section-flags=.bss=contents,alloc,load,data"
     ksection=.kernel:vmlinux.bin
     isection=.kernel:initrd
+    link_address=''
     ;;
 ep88xc|ep405|ep8248e)
     platformo="$object/fixed-head.o $object/$platform.o"
@@ -268,7 +275,10 @@ if [ -n "$dtb" ]; then
 fi
 
 if [ "$platform" != "miboot" ]; then
-    ${CROSS}ld -m elf32ppc -T $lds -o "$ofile" \
+    if [ -n "$link_address" ] ; then
+        text_start="-Ttext $link_address --defsym _start=$link_address"
+    fi
+    ${CROSS}ld -m elf32ppc -T $lds $text_start -o "$ofile" \
 	$platformo $tmp $object/wrapper.a
     rm $tmp
 fi
diff --git a/arch/powerpc/boot/zImage.coff.lds.S b/arch/powerpc/boot/zImage.coff.lds.S
index fe87a90..856dc78 100644
--- a/arch/powerpc/boot/zImage.coff.lds.S
+++ b/arch/powerpc/boot/zImage.coff.lds.S
@@ -3,7 +3,6 @@ ENTRY(_zimage_start_opd)
 EXTERN(_zimage_start_opd)
 SECTIONS
 {
-  . = (5*1024*1024);
   _start = .;
   .text      :
   {
diff --git a/arch/powerpc/boot/zImage.lds.S b/arch/powerpc/boot/zImage.lds.S
index f6e380f..0962d62 100644
--- a/arch/powerpc/boot/zImage.lds.S
+++ b/arch/powerpc/boot/zImage.lds.S
@@ -3,7 +3,6 @@ ENTRY(_zimage_start)
 EXTERN(_zimage_start)
 SECTIONS
 {
-  . = (4*1024*1024);
   _start = .;
   .text      :
   {
-- 
1.5.5.4

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

* Re: [PATCH v2] Change the default link address for pSeries zImage kernels.
  2008-06-24  4:20 ` [PATCH v2] " Tony Breeds
@ 2008-07-02 15:04   ` Olaf Hering
  2008-07-04  3:14     ` Tony Breeds
  0 siblings, 1 reply; 8+ messages in thread
From: Olaf Hering @ 2008-07-02 15:04 UTC (permalink / raw)
  To: Tony Breeds; +Cc: linuxppc-dev, Paul Mackerras

On Tue, Jun 24, Tony Breeds wrote:

> Currently we set the start of the .text section to be 4Mb for pSeries.
> In situations where the zImage is > 8Mb we'll fail to boot (due to
> overlapping with OF).  Move .text in a zImage from 4MB to 64MB (well past OF).
> 
> We still will not be able to load large zImage unless we also move OF,
> to that end, add a note to the zImage ELF to move OF to 32Mb.  If this
> is the very first kernel booted then we'll need to move OF manually by
> setting real-base.

Setting real-base to what?

What currently happens with a large boot file is:
Firmware loads the zImage at load-base, finds that the ELF file is too
large to fit into the memory window and stops.

With your patch, firmware loads 12566528 bytes, and starts the zImage.
The result is a truncated file, the initrd will be corrupted, kernel
panic in populate_rootfs().

The only system where firmware relocates itself from 12MB to 32MB is a
p640 with firmware version NAN04194.
All other systems seem to ignore the NOTE section, real-base remains at
0xc00000

So I do not think your patch is a real improvement,
clear error vs. silent corruption.

Do you happen to know how to automate the changing the value of
real-base? The addnote change has appearently no effect on recent
systems.

Olaf

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

* Re: [PATCH v2] Change the default link address for pSeries zImage kernels.
  2008-07-02 15:04   ` Olaf Hering
@ 2008-07-04  3:14     ` Tony Breeds
  0 siblings, 0 replies; 8+ messages in thread
From: Tony Breeds @ 2008-07-04  3:14 UTC (permalink / raw)
  To: Olaf Hering; +Cc: linuxppc-dev, Paul Mackerras

On Wed, Jul 02, 2008 at 05:04:32PM +0200, Olaf Hering wrote:
 
> Setting real-base to what?

32Mb, or any other value big enough to allow the tftp to fit in
${real-base} - ${load-base}.  I admitt it's far from ideal.
 
> What currently happens with a large boot file is:
> Firmware loads the zImage at load-base, finds that the ELF file is too
> large to fit into the memory window and stops.
> 
> With your patch, firmware loads 12566528 bytes, and starts the zImage.
> The result is a truncated file, the initrd will be corrupted, kernel
> panic in populate_rootfs().

Okay that's not the behaviour I see here on the POWER4 machines, they
grab the firt n bytes (probabbly 12566528), and then abort with a
message about image being too large and it cannot be split.
(something akin to https://bugzilla.novell.com/show_bug.cgi?id=350212 )
 
> The only system where firmware relocates itself from 12MB to 32MB is a
> p640 with firmware version NAN04194.
> All other systems seem to ignore the NOTE section, real-base remains at
> 0xc00000

Add I thought /all/ POWER4 systems were unable to relocate OF
(regardless of whether the request is from the NOTE or from set-env
real-base).
 
> So I do not think your patch is a real improvement,
> clear error vs. silent corruption.
> 
> Do you happen to know how to automate the changing the value of
> real-base? The addnote change has appearently no effect on recent
> systems.

It's there for POWER5 and on.  I was sure that no POWER4 machines could
be reloacted, but you say that your p640 can.

Yours Tony

  linux.conf.au    http://www.marchsouth.org/
  Jan 19 - 24 2009 The Australian Linux Technical Conference!

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

end of thread, other threads:[~2008-07-04  3:14 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-23  8:13 [PATCH 1/1] Change the default link address for pSeries zImage kernels Tony Breeds
2008-06-23  8:16 ` Tony Breeds
2008-06-23  9:30 ` Adrian Reber
2008-06-23  9:57   ` Benjamin Herrenschmidt
2008-06-23 12:20 ` Michael Ellerman
2008-06-24  4:20 ` [PATCH v2] " Tony Breeds
2008-07-02 15:04   ` Olaf Hering
2008-07-04  3:14     ` Tony Breeds

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).