public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Alexander van Heukelum <heukelum@mailshack.com>
To: Mike Travis <travis@sgi.com>
Cc: Ingo Molnar <mingo@elte.hu>, Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, heukelum@fastmail.fm
Subject: Re: [PATCH 1/2] boot: increase stack size for kernel boot loader decompressor
Date: Mon, 7 Apr 2008 23:44:34 +0200	[thread overview]
Message-ID: <20080407214434.GA5296@mailshack.com> (raw)
In-Reply-To: <47FA6478.1070301@sgi.com>

On Mon, Apr 07, 2008 at 11:14:16AM -0700, Mike Travis wrote:
> Alexander van Heukelum wrote:
> > On Fri, Apr 04, 2008 at 06:30:15PM -0700, Mike Travis wrote:
> >>   * Increase stack size for the kernel bootloader decompressor.  This is
> >>     needed to boot a kernel with NR_CPUS = 4096.  I tested with 8k stack
> >>     size but that wasn't sufficient.
> >>
> >> Based on:
> >> 	git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git
> >>     +   x86/latest          .../x86/linux-2.6-x86.git
> >>     +   sched-devel/latest  .../mingo/linux-2.6-sched-devel.git
> >>
> >> Signed-off-by: Mike Travis <travis@sgi.com>
> >> ---
> >>  arch/x86/boot/compressed/head_64.S |    2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> --- linux-2.6.25-rc5.orig/arch/x86/boot/compressed/head_64.S
> >> +++ linux-2.6.25-rc5/arch/x86/boot/compressed/head_64.S
> >> @@ -314,5 +314,5 @@ gdt_end:
> >>  /* Stack for uncompression */
> >>  	.balign 4
> >>  user_stack:
> >> -	.fill 4096,4,0
> >> +	.fill 16384,4,0
> > --------------^^^ * ^
> > 
> > Changed from 16K to 64K. I wonder what is using so much space on
> > this stack?
> > 
> >>  user_stack_end:
> >>
> >> -- 
> 
> Hi,
> 
> That is a good question.  It's pretty difficult to debug at that early
> stage (any ideas are certainly welcome!).  It's mostly hit and miss (and
> handy access to the reset button ;-)  I could do some further research
> but since it's "throwaway" memory (at least I think it is), then I didn't
> think it important to pursue.

It's certainly not important enough to put much time in. I tried
MAXSMP on top of just Ingo's -x86 with qemu, though, but it wouldn't
crash. I set the stack size to 16 bytes, and it still booted happily
(of course there is still about 11 kilobytes of inflate code which
is then overwritten by stack use).

I did see that the malloc space that the inflate code is using is
taken from _after_ the end of the bss. I don't see how this is
protected from being used/overwritten. Changing the stack size changes
the memory layout a bit... maybe you were so unlucky to create a
vmlinux image that was just barely smaller than some threshold and
increasing the stack size made the decompression/relocation area be
located somewhere else?

Test patch follows.

Greetings,
	Alexander

> Thanks,
> Mike

diff --git a/arch/x86/boot/compressed/vmlinux_32.lds b/arch/x86/boot/compressed/vmlinux_32.lds
index bb3c483..c858e30 100644
--- a/arch/x86/boot/compressed/vmlinux_32.lds
+++ b/arch/x86/boot/compressed/vmlinux_32.lds
@@ -39,5 +39,6 @@ SECTIONS
 		*(.bss.*)
 		*(COMMON)
 		_end = . ;
+		_real_end = . + 0x4000;
 	}
 }
diff --git a/arch/x86/boot/compressed/vmlinux_64.lds b/arch/x86/boot/compressed/vmlinux_64.lds
index 7e5c720..9bef3cd 100644
--- a/arch/x86/boot/compressed/vmlinux_64.lds
+++ b/arch/x86/boot/compressed/vmlinux_64.lds
@@ -44,5 +44,6 @@ SECTIONS
 		pgtable = . ;
 		. = . + 4096 * 6;
 		_heap = .;
+		_heap_end = . + 0x7000;
 	}
 }


  reply	other threads:[~2008-04-07 21:48 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-04-05  1:30 [PATCH 0/2] NR_CPUS: increase maximum NR_CPUS to 4096 Mike Travis
2008-04-05  1:30 ` [PATCH 1/2] boot: increase stack size for kernel boot loader decompressor Mike Travis
2008-04-05 13:46   ` Alexander van Heukelum
2008-04-07 18:14     ` Mike Travis
2008-04-07 21:44       ` Alexander van Heukelum [this message]
2008-04-08  8:23         ` Ingo Molnar
2008-04-08 10:54           ` [PATCH] x86: cleanup boot-heap usage Alexander van Heukelum
2008-04-08 18:39             ` Yinghai Lu
2008-04-08 14:56           ` [PATCH 1/2] boot: increase stack size for kernel boot loader decompressor Mike Travis
2008-04-08 17:54           ` Yinghai Lu
2008-04-09 15:08             ` Alexander van Heukelum
2008-04-09 17:58               ` Yinghai Lu
2008-04-09 17:59               ` Yinghai Lu
2008-04-08 12:20         ` Alexander van Heukelum
2008-04-08 13:41           ` Ingo Molnar
2008-04-08 15:10             ` Mike Travis
2008-04-08 15:39               ` Ingo Molnar
2008-04-08 19:09                 ` Mike Travis
2008-04-08 21:48                 ` Mike Travis
2008-04-05  1:30 ` [PATCH 2/2] x86: Modify Kconfig to allow up to 4096 cpus Mike Travis
2008-04-08 21:53 ` [PATCH 0/2] NR_CPUS: increase maximum NR_CPUS to 4096 Yinghai Lu
2008-04-08 22:03   ` Mike Travis
2008-04-08 22:32     ` Yinghai Lu
  -- strict thread matches above, loose matches on Subject: below --
2008-03-26  1:41 Mike Travis
2008-03-26  1:41 ` [PATCH 1/2] boot: increase stack size for kernel boot loader decompressor Mike Travis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080407214434.GA5296@mailshack.com \
    --to=heukelum@mailshack.com \
    --cc=akpm@linux-foundation.org \
    --cc=heukelum@fastmail.fm \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=tglx@linutronix.de \
    --cc=travis@sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox