linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: "Kirill A. Shutemov" <kirill@shutemov.name>
To: Andy Lutomirski <luto@amacapital.net>
Cc: "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Ingo Molnar <mingo@redhat.com>, X86 ML <x86@kernel.org>,
	Thomas Gleixner <tglx@linutronix.de>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Borislav Petkov <bp@suse.de>, Andi Kleen <ak@linux.intel.com>,
	Linux-MM <linux-mm@kvack.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 8/9] x86/mm: Make __VIRTUAL_MASK_SHIFT dynamic
Date: Wed, 14 Feb 2018 20:55:48 +0300	[thread overview]
Message-ID: <20180214175548.6uxpm3bspmgqi7hs@node.shutemov.name> (raw)
In-Reply-To: <CALCETrVafx9kZwsJrihUxKszio9rJCPZJHnWSh3QC992o=zxnA@mail.gmail.com>

On Wed, Feb 14, 2018 at 05:22:58PM +0000, Andy Lutomirski wrote:
> On Wed, Feb 14, 2018 at 11:16 AM, Kirill A. Shutemov
> <kirill.shutemov@linux.intel.com> wrote:
> > For boot-time switching between paging modes, we need to be able to
> > adjust virtual mask shifts.
> >
> > The change doesn't affect the kernel image size much:
> >
> >    text    data     bss     dec     hex filename
> > 8628892 4734340 1368064 14731296         e0c820 vmlinux.before
> > 8628966 4734340 1368064 14731370         e0c86a vmlinux.after
> >
> > Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
> > ---
> >  arch/x86/entry/entry_64.S            | 12 ++++++++++++
> >  arch/x86/include/asm/page_64_types.h |  2 +-
> >  arch/x86/mm/dump_pagetables.c        | 12 ++++++++++--
> >  arch/x86/mm/kaslr.c                  |  4 +++-
> >  4 files changed, 26 insertions(+), 4 deletions(-)
> >
> > diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
> > index cd216c9431e1..1608b13a0b36 100644
> > --- a/arch/x86/entry/entry_64.S
> > +++ b/arch/x86/entry/entry_64.S
> > @@ -260,8 +260,20 @@ GLOBAL(entry_SYSCALL_64_after_hwframe)
> >          * Change top bits to match most significant bit (47th or 56th bit
> >          * depending on paging mode) in the address.
> >          */
> > +#ifdef CONFIG_X86_5LEVEL
> > +       testl   $1, pgtable_l5_enabled(%rip)
> > +       jz      1f
> > +       shl     $(64 - 57), %rcx
> > +       sar     $(64 - 57), %rcx
> > +       jmp     2f
> > +1:
> > +       shl     $(64 - 48), %rcx
> > +       sar     $(64 - 48), %rcx
> > +2:
> > +#else
> >         shl     $(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx
> >         sar     $(64 - (__VIRTUAL_MASK_SHIFT+1)), %rcx
> > +#endif
> 
> Eww.
> 
> Can't this be ALTERNATIVE "shl ... sar ...", "shl ... sar ...",
> X86_FEATURE_5LEVEL or similar?

Optimization comes in a separate patch:

https://git.kernel.org/pub/scm/linux/kernel/git/kas/linux.git/commit/?h=la57/boot-switching/wip&id=015fa3576a7f2b8bd271096bb3a12b06cdc845af

-- 
 Kirill A. Shutemov

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

  reply	other threads:[~2018-02-14 17:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-14 11:16 [PATCH 0/9] x86/mm: Dynamic memory layout Kirill A. Shutemov
2018-02-14 11:16 ` [PATCH 1/9] x86/mm/64: Make __PHYSICAL_MASK_SHIFT always 52 Kirill A. Shutemov
2018-02-14 11:16 ` [PATCH 2/9] mm/zsmalloc: Prepare to variable MAX_PHYSMEM_BITS Kirill A. Shutemov
2018-02-14 11:16 ` [PATCH 3/9] x86/mm: Make virtual memory layout movable for CONFIG_X86_5LEVEL Kirill A. Shutemov
2018-02-14 11:16 ` [PATCH 4/9] x86: Introduce pgtable_l5_enabled Kirill A. Shutemov
2018-02-14 11:16 ` [PATCH 5/9] x86/mm: Make LDT_BASE_ADDR dynamic Kirill A. Shutemov
2018-02-14 13:32   ` Kirill A. Shutemov
2018-02-14 11:16 ` [PATCH 6/9] x86/mm: Make PGDIR_SHIFT and PTRS_PER_P4D variable Kirill A. Shutemov
2018-02-14 11:16 ` [PATCH 7/9] x86/mm: Make MAX_PHYSADDR_BITS and MAX_PHYSMEM_BITS dynamic Kirill A. Shutemov
2018-02-14 11:16 ` [PATCH 8/9] x86/mm: Make __VIRTUAL_MASK_SHIFT dynamic Kirill A. Shutemov
2018-02-14 17:22   ` Andy Lutomirski
2018-02-14 17:55     ` Kirill A. Shutemov [this message]
2018-02-14 18:02       ` Andy Lutomirski
2018-02-14 11:16 ` [PATCH 9/9] x86/mm: Adjust virtual address space layout in early boot Kirill A. Shutemov
2018-02-14 12:10   ` Ingo Molnar
2018-02-14 12:19     ` Kirill A. Shutemov
2018-02-14 12:26       ` Ingo Molnar

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=20180214175548.6uxpm3bspmgqi7hs@node.shutemov.name \
    --to=kirill@shutemov.name \
    --cc=ak@linux.intel.com \
    --cc=bp@suse.de \
    --cc=hpa@zytor.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@amacapital.net \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@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;
as well as URLs for NNTP newsgroup(s).