mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Dave Hansen <dave.hansen@linux.intel.com>
To: linux-kernel@vger.kernel.org
Cc: x86@kernel.org, Dave Hansen <dave.hansen@linux.intel.com>,
	tglx@linutronix.de, luto@kernel.org, bp@suse.de,
	brgerst@gmail.com, dvlasenk@redhat.com, hpa@zytor.com,
	jpoimboe@redhat.com, torvalds@linux-foundation.org,
	peterz@infradead.org, riel@redhat.com
Subject: [PATCH] x86/kpti: WARN if kernel memory mapped to userspace is non-global
Date: Fri, 15 Dec 2017 16:01:45 -0800	[thread overview]
Message-ID: <20171216000145.3328ACA0@viggo.jf.intel.com> (raw)


From: Dave Hansen <dave.hansen@linux.intel.com>

All memory being mapped out to userspace is shared.  That means that
it is both safe and _expected_ to have the page table Global bit set.

If a PMD is found without Global set, it either a place that could be
performing better, or something unexpected is being mapped out to
userspace.  Both of those are things for which a warning is good.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Borislav Petkov <bp@suse.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Rik van Riel <riel@redhat.com>
---

 b/arch/x86/mm/kpti.c |    3 +++
 1 file changed, 3 insertions(+)

diff -puN arch/x86/mm/kpti.c~kaiser-set-global-in-kernel-for-shared arch/x86/mm/kpti.c
--- a/arch/x86/mm/kpti.c~kaiser-set-global-in-kernel-for-shared	2017-12-15 09:47:52.884717268 -0800
+++ b/arch/x86/mm/kpti.c	2017-12-15 10:00:39.134715357 -0800
@@ -157,6 +157,9 @@ kpti_clone_pmds(unsigned long start, uns
 		if (WARN_ON(!target_pmd))
 			return;
 
+		/* Only clone PMDs which we *intend* to share: */
+		WARN_ON_ONCE(!(pmd_flags(*target_pmd) & _PAGE_GLOBAL));
+
 		/*
 		 * Copy the PMD.  That is, the kernelmode and usermode
 		 * tables will share the last-level page tables of this
_

                 reply	other threads:[~2017-12-16  0:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20171216000145.3328ACA0@viggo.jf.intel.com \
    --to=dave.hansen@linux.intel.com \
    --cc=bp@suse.de \
    --cc=brgerst@gmail.com \
    --cc=dvlasenk@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jpoimboe@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=peterz@infradead.org \
    --cc=riel@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

Powered by JetHome