]> git.proxmox.com Git - pve-kernel.git/blob - patches/kernel/0086-x86-boot-Relocate-definition-of-the-initial-state-of.patch
936d6b02aafd462e729aa0def57bbe07cd5bb9d2
[pve-kernel.git] / patches / kernel / 0086-x86-boot-Relocate-definition-of-the-initial-state-of.patch
1 From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2 From: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
3 Date: Fri, 27 Oct 2017 13:25:29 -0700
4 Subject: [PATCH] x86/boot: Relocate definition of the initial state of CR0
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 CVE-2017-5754
10
11 Both head_32.S and head_64.S utilize the same value to initialize the
12 control register CR0. Also, other parts of the kernel might want to access
13 this initial definition (e.g., emulation code for User-Mode Instruction
14 Prevention uses this state to provide a sane dummy value for CR0 when
15 emulating the smsw instruction). Thus, relocate this definition to a
16 header file from which it can be conveniently accessed.
17
18 Suggested-by: Borislav Petkov <bp@alien8.de>
19 Signed-off-by: Ricardo Neri <ricardo.neri-calderon@linux.intel.com>
20 Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
21 Reviewed-by: Borislav Petkov <bp@suse.de>
22 Reviewed-by: Andy Lutomirski <luto@kernel.org>
23 Cc: "Michael S. Tsirkin" <mst@redhat.com>
24 Cc: Peter Zijlstra <peterz@infradead.org>
25 Cc: Dave Hansen <dave.hansen@linux.intel.com>
26 Cc: ricardo.neri@intel.com
27 Cc: linux-mm@kvack.org
28 Cc: Paul Gortmaker <paul.gortmaker@windriver.com>
29 Cc: Huang Rui <ray.huang@amd.com>
30 Cc: Shuah Khan <shuah@kernel.org>
31 Cc: linux-arch@vger.kernel.org
32 Cc: Jonathan Corbet <corbet@lwn.net>
33 Cc: Jiri Slaby <jslaby@suse.cz>
34 Cc: "Ravi V. Shankar" <ravi.v.shankar@intel.com>
35 Cc: Denys Vlasenko <dvlasenk@redhat.com>
36 Cc: Chris Metcalf <cmetcalf@mellanox.com>
37 Cc: Brian Gerst <brgerst@gmail.com>
38 Cc: Josh Poimboeuf <jpoimboe@redhat.com>
39 Cc: Chen Yucong <slaoub@gmail.com>
40 Cc: Vlastimil Babka <vbabka@suse.cz>
41 Cc: Dave Hansen <dave.hansen@intel.com>
42 Cc: Andy Lutomirski <luto@amacapital.net>
43 Cc: Masami Hiramatsu <mhiramat@kernel.org>
44 Cc: Paolo Bonzini <pbonzini@redhat.com>
45 Cc: Andrew Morton <akpm@linux-foundation.org>
46 Cc: Linus Torvalds <torvalds@linux-foundation.org>
47 Link: https://lkml.kernel.org/r/1509135945-13762-3-git-send-email-ricardo.neri-calderon@linux.intel.com
48
49 (cherry picked from commit b0ce5b8c95c83a7b98c679b117e3d6ae6f97154b)
50 Signed-off-by: Andy Whitcroft <apw@canonical.com>
51 Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
52 (cherry picked from commit 27c31a88c22edab269abe17c0ac7db0351d26c5f)
53 Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
54 ---
55 arch/x86/include/uapi/asm/processor-flags.h | 3 +++
56 arch/x86/kernel/head_32.S | 3 ---
57 arch/x86/kernel/head_64.S | 3 ---
58 3 files changed, 3 insertions(+), 6 deletions(-)
59
60 diff --git a/arch/x86/include/uapi/asm/processor-flags.h b/arch/x86/include/uapi/asm/processor-flags.h
61 index 185f3d10c194..39946d0a1d41 100644
62 --- a/arch/x86/include/uapi/asm/processor-flags.h
63 +++ b/arch/x86/include/uapi/asm/processor-flags.h
64 @@ -151,5 +151,8 @@
65 #define CX86_ARR_BASE 0xc4
66 #define CX86_RCR_BASE 0xdc
67
68 +#define CR0_STATE (X86_CR0_PE | X86_CR0_MP | X86_CR0_ET | \
69 + X86_CR0_NE | X86_CR0_WP | X86_CR0_AM | \
70 + X86_CR0_PG)
71
72 #endif /* _UAPI_ASM_X86_PROCESSOR_FLAGS_H */
73 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
74 index 337a65377baf..7bbcdb1ea31a 100644
75 --- a/arch/x86/kernel/head_32.S
76 +++ b/arch/x86/kernel/head_32.S
77 @@ -213,9 +213,6 @@ ENTRY(startup_32_smp)
78 #endif
79
80 .Ldefault_entry:
81 -#define CR0_STATE (X86_CR0_PE | X86_CR0_MP | X86_CR0_ET | \
82 - X86_CR0_NE | X86_CR0_WP | X86_CR0_AM | \
83 - X86_CR0_PG)
84 movl $(CR0_STATE & ~X86_CR0_PG),%eax
85 movl %eax,%cr0
86
87 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
88 index a2d8541b1da4..4117c1e0b3d2 100644
89 --- a/arch/x86/kernel/head_64.S
90 +++ b/arch/x86/kernel/head_64.S
91 @@ -137,9 +137,6 @@ ENTRY(secondary_startup_64)
92 1: wrmsr /* Make changes effective */
93
94 /* Setup cr0 */
95 -#define CR0_STATE (X86_CR0_PE | X86_CR0_MP | X86_CR0_ET | \
96 - X86_CR0_NE | X86_CR0_WP | X86_CR0_AM | \
97 - X86_CR0_PG)
98 movl $CR0_STATE, %eax
99 /* Make changes effective */
100 movq %rax, %cr0
101 --
102 2.14.2
103