]> git.proxmox.com Git - pve-kernel.git/blame - patches/kernel/0276-x86-enter-MACROS-to-set-clear-IBRS-and-set-IBPB.patch
fix syscall retpoline
[pve-kernel.git] / patches / kernel / 0276-x86-enter-MACROS-to-set-clear-IBRS-and-set-IBPB.patch
CommitLineData
035dbe67
FG
1From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2From: Tim Chen <tim.c.chen@linux.intel.com>
3Date: Fri, 15 Sep 2017 18:04:53 -0700
4Subject: [PATCH] x86/enter: MACROS to set/clear IBRS and set IBPB
5MIME-Version: 1.0
6Content-Type: text/plain; charset=UTF-8
7Content-Transfer-Encoding: 8bit
8
9CVE-2017-5753
10CVE-2017-5715
11
12Setup macros to control IBRS and IBPB
13
14Signed-off-by: Tim Chen <tim.c.chen@linux.intel.com>
15Signed-off-by: Andy Whitcroft <apw@canonical.com>
16Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
17(cherry picked from commit 171d754fe3b783d361555cf2569e68a7b0e0d54a)
18Signed-off-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>
19---
20 arch/x86/include/asm/spec_ctrl.h | 52 ++++++++++++++++++++++++++++++++++++++++
21 1 file changed, 52 insertions(+)
22 create mode 100644 arch/x86/include/asm/spec_ctrl.h
23
24diff --git a/arch/x86/include/asm/spec_ctrl.h b/arch/x86/include/asm/spec_ctrl.h
25new file mode 100644
26index 000000000000..7f8bb09b6acb
27--- /dev/null
28+++ b/arch/x86/include/asm/spec_ctrl.h
29@@ -0,0 +1,52 @@
30+#ifndef _ASM_X86_SPEC_CTRL_H
31+#define _ASM_X86_SPEC_CTRL_H
32+
33+#include <linux/stringify.h>
34+#include <asm/msr-index.h>
35+#include <asm/cpufeatures.h>
36+#include <asm/alternative-asm.h>
37+
38+#ifdef __ASSEMBLY__
39+
40+#define __ASM_ENABLE_IBRS \
41+ pushq %rax; \
42+ pushq %rcx; \
43+ pushq %rdx; \
44+ movl $MSR_IA32_SPEC_CTRL, %ecx; \
45+ movl $0, %edx; \
46+ movl $FEATURE_ENABLE_IBRS, %eax; \
47+ wrmsr; \
48+ popq %rdx; \
49+ popq %rcx; \
50+ popq %rax
51+#define __ASM_ENABLE_IBRS_CLOBBER \
52+ movl $MSR_IA32_SPEC_CTRL, %ecx; \
53+ movl $0, %edx; \
54+ movl $FEATURE_ENABLE_IBRS, %eax; \
55+ wrmsr;
56+#define __ASM_DISABLE_IBRS \
57+ pushq %rax; \
58+ pushq %rcx; \
59+ pushq %rdx; \
60+ movl $MSR_IA32_SPEC_CTRL, %ecx; \
61+ movl $0, %edx; \
62+ movl $0, %eax; \
63+ wrmsr; \
64+ popq %rdx; \
65+ popq %rcx; \
66+ popq %rax
67+
68+.macro ENABLE_IBRS
69+ALTERNATIVE "", __stringify(__ASM_ENABLE_IBRS), X86_FEATURE_SPEC_CTRL
70+.endm
71+
72+.macro ENABLE_IBRS_CLOBBER
73+ALTERNATIVE "", __stringify(__ASM_ENABLE_IBRS_CLOBBER), X86_FEATURE_SPEC_CTRL
74+.endm
75+
76+.macro DISABLE_IBRS
77+ALTERNATIVE "", __stringify(__ASM_DISABLE_IBRS), X86_FEATURE_SPEC_CTRL
78+.endm
79+
80+#endif /* __ASSEMBLY__ */
81+#endif /* _ASM_X86_SPEC_CTRL_H */
82--
832.14.2
84