public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Baoquan He <bhe@redhat.com>
To: Borislav Petkov <bp@suse.de>
Cc: tglx@linutronix.de, hpa@zytor.com, mingo@redhat.com,
	linux-kernel@vger.kernel.org, x86@kernel.org,
	keescook@chromium.org, yinghai@kernel.org, anderson@redhat.com,
	luto@kernel.org, thgarnie@google.com, kuleshovmail@gmail.com
Subject: Re: [PATCH v4 1/3] x86: Introduce a new constant KERNEL_MAPPING_SIZE
Date: Fri, 3 Mar 2017 21:11:52 +0800	[thread overview]
Message-ID: <20170303131152.GG18391@x1> (raw)
In-Reply-To: <20170303125213.GF18391@x1>

On 03/03/17 at 08:52pm, Baoquan He wrote:
> On 03/03/17 at 01:16pm, Borislav Petkov wrote:
> > On Fri, Mar 03, 2017 at 08:06:16PM +0800, Baoquan He wrote:
> > > OK, I am trying to make things clearer, seems I failed. I thought kernel
> > > iamge size is only allowed to be 512M at most, but can be mapped into 1G
> > > region.
> > 
> > It doesn't look like it. But we could be missing something. You could
> > try some git archeology to find out why the 512M limit. It could be "no
> > reason", it could be remnant from 32-bit, it could be anything...
> > 
> > There's the full git history here too:
> > 
> > https://git.kernel.org/cgit/linux/kernel/git/history/history.git
> > 
> > in case it helps.
> 

And another meaning of defining kernel iamge size and mapping size
differently is we can randomize the limited kernel image in the mapping
area. If they are the same or kernel image can be very large, the
position will be fixed or very few, kernel text KASLR will be
meaningless. E.g 512M of kernel image, 16M aligned, there are 32 slots
we can choose to position. If kernel image can be 1g either, no
possibility to randomize at all.

> Thanks, have got all related change history below. In the last commit log
> Ingo wrote he was just trying to give more space to kernel and push
> modules up a bit, and it should be enough for a few years. My thought of
> introducing KERNEL_MAPPING_SIZE is mainly because in commit 85eb69a1
> ("x86: increase the kernel text limit to 512 MB") Ingo is trying to
> increase kernel image size, since the really large static arrays and
> building allyesconfig kernel are all bloating kernel image. I feel Ingo
> is very careful to keep the pace to increase it, guess people don't want
> to see kernel image can be made by default as 1G big at one time without
> obvious reason. AFAIK, peopel sometime have to tell how much space it
> will increae with their new feature or big change. This is a very good
> self alert with a limited but usually enough value, 512M, let people pay
> attention to the elegacy but not always many lines of code, think more
> and refector code. And linker script is the guard to check it. 
> 
> Not sure if I make myself clear. I hesitated to do that earlier, so
> finally introduce KERNEL_MAPPING_SIZE. Surely in the current case, as
> you said, 1G is hard-constrainted line, unless we decide to give a
> larger space for kernel mapping or put it other place since Intel people
> have been working on 5-level page mapping thing, we don't lack virtual
> space, but kernel mapping is too constrainted. Even though we have more
> than 1G kernel mapping space, image size still should be limited to a
> small value, like plus 128M or + 256M.
> 
> ***
> commit 85eb69a16aab5a394ce043c2131319eae35e6493
> Author: Ingo Molnar <mingo@elte.hu>
> Date:   Thu Feb 21 12:50:51 2008 +0100
> 
>     x86: increase the kernel text limit to 512 MB
>     
>     people sometimes do crazy stuff like building really large static
>     arrays into their kernels or building allyesconfig kernels. Give
>     more space to the kernel and push modules up a bit: kernel has
>     512 MB and modules have 1.5 GB.
>     
>     Should be enough for a few years ;-)
> 
> ***
> d4afe414    x86: rename KERNEL_TEXT_SIZE => KERNEL_IMAGE_SIZE
> Rename it to be KERNEL_IMAGE_SIZE
> 
> ***
> 88f3aec7    x86: fix spontaneous reboot with allyesconfig bzImage
> In this commit Ingo changed KERNEL_TEXT_SIZE from 40M to 128M.
> 
> > 
> > > It's fine to me, thing can be solved anyway. Will repost with
> > > KERNEL_IMAGE_SIZE by default 1G.
> > 
> > I think you should slow down first and try to find out why the 512
> > default. Then we can talk about changes.
> > 
> > -- 
> > Regards/Gruss,
> >     Boris.
> > 
> > SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
> > -- 

  reply	other threads:[~2017-03-03 13:23 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-02 12:54 [PATCH v4 0/3] x86/64/KASLR: Change kernel mapping size to 1G unconditionally Baoquan He
2017-02-02 12:54 ` [PATCH v4 1/3] x86: Introduce a new constant KERNEL_MAPPING_SIZE Baoquan He
2017-02-14 17:32   ` Borislav Petkov
2017-02-26  4:09     ` Baoquan He
2017-03-03 11:43       ` Borislav Petkov
2017-03-03 12:06         ` Baoquan He
2017-03-03 12:16           ` Borislav Petkov
2017-03-03 12:52             ` Baoquan He
2017-03-03 13:11               ` Baoquan He [this message]
2017-03-03 14:28                 ` Borislav Petkov
2017-03-03 15:07                   ` Baoquan He
2017-03-03 15:08                     ` Baoquan He
2017-03-03 15:23                       ` Borislav Petkov
2017-03-04 10:10                         ` Baoquan He
2017-03-04 11:55                           ` Borislav Petkov
2017-03-04 13:59                             ` Baoquan He
2017-03-16  8:14                         ` Ingo Molnar
2017-03-16  9:44                           ` Baoquan He
2017-02-02 12:54 ` [PATCH v4 2/3] x86/64/KASLR: Change kernel mapping size to 1G unconditionally Baoquan He
2017-02-02 12:54 ` [PATCH v4 3/3] x86/64/doc: Update the ranges of kernel text and modules mapping Baoquan He
2017-02-02 19:40 ` [PATCH v4 0/3] x86/64/KASLR: Change kernel mapping size to 1G unconditionally Kees Cook
2017-03-04 14:26 ` Baoquan He

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=20170303131152.GG18391@x1 \
    --to=bhe@redhat.com \
    --cc=anderson@redhat.com \
    --cc=bp@suse.de \
    --cc=hpa@zytor.com \
    --cc=keescook@chromium.org \
    --cc=kuleshovmail@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=thgarnie@google.com \
    --cc=x86@kernel.org \
    --cc=yinghai@kernel.org \
    /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