| From: Andy Lutomirski <luto@kernel.org> |
| Date: Thu, 29 Jun 2017 08:53:19 -0700 |
| Subject: x86/mm: Disable PCID on 32-bit kernels |
| |
| commit cba4671af7550e008f7a7835f06df0763825bf3e upstream. |
| |
| 32-bit kernels on new hardware will see PCID in CPUID, but PCID can |
| only be used in 64-bit mode. Rather than making all PCID code |
| conditional, just disable the feature on 32-bit builds. |
| |
| Signed-off-by: Andy Lutomirski <luto@kernel.org> |
| Reviewed-by: Nadav Amit <nadav.amit@gmail.com> |
| Reviewed-by: Borislav Petkov <bp@suse.de> |
| Reviewed-by: Thomas Gleixner <tglx@linutronix.de> |
| Cc: Andrew Morton <akpm@linux-foundation.org> |
| Cc: Arjan van de Ven <arjan@linux.intel.com> |
| Cc: Borislav Petkov <bp@alien8.de> |
| Cc: Dave Hansen <dave.hansen@intel.com> |
| Cc: Linus Torvalds <torvalds@linux-foundation.org> |
| Cc: Mel Gorman <mgorman@suse.de> |
| Cc: Peter Zijlstra <peterz@infradead.org> |
| Cc: Rik van Riel <riel@redhat.com> |
| Cc: linux-mm@kvack.org |
| Link: http://lkml.kernel.org/r/2e391769192a4d31b808410c383c6bf0734bc6ea.1498751203.git.luto@kernel.org |
| Signed-off-by: Ingo Molnar <mingo@kernel.org> |
| Signed-off-by: Hugh Dickins <hughd@google.com> |
| Signed-off-by: Ben Hutchings <ben@decadent.org.uk> |
| --- |
| arch/x86/kernel/cpu/bugs.c | 8 ++++++++ |
| arch/x86/kernel/cpu/common.c | 5 +++++ |
| 2 files changed, 13 insertions(+) |
| |
| diff --git a/arch/x86/kernel/cpu/bugs.c b/arch/x86/kernel/cpu/bugs.c |
| index 46674fbb62ba..ad95476a08b9 100644 |
| --- a/arch/x86/kernel/cpu/bugs.c |
| +++ b/arch/x86/kernel/cpu/bugs.c |
| @@ -159,6 +159,14 @@ static void __init check_config(void) |
| |
| void __init check_bugs(void) |
| { |
| +#ifdef CONFIG_X86_32 |
| + /* |
| + * Regardless of whether PCID is enumerated, the SDM says |
| + * that it can't be enabled in 32-bit mode. |
| + */ |
| + setup_clear_cpu_cap(X86_FEATURE_PCID); |
| +#endif |
| + |
| identify_boot_cpu(); |
| #ifndef CONFIG_SMP |
| printk(KERN_INFO "CPU: "); |
| diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c |
| index 1477e7046838..e7dd20a3c498 100644 |
| --- a/arch/x86/kernel/cpu/common.c |
| +++ b/arch/x86/kernel/cpu/common.c |
| @@ -934,6 +934,11 @@ void __cpuinit identify_secondary_cpu(struct cpuinfo_x86 *c) |
| BUG_ON(c == &boot_cpu_data); |
| identify_cpu(c); |
| #ifdef CONFIG_X86_32 |
| + /* |
| + * Regardless of whether PCID is enumerated, the SDM says |
| + * that it can't be enabled in 32-bit mode. |
| + */ |
| + clear_cpu_cap(c, X86_FEATURE_PCID); |
| enable_sep_cpu(); |
| #endif |
| mtrr_ap_init(); |
| |