]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/3.10.32/x86-smap-don-t-enable-smap-if-config_x86_smap-is-disabled.patch
drop queue-4.14/mips-make-sure-dt-memory-regions-are-valid.patch
[thirdparty/kernel/stable-queue.git] / releases / 3.10.32 / x86-smap-don-t-enable-smap-if-config_x86_smap-is-disabled.patch
CommitLineData
b18e18e8
GKH
1From 03bbd596ac04fef47ce93a730b8f086d797c3021 Mon Sep 17 00:00:00 2001
2From: "H. Peter Anvin" <hpa@linux.intel.com>
3Date: Thu, 13 Feb 2014 07:34:30 -0800
4Subject: x86, smap: Don't enable SMAP if CONFIG_X86_SMAP is disabled
5
6From: "H. Peter Anvin" <hpa@linux.intel.com>
7
8commit 03bbd596ac04fef47ce93a730b8f086d797c3021 upstream.
9
10If SMAP support is not compiled into the kernel, don't enable SMAP in
11CR4 -- in fact, we should clear it, because the kernel doesn't contain
12the proper STAC/CLAC instructions for SMAP support.
13
14Found by Fengguang Wu's test system.
15
16Reported-by: Fengguang Wu <fengguang.wu@intel.com>
17Link: http://lkml.kernel.org/r/20140213124550.GA30497@localhost
18Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
19Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
20
21---
22 arch/x86/kernel/cpu/common.c | 7 ++++++-
23 1 file changed, 6 insertions(+), 1 deletion(-)
24
25--- a/arch/x86/kernel/cpu/common.c
26+++ b/arch/x86/kernel/cpu/common.c
27@@ -284,8 +284,13 @@ static __always_inline void setup_smap(s
28 raw_local_save_flags(eflags);
29 BUG_ON(eflags & X86_EFLAGS_AC);
30
31- if (cpu_has(c, X86_FEATURE_SMAP))
32+ if (cpu_has(c, X86_FEATURE_SMAP)) {
33+#ifdef CONFIG_X86_SMAP
34 set_in_cr4(X86_CR4_SMAP);
35+#else
36+ clear_in_cr4(X86_CR4_SMAP);
37+#endif
38+ }
39 }
40
41 /*