Skip to content

Commit 06696d2

Browse files
KAGA-KOKOkonradwilk
authored andcommitted
x86/speculation: Create spec-ctrl.h to avoid include hell
Having everything in nospec-branch.h creates a hell of dependencies when adding the prctl based switching mechanism. Move everything which is not required in nospec-branch.h to spec-ctrl.h and fix up the includes in the relevant files. Signed-off-by: Thomas Gleixner <[email protected]> Reviewed-by: Konrad Rzeszutek Wilk <[email protected]> Reviewed-by: Ingo Molnar <[email protected]> (cherry picked from commit 28a2775) Orabug: 28034177 CVE: CVE-2018-3639 Signed-off-by: Konrad Rzeszutek Wilk <[email protected]> Tested-by: Mihai Carabas <[email protected]> Reviewed-by: Mihai Carabas <[email protected]> Reviewed-by: John Haxby <[email protected]> Conflicts: arch/x86/kvm/svm.c arch/x86/kvm/vmx.c [So close.. the header file that exposes the IBRS is called spec_ctrl.h while this is spec-ctrl.h]
1 parent bd72249 commit 06696d2

File tree

7 files changed

+26
-16
lines changed

7 files changed

+26
-16
lines changed

arch/x86/include/asm/mwait.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <asm/cpufeature.h>
99
#include <asm/spec_ctrl.h>
10+
#include <asm/spec-ctrl.h>
1011
#include <asm/nospec-branch.h>
1112
#include <asm/microcode.h>
1213

arch/x86/include/asm/nospec-branch.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -228,26 +228,12 @@ enum spectre_v2_mitigation {
228228
extern void x86_spec_ctrl_set(u64);
229229
extern u64 x86_spec_ctrl_get_default(void);
230230

231-
/*
232-
* On VMENTER we must preserve whatever view of the SPEC_CTRL MSR
233-
* the guest has, while on VMEXIT we restore the host view. This
234-
* would be easier if SPEC_CTRL were architecturally maskable or
235-
* shadowable for guests but this is not (currently) the case.
236-
* Takes the guest view of SPEC_CTRL MSR as a parameter.
237-
*/
238-
extern void x86_spec_ctrl_set_guest(u64);
239-
extern void x86_spec_ctrl_restore_host(u64);
240-
241231
/* The Speculative Store Bypass disable variants */
242232
enum ssb_mitigation {
243233
SPEC_STORE_BYPASS_NONE,
244234
SPEC_STORE_BYPASS_DISABLE,
245235
};
246236

247-
/* AMD specific Speculative Store Bypass MSR data */
248-
extern u64 x86_amd_ls_cfg_base;
249-
extern u64 x86_amd_ls_cfg_rds_mask;
250-
251237
extern char __indirect_thunk_start[];
252238
extern char __indirect_thunk_end[];
253239

arch/x86/include/asm/spec-ctrl.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _ASM_X86_SPECCTRL_H_
3+
#define _ASM_X86_SPECCTRL_H_
4+
5+
#include <asm/nospec-branch.h>
6+
7+
/*
8+
* On VMENTER we must preserve whatever view of the SPEC_CTRL MSR
9+
* the guest has, while on VMEXIT we restore the host view. This
10+
* would be easier if SPEC_CTRL were architecturally maskable or
11+
* shadowable for guests but this is not (currently) the case.
12+
* Takes the guest view of SPEC_CTRL MSR as a parameter.
13+
*/
14+
extern void x86_spec_ctrl_set_guest(u64);
15+
extern void x86_spec_ctrl_restore_host(u64);
16+
17+
/* AMD specific Speculative Store Bypass MSR data */
18+
extern u64 x86_amd_ls_cfg_base;
19+
extern u64 x86_amd_ls_cfg_rds_mask;
20+
21+
#endif

arch/x86/kernel/cpu/amd.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#include <asm/processor.h>
1111
#include <asm/apic.h>
1212
#include <asm/cpu.h>
13-
#include <asm/nospec-branch.h>
13+
#include <asm/spec-ctrl.h>
1414
#include <asm/smp.h>
1515
#include <asm/pci-direct.h>
1616
#include <asm/delay.h>

arch/x86/kernel/cpu/bugs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include <linux/cpu.h>
1414
#include <linux/module.h>
1515

16-
#include <asm/nospec-branch.h>
16+
#include <asm/spec-ctrl.h>
1717
#include <asm/cmdline.h>
1818
#include <asm/bugs.h>
1919
#include <asm/processor.h>

arch/x86/kvm/svm.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
#include <asm/irq_remapping.h>
5252
#include <asm/microcode.h>
5353
#include <asm/nospec-branch.h>
54+
#include <asm/spec-ctrl.h>
5455
#include <asm/spec_ctrl.h>
5556

5657
#include <asm/virtext.h>

arch/x86/kvm/vmx.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#include <asm/microcode.h>
5555
#include <asm/nospec-branch.h>
5656
#include <asm/spec_ctrl.h>
57+
#include <asm/spec-ctrl.h>
5758

5859
#include "trace.h"
5960
#include "pmu.h"

0 commit comments

Comments
 (0)