linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: linux-kernel@vger.kernel.org, Thomas Gleixner <tglx@linutronix.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>,
	Andy Lutomirski <luto@kernel.org>, Ingo Molnar <mingo@kernel.org>,
	Borislav Petkov <bp@alien8.de>, Brian Gerst <brgerst@gmail.com>,
	Denys Vlasenko <dvlasenk@redhat.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Josh Poimboeuf <jpoimboe@redhat.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Rik van Riel <riel@redhat.com>,
	daniel.gruss@iaik.tugraz.at, hughd@google.com,
	keescook@google.com, linux-mm@kvack.org,
	michael.schwarz@iaik.tugraz.at, moritz.lipp@iaik.tugraz.at,
	richard.fellner@student.tugraz.at
Subject: [PATCH 3/6] x86/mm/kaiser: Allow PCID with nokaiser
Date: Wed, 29 Nov 2017 11:33:04 +0100	[thread overview]
Message-ID: <20171129103512.769862503@infradead.org> (raw)
In-Reply-To: 20171129103301.131535445@infradead.org

[-- Attachment #1: peterz-nokaiser-dont-kill-pcid.patch --]
[-- Type: text/plain, Size: 2594 bytes --]

Currently KAISER kills PCID on platforms that lack INVPCID, even when
nokaiser.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 arch/x86/include/asm/tlbflush.h |    9 +++++----
 arch/x86/mm/init.c              |    2 +-
 arch/x86/mm/tlb.c               |    7 ++++++-
 3 files changed, 12 insertions(+), 6 deletions(-)

--- a/arch/x86/include/asm/tlbflush.h
+++ b/arch/x86/include/asm/tlbflush.h
@@ -9,6 +9,7 @@
 #include <asm/cpufeature.h>
 #include <asm/special_insns.h>
 #include <asm/smp.h>
+#include <asm/kaiser.h>
 
 static inline void __invpcid(unsigned long pcid, unsigned long addr,
 			     unsigned long type)
@@ -355,12 +356,12 @@ static inline void __native_flush_tlb(vo
 		 * CR4 has X86_CR4_PCIDE set.  In other words, this does
 		 * not fully flush the TLB if PCIDs are in use.
 		 *
-		 * With KAISER and PCIDs, the means that we did not
+		 * With KAISER and PCIDs, that means that we did not
 		 * flush the user PCID.  Warn if it gets called.
 		 */
-		if (IS_ENABLED(CONFIG_KAISER))
-			WARN_ON_ONCE(this_cpu_read(cpu_tlbstate.cr4) &
-				     X86_CR4_PCIDE);
+		if (IS_ENABLED(CONFIG_KAISER) && kaiser_enabled)
+			WARN_ON_ONCE(this_cpu_read(cpu_tlbstate.cr4) & X86_CR4_PCIDE);
+
 		/*
 		 * If current->mm == NULL then we borrow a mm
 		 * which may change during a task switch and
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -219,7 +219,7 @@ static void setup_pcid(void)
 		 * have KAISER and do not have INVPCID.
 		 */
 		if (!IS_ENABLED(CONFIG_X86_GLOBAL_PAGES) &&
-		    !boot_cpu_has(X86_FEATURE_INVPCID)) {
+		    kaiser_enabled && !boot_cpu_has(X86_FEATURE_INVPCID)) {
 			setup_clear_cpu_cap(X86_FEATURE_PCID);
 			return;
 		}
--- a/arch/x86/mm/tlb.c
+++ b/arch/x86/mm/tlb.c
@@ -6,13 +6,14 @@
 #include <linux/interrupt.h>
 #include <linux/export.h>
 #include <linux/cpu.h>
+#include <linux/debugfs.h>
 
 #include <asm/tlbflush.h>
 #include <asm/mmu_context.h>
 #include <asm/cache.h>
 #include <asm/apic.h>
 #include <asm/uv/uv.h>
-#include <linux/debugfs.h>
+#include <asm/kaiser.h>
 
 /*
  *	TLB flushing, formerly SMP-only
@@ -115,6 +116,10 @@ static void flush_user_asid(pgd_t *pgd,
 	 */
 	if (!cpu_feature_enabled(X86_FEATURE_PCID))
 		return;
+
+	if (!kaiser_enabled)
+		return;
+
 	/*
 	 * With PCIDs enabled, write_cr3() only flushes TLB
 	 * entries for the current (kernel) ASID.  This leaves


--
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>

  parent reply	other threads:[~2017-11-29 10:35 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-29 10:33 [PATCH 0/6] more KAISER bits Peter Zijlstra
2017-11-29 10:33 ` [PATCH 1/6] x86/mm/kaiser: Add some static Peter Zijlstra
2017-11-29 10:33 ` [PATCH 2/6] x86/mm/kaiser: Fix inconsistency in SAVE_AND_SWITCH_TO_KERNEL_CR3 Peter Zijlstra
2017-11-29 10:33 ` Peter Zijlstra [this message]
2017-11-29 10:33 ` [PATCH 4/6] x86/mm/kaiser: Support PCID without INVPCID Peter Zijlstra
2017-11-29 10:48   ` Peter Zijlstra
2017-11-29 11:48   ` Peter Zijlstra
2017-11-29 12:31   ` Peter Zijlstra
2017-11-29 13:38     ` Peter Zijlstra
2017-11-29 10:33 ` [PATCH 5/6] x86/mm/kaiser: Optimize RESTORE_CR3 Peter Zijlstra
2017-11-29 20:02   ` Borislav Petkov
2017-11-29 20:06     ` Peter Zijlstra
2017-11-29 10:33 ` [PATCH 6/6] x86/mm/kaiser: Optimize __native_flush_tlb Peter Zijlstra
2017-11-30 12:43   ` Peter Zijlstra
2017-11-30 13:13     ` Peter Zijlstra
2017-11-29 14:26 ` [PATCH 0/6] more KAISER bits Thomas Gleixner
2017-11-29 16:02   ` Thomas Gleixner
2017-11-29 18:03     ` Dave Hansen

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=20171129103512.769862503@infradead.org \
    --to=peterz@infradead.org \
    --cc=bp@alien8.de \
    --cc=brgerst@gmail.com \
    --cc=daniel.gruss@iaik.tugraz.at \
    --cc=dave.hansen@linux.intel.com \
    --cc=dvlasenk@redhat.com \
    --cc=hpa@zytor.com \
    --cc=hughd@google.com \
    --cc=jpoimboe@redhat.com \
    --cc=keescook@google.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=luto@kernel.org \
    --cc=michael.schwarz@iaik.tugraz.at \
    --cc=mingo@kernel.org \
    --cc=moritz.lipp@iaik.tugraz.at \
    --cc=richard.fellner@student.tugraz.at \
    --cc=riel@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=torvalds@linux-foundation.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).