From: Thomas Garnier <thgarnie@google.com>
To: Borislav Petkov <bp@suse.de>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H . Peter Anvin" <hpa@zytor.com>,
Andrey Ryabinin <aryabinin@virtuozzo.com>,
Alexander Potapenko <glider@google.com>,
Dmitry Vyukov <dvyukov@google.com>,
Kees Cook <keescook@chromium.org>,
Andy Lutomirski <luto@kernel.org>,
Paul Gortmaker <paul.gortmaker@windriver.com>,
Andy Lutomirski <luto@amacapital.net>,
"Rafael J . Wysocki" <rjw@rjwysocki.net>,
Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
Jiri Kosina <jikos@kernel.org>,
Matt Fleming <matt@codeblueprint.co.uk>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Juergen Gross <jgross@suse.com>,
Rusty Russell <rusty@rustcorp.com.au>,
Peter Zijlstra <peterz@infradead.org>,
Christian Borntraeger <borntraeger@de.ibm.com>,
"Luis R . Rodriguez" <mcgrof@kernel.org>,
He Chen <he.chen@linux.inte>
Subject: Re: [PATCH v3 1/4] x86/mm: Adapt MODULES_END based on Fixmap section size
Date: Wed, 15 Feb 2017 07:40:51 -0800 [thread overview]
Message-ID: <CAJcbSZEsCzBQEFELm1wbc4DP2=dZTCFYfsb-eX0ifoCKF4EQUw@mail.gmail.com> (raw)
In-Reply-To: <20170215135824.tflwuf3esu2npwwo@pd.tnic>
On Wed, Feb 15, 2017 at 5:58 AM, Borislav Petkov <bp@suse.de> wrote:
>
> On Tue, Feb 14, 2017 at 11:42:56AM -0800, Thomas Garnier wrote:
> > This patch aligns MODULES_END to the beginning of the Fixmap section.
> > It optimizes the space available for both sections. The address is
> > pre-computed based on the number of pages required by the Fixmap
> > section.
> >
> > It will allow GDT remapping in the Fixmap section. The current
> > MODULES_END static address does not provide enough space for the kernel
> > to support a large number of processors.
> >
> > Signed-off-by: Thomas Garnier <thgarnie@google.com>
> > ---
> > Based on next-20170213
> > ---
> > arch/x86/include/asm/fixmap.h | 8 ++++++++
> > arch/x86/include/asm/pgtable_64_types.h | 3 ---
> > arch/x86/kernel/module.c | 1 +
> > arch/x86/mm/dump_pagetables.c | 1 +
> > arch/x86/mm/kasan_init_64.c | 1 +
> > 5 files changed, 11 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
> > index 8554f960e21b..20231189e0e3 100644
> > --- a/arch/x86/include/asm/fixmap.h
> > +++ b/arch/x86/include/asm/fixmap.h
> > @@ -132,6 +132,14 @@ enum fixed_addresses {
> >
> > extern void reserve_top_address(unsigned long reserve);
> >
> > +/* On 64-bit, the module sections ends with the start of the fixmap */
> > +#ifdef CONFIG_X86_64
> > +#define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
> > +#define MODULES_END __fix_to_virt(__end_of_fixed_addresses + 1)
> > +#define MODULES_LEN (MODULES_END - MODULES_VADDR)
> > +#endif /* CONFIG_X86_64 */
>
> JFYI: so there's another patchset which adds KERNEL_MAPPING_SIZE:
>
> https://lkml.kernel.org/r/1486040077-3719-1-git-send-email-bhe@redhat.com
>
> and makes it a 1G, i.e., the KASLR default. I guess the above will have
> to be KERNEL_MAPPING_SIZE then.
>
> And why are you moving those to fixmap.h? What's wrong with
> including fixmap.h into pgtable_64_types.h so that you can get
> __end_of_fixed_addresses?
>
> FWIW, I didn't even have to add any includes with my .config, i.e., that builds:
>
I tried to add fixmap.h and I thought I tried without too but maybe
not, I will try to adapt it on v4.
> ---
> diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
> index 3a264200c62f..eda7fa856fa9 100644
> --- a/arch/x86/include/asm/pgtable_64_types.h
> +++ b/arch/x86/include/asm/pgtable_64_types.h
> @@ -67,7 +67,7 @@ typedef struct { pteval_t pte; } pte_t;
> #endif /* CONFIG_RANDOMIZE_MEMORY */
> #define VMALLOC_END (VMALLOC_START + _AC((VMALLOC_SIZE_TB << 40) - 1, UL))
> #define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
> -#define MODULES_END _AC(0xffffffffff000000, UL)
> +#define MODULES_END __fix_to_virt(__end_of_fixed_addresses + 1)
> #define MODULES_LEN (MODULES_END - MODULES_VADDR)
> #define ESPFIX_PGD_ENTRY _AC(-2, UL)
> #define ESPFIX_BASE_ADDR (ESPFIX_PGD_ENTRY << PGDIR_SHIFT)
> ---
>
> but I wouldn't be surprised if some strange configuration would need it.
>
> > #define FIXADDR_SIZE (__end_of_permanent_fixed_addresses << PAGE_SHIFT)
> > #define FIXADDR_START (FIXADDR_TOP - FIXADDR_SIZE)
> >
> > diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
> > index 3a264200c62f..de8bace10200 100644
> > --- a/arch/x86/include/asm/pgtable_64_types.h
> > +++ b/arch/x86/include/asm/pgtable_64_types.h
> > @@ -66,9 +66,6 @@ typedef struct { pteval_t pte; } pte_t;
> > #define VMEMMAP_START __VMEMMAP_BASE
> > #endif /* CONFIG_RANDOMIZE_MEMORY */
> > #define VMALLOC_END (VMALLOC_START + _AC((VMALLOC_SIZE_TB << 40) - 1, UL))
> > -#define MODULES_VADDR (__START_KERNEL_map + KERNEL_IMAGE_SIZE)
> > -#define MODULES_END _AC(0xffffffffff000000, UL)
>
> How much of an ABI breakage would that be? See
> Documentation/x86/x86_64/mm.txt.
>
> With my .config MODULES_END becomes 0xffffffffff1fe000 and it'll remain
> dynamic depending on .config. No idea how much in userspace relies on
> MODULES_END being static 0xffffffffff000000...
>
> Hmm.
>
Why do you think they rely on it being static? The VSYSCALL address is
not changed for example.
> --
> Regards/Gruss,
> Boris.
>
> SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton, HRB 21284 (AG Nürnberg)
> --
Thanks for the feedback.
--
Thomas
next prev parent reply other threads:[~2017-02-15 15:40 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-14 19:42 [PATCH v3 1/4] x86/mm: Adapt MODULES_END based on Fixmap section size Thomas Garnier
2017-02-14 19:42 ` [PATCH v3 2/4] x86: Remap GDT tables in the Fixmap section Thomas Garnier
2017-02-15 15:37 ` Boris Ostrovsky
2017-02-15 15:41 ` Thomas Garnier
2017-02-14 19:42 ` [PATCH v3 3/4] x86: Make the GDT remapping read-only on 64-bit Thomas Garnier
2017-02-14 19:42 ` [PATCH v3 4/4] KVM: VMX: Simplify segment_base Thomas Garnier
2017-02-15 3:57 ` Andy Lutomirski
2017-02-15 15:44 ` Thomas Garnier
2017-02-17 17:49 ` Jim Mattson
2017-02-17 20:11 ` Thomas Garnier
2017-02-17 21:00 ` Jim Mattson
2017-02-17 22:01 ` Thomas Garnier
2017-02-20 16:56 ` Andy Lutomirski
2017-02-20 17:28 ` Thomas Garnier
2017-02-20 17:39 ` Thomas Garnier
2017-02-21 8:03 ` Ingo Molnar
2017-02-21 10:28 ` Paolo Bonzini
2017-02-22 6:34 ` Ingo Molnar
2017-02-15 13:58 ` [PATCH v3 1/4] x86/mm: Adapt MODULES_END based on Fixmap section size Borislav Petkov
2017-02-15 15:40 ` Thomas Garnier [this message]
2017-02-15 15:49 ` Borislav Petkov
2017-02-15 21:08 ` Borislav Petkov
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='CAJcbSZEsCzBQEFELm1wbc4DP2=dZTCFYfsb-eX0ifoCKF4EQUw@mail.gmail.com' \
--to=thgarnie@google.com \
--cc=ard.biesheuvel@linaro.org \
--cc=aryabinin@virtuozzo.com \
--cc=boris.ostrovsky@oracle.com \
--cc=borntraeger@de.ibm.com \
--cc=bp@suse.de \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=he.chen@linux.inte \
--cc=hpa@zytor.com \
--cc=jgross@suse.com \
--cc=jikos@kernel.org \
--cc=keescook@chromium.org \
--cc=len.brown@intel.com \
--cc=luto@amacapital.net \
--cc=luto@kernel.org \
--cc=matt@codeblueprint.co.uk \
--cc=mcgrof@kernel.org \
--cc=mingo@redhat.com \
--cc=paul.gortmaker@windriver.com \
--cc=pavel@ucw.cz \
--cc=peterz@infradead.org \
--cc=rjw@rjwysocki.net \
--cc=rusty@rustcorp.com.au \
--cc=tglx@linutronix.de \
/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).