mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Yinghai Lu" <yhlu.kernel@gmail.com>
To: "Alexander van Heukelum" <heukelum@fastmail.fm>
Cc: "Ingo Molnar" <mingo@elte.hu>,
	"Alexander van Heukelum" <heukelum@mailshack.com>,
	"Mike Travis" <travis@sgi.com>,
	"Thomas Gleixner" <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	"Andrew Morton" <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] boot: increase stack size for kernel boot loader decompressor
Date: Wed, 9 Apr 2008 10:59:40 -0700	[thread overview]
Message-ID: <86802c440804091059l54592e07n4590b3ecebf5cb28@mail.gmail.com> (raw)
In-Reply-To: <1207753698.11287.1246953549@webmail.messagingengine.com>

On Wed, Apr 9, 2008 at 8:08 AM, Alexander van Heukelum
<heukelum@fastmail.fm> wrote:
>
>  On Tue, 8 Apr 2008 10:54:15 -0700, "Yinghai Lu" <yhlu.kernel@gmail.com>
>  said:
>
> > On Tue, Apr 8, 2008 at 1:23 AM, Ingo Molnar <mingo@elte.hu> wrote:
>  > >
>  > >  * Alexander van Heukelum <heukelum@mailshack.com> wrote:
>  > >
>  > >  > 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.
>  > >
>  > >  that's a really interesting theory.
>  > >
>  > >  FWIIW, i've been booting allyesconfig bzImages for a long time (with
>  > >  only minimal amount of drivers disabled - mostly old ISA ones that
>  > >  assume the presence of the real hardware), and they boot and work fine
>  > >  on both 32-bit and 64-bit typical whitebox PCs. That means huge bzImages
>  > >  that decompresses into a ~41 MB kernel image. I'd expect that to be a
>  > >  rather severe test of the decompressor.
>  >
>  > i don't that Alexander's patch is needed.
>
>  Hello Yinghai Lu,
>
>  Indeed, I now think it is not needed either. The decompression is
>  done in-place nowadays: the (compressed) image is moved to a high
>  memory address first, then the decompression is done starting at
>  the low end of the buffer. It is guaranteed that the output never
>  overwrites the input, and the decompression code, the stack, and
>  the heap are all at higher addresses than the input buffer. The
>  same goes for the pagetables needed for x86_64.
>
>
>  > also because Alex move heap before _end,
>  > we may need add some extra for buffer offset
>  >
>  >         /* Replace the compressed data size with the uncompressed size */
>  >         subl    input_len(%ebp), %ebx
>  >         movl    output_len(%ebp), %eax
>  >         addl    %eax, %ebx
>  >         /* Add 8 bytes for every 32K input block */
>  >         shrl    $12, %eax
>  >         addl    %eax, %ebx
>  >         /* Add 32K + 18 bytes of extra slack and align on a 4K boundary
>  >         */
>  >         addl    $(32768 + 18 + 4095), %ebx
>  >         andl    $~4095, %ebx =============================> need add
>  > heap size too.
>  > ....
>
>  No, that size is accounted for automatically: the code computes the
>  buffer size needed (including slack) minus the buffer size that is
>  already available (in the embedded gzip-file). The image is moved
>  by this amount (rounded up to a page). So that part is fine.

just wonder if Ingo have very big vmlinux, that +32K + 18 formula still works.

YH

  parent reply	other threads:[~2008-04-09 17:59 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
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 [this message]
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=86802c440804091059l54592e07n4590b3ecebf5cb28@mail.gmail.com \
    --to=yhlu.kernel@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=heukelum@fastmail.fm \
    --cc=heukelum@mailshack.com \
    --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

Powered by JetHome