mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joerg Roedel <joro@8bytes.org>
To: Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@redhat.com>
Cc: hpa@zytor.com, Linus Torvalds <torvalds@linux-foundation.org>,
	Dave Hansen <dave.hansen@intel.com>,
	Andy Lutomirski <luto@amacapital.net>,
	Borislav Petkov <bp@alien8.de>, Jiri Kosina <jkosina@suse.cz>,
	linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	x86@kernel.org, Joerg Roedel <joro@8bytes.org>
Subject: [PATCH 0/3] x86/pti: Call pti_init() after mark_readonly()
Date: Tue,  3 Jul 2018 13:52:23 +0200	[thread overview]
Message-ID: <1530618746-23116-1-git-send-email-joro@8bytes.org> (raw)

Hi,

here is a small patch-set to move the call to pti_init()
after mark_readonly() has run. The purpose of pti_inti() is to
initialize the kernel-mappings in the user-space page-table
by mapping kernel-text, entry-text, espfix and vsyscall
mappings into the user-space page-table.

These mappings only make sense when they have exactly the
same permissions as in the kernel page-table wrt.
read/write/execute with the global bit set (which we set in
shared mappings for performance reasons).

Since the mappings are copied only once and are not updated
later, we need to copy them when they are finished, which is
not before mark_readonly() has run.

Calling pti_init() earlier worked for now on x86-64 because
the sections that are cloned are at least 2M aligned and not
changed by later code. But that is still fragile because
pti_init() always needs special care when kernel mappings or
the elf-layout is changed or extended. Further it doesn't
work on x86-32 because the elf sections are not 2M aligned
there.

So move the call to pti_init() after all the kernel-mappings
have been finished.

Any useful feedback appreciated.


Thanks,

	Joerg

Joerg Roedel (3):
  x86/pti: Move pti_init() code out of __init
  x86/mm/pti: Call pti_init() after mark_readonly()
  x86/pti: Call pti_clone_kernel_text() from pti_init()

 arch/x86/entry/vsyscall/vsyscall_64.c |  2 +-
 arch/x86/include/asm/pti.h            |  2 --
 arch/x86/mm/init_64.c                 |  6 ------
 arch/x86/mm/pti.c                     | 19 ++++++++++---------
 init/main.c                           |  8 ++++++--
 5 files changed, 17 insertions(+), 20 deletions(-)

-- 
2.7.4


             reply	other threads:[~2018-07-03 11:52 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-03 11:52 Joerg Roedel [this message]
2018-07-03 11:52 ` [PATCH 1/3] x86/pti: Move pti_init() code out of __init Joerg Roedel
2018-07-03 11:52 ` [PATCH 2/3] x86/pti: Call pti_init() after mark_readonly() Joerg Roedel
2018-07-03 11:52 ` [PATCH 3/3] x86/pti: Call pti_clone_kernel_text() from pti_init() Joerg Roedel
2018-07-10 13:19 ` [PATCH 0/3] x86/pti: Call pti_init() after mark_readonly() Joerg Roedel
2018-07-10 20:25   ` Thomas Gleixner

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=1530618746-23116-1-git-send-email-joro@8bytes.org \
    --to=joro@8bytes.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@intel.com \
    --cc=hpa@zytor.com \
    --cc=jkosina@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@amacapital.net \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --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

Powered by JetHome