Commit-ID:  5e8105950a8b3e03e805299b4d05020ee4eda31a
Gitweb:     https://git.kernel.org/tip/5e8105950a8b3e03e805299b4d05020ee4eda31a
Author:     Joerg Roedel <jroe...@suse.de>
AuthorDate: Wed, 18 Jul 2018 11:41:15 +0200
Committer:  Thomas Gleixner <t...@linutronix.de>
CommitDate: Fri, 20 Jul 2018 01:11:48 +0200

x86/mm/pti: Add Warning when booting on a PCID capable CPU

Warn the user in case the performance can be significantly improved by
switching to a 64-bit kernel.

Suggested-by: Andy Lutomirski <l...@kernel.org>
Signed-off-by: Joerg Roedel <jroe...@suse.de>
Signed-off-by: Thomas Gleixner <t...@linutronix.de>
Tested-by: Pavel Machek <pa...@ucw.cz>
Cc: "H . Peter Anvin" <h...@zytor.com>
Cc: linux...@kvack.org
Cc: Linus Torvalds <torva...@linux-foundation.org>
Cc: Dave Hansen <dave.han...@intel.com>
Cc: Josh Poimboeuf <jpoim...@redhat.com>
Cc: Juergen Gross <jgr...@suse.com>
Cc: Peter Zijlstra <pet...@infradead.org>
Cc: Borislav Petkov <b...@alien8.de>
Cc: Jiri Kosina <jkos...@suse.cz>
Cc: Boris Ostrovsky <boris.ostrov...@oracle.com>
Cc: Brian Gerst <brge...@gmail.com>
Cc: David Laight <david.lai...@aculab.com>
Cc: Denys Vlasenko <dvlas...@redhat.com>
Cc: Eduardo Valentin <edu...@amazon.com>
Cc: Greg KH <gre...@linuxfoundation.org>
Cc: Will Deacon <will.dea...@arm.com>
Cc: aligu...@amazon.com
Cc: daniel.gr...@iaik.tugraz.at
Cc: hu...@google.com
Cc: keesc...@google.com
Cc: Andrea Arcangeli <aarca...@redhat.com>
Cc: Waiman Long <ll...@redhat.com>
Cc: "David H . Gutteridge" <dhgutteri...@sympatico.ca>
Cc: j...@8bytes.org
Link: 
https://lkml.kernel.org/r/1531906876-13451-39-git-send-email-j...@8bytes.org

---
 arch/x86/mm/pti.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/arch/x86/mm/pti.c b/arch/x86/mm/pti.c
index a536ecc91847..7b1c85759005 100644
--- a/arch/x86/mm/pti.c
+++ b/arch/x86/mm/pti.c
@@ -517,6 +517,28 @@ void __init pti_init(void)
 
        pr_info("enabled\n");
 
+#ifdef CONFIG_X86_32
+       /*
+        * We check for X86_FEATURE_PCID here. But the init-code will
+        * clear the feature flag on 32 bit because the feature is not
+        * supported on 32 bit anyway. To print the warning we need to
+        * check with cpuid directly again.
+        */
+       if (cpuid_ecx(0x1) && BIT(17)) {
+               /* Use printk to work around pr_fmt() */
+               printk(KERN_WARNING "\n");
+               printk(KERN_WARNING 
"************************************************************\n");
+               printk(KERN_WARNING "** WARNING! WARNING! WARNING! WARNING! 
WARNING! WARNING!  **\n");
+               printk(KERN_WARNING "**                                         
               **\n");
+               printk(KERN_WARNING "** You are using 32-bit PTI on a 64-bit 
PCID-capable CPU. **\n");
+               printk(KERN_WARNING "** Your performance will increase 
dramatically if you     **\n");
+               printk(KERN_WARNING "** switch to a 64-bit kernel!              
               **\n");
+               printk(KERN_WARNING "**                                         
               **\n");
+               printk(KERN_WARNING "** WARNING! WARNING! WARNING! WARNING! 
WARNING! WARNING!  **\n");
+               printk(KERN_WARNING 
"************************************************************\n");
+       }
+#endif
+
        pti_clone_user_shared();
 
        /* Undo all global bits from the init pagetables in head_64.S: */

Reply via email to