linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Baoquan He <bhe@redhat.com>
Cc: rja@hpe.com, frank.ramsay@hpe.com, linux-kernel@vger.kernel.org,
	x86@kernel.org, mingo@redhat.com, tglx@linutronix.de,
	hpa@zytor.com, thgarnie@google.com, keescook@chromium.org,
	akpm@linux-foundation.org, yamada.masahiro@socionext.com
Subject: Re: [PATCH v2 RESEND 2/2] x86/mm/KASLR: Do not adapt the size of the direct mapping section for SGI UV system
Date: Thu, 28 Sep 2017 11:01:43 +0200	[thread overview]
Message-ID: <20170928090143.m6sog2am2ccz5dm4@gmail.com> (raw)
In-Reply-To: <20170928083112.GN16025@x1>


* Baoquan He <bhe@redhat.com> wrote:

> Hi Ingo,
> 
> On 09/28/17 at 09:56am, Ingo Molnar wrote:
> > > diff --git a/arch/x86/mm/kaslr.c b/arch/x86/mm/kaslr.c
> > > index af599167fe3c..4d68c08df82d 100644
> > > --- a/arch/x86/mm/kaslr.c
> > > +++ b/arch/x86/mm/kaslr.c
> > > @@ -27,6 +27,7 @@
> > >  #include <asm/pgtable.h>
> > >  #include <asm/setup.h>
> > >  #include <asm/kaslr.h>
> > > +#include <asm/uv/uv.h>
> > >  
> > >  #include "mm_internal.h"
> > >  
> > > @@ -123,7 +124,7 @@ void __init kernel_randomize_memory(void)
> > >  		CONFIG_RANDOMIZE_MEMORY_PHYSICAL_PADDING;
> > >  
> > >  	/* Adapt phyiscal memory region size based on available memory */
> > > -	if (memory_tb < kaslr_regions[0].size_tb)
> > > +	if (memory_tb < kaslr_regions[0].size_tb && !is_early_uv_system())
> > >  		kaslr_regions[0].size_tb = memory_tb;
> > This is really an ugly hack. Is kaslr_regions[] incorrect? If so then it should be 
> > corrected instead of uglifying the code that uses it...
> 
> Thanks for looking into this!
> 
> If on SGI UV system, the kaslr_regions[0].size_tb, namely the size of
> the direct mapping section, is incorrect. 
> 
> Its direct mapping size includes two parts:
> #1 RAM size of system
> #2 MMIOH region size which only SGI UV system has.
> 
> However, the #2 can only be got till uv_system_init() is called in
> native_smp_prepare_cpus(). That is too late for mm KASLR calculation.
> That's why I made this hack.
> 
> I checked uv_system_init() code, seems not easy to know the size of
> MMIOH region before or inside kernel_randomize_memory(). I have CCed UV
> devel experts, not sure if they have any idea about this. Otherwise,
> this patch could be the only way I can think of.
> 
> Hi Mike and Russ,
> 
> Is there any chance we can get the size of MMIOH region before mm KASLR
> code, namely before we call kernel_randomize_memory()?

I don't mind system specific quirks to hardware enumeration details, as long as 
they don't pollute generic code with such special hacks.

I.e. in this case it's wrong to allow kaslr_regions[0].size_tb to be wrong. Any 
other code that relies on it in the future will be wrong as well on UV systems.

The right quirk would be to fix that up where it gets introduced, or something 
like that.

Thanks,

	Ingo

  reply	other threads:[~2017-09-28  9:01 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-07  7:42 [PATCH v2 RESEND 0/2] x86/mm/KASLR: Do not adapt the size of the direct mapping section for SGI UV system Baoquan He
2017-09-07  7:42 ` [PATCH v2 RESEND 1/2] x86/UV: Introduce a helper function to check UV system at earlier stage Baoquan He
2017-09-14  7:29   ` Baoquan He
2017-09-14  7:49     ` Dave Young
2017-09-14  8:08       ` Baoquan He
2017-09-15  0:47         ` Dave Young
2017-09-15  0:55         ` Dave Young
2017-09-07  7:42 ` [PATCH v2 RESEND 2/2] x86/mm/KASLR: Do not adapt the size of the direct mapping section for SGI UV system Baoquan He
2017-09-28  7:56   ` Ingo Molnar
2017-09-28  8:31     ` Baoquan He
2017-09-28  9:01       ` Ingo Molnar [this message]
2017-09-28 14:10         ` Mike Travis
2017-09-30 11:25           ` Baoquan He
2018-05-17  3:18           ` Baoquan He
2018-05-17 15:06             ` Ramsay, Frank
2018-05-17 15:47               ` Mike Travis
     [not found]             ` <53301a1e-e817-912f-cf7d-0000b078c7a3@hpe.com>
     [not found]               ` <20180523000306.GY24627@MiWiFi-R3L-srv>
     [not found]                 ` <7ce3cc80-3991-f914-c539-9fa38256ea4b@hpe.com>
2018-05-31  3:26                   ` Baoquan He
2017-09-14  1:44 ` [PATCH v2 RESEND 0/2] " 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=20170928090143.m6sog2am2ccz5dm4@gmail.com \
    --to=mingo@kernel.org \
    --cc=akpm@linux-foundation.org \
    --cc=bhe@redhat.com \
    --cc=frank.ramsay@hpe.com \
    --cc=hpa@zytor.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rja@hpe.com \
    --cc=tglx@linutronix.de \
    --cc=thgarnie@google.com \
    --cc=x86@kernel.org \
    --cc=yamada.masahiro@socionext.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;
as well as URLs for NNTP newsgroup(s).