Skip to content

Commit 6304672

Browse files
committed
Merge branch 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86/pti updates from Thomas Gleixner: "Another set of melted spectrum related changes: - Code simplifications and cleanups for RSB and retpolines. - Make the indirect calls in KVM speculation safe. - Whitelist CPUs which are known not to speculate from Meltdown and prepare for the new CPUID flag which tells the kernel that a CPU is not affected. - A less rigorous variant of the module retpoline check which merily warns when a non-retpoline protected module is loaded and reflects that fact in the sysfs file. - Prepare for Indirect Branch Prediction Barrier support. - Prepare for exposure of the Speculation Control MSRs to guests, so guest OSes which depend on those "features" can use them. Includes a blacklist of the broken microcodes. The actual exposure of the MSRs through KVM is still being worked on" * 'x86-pti-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/speculation: Simplify indirect_branch_prediction_barrier() x86/retpoline: Simplify vmexit_fill_RSB() x86/cpufeatures: Clean up Spectre v2 related CPUID flags x86/cpu/bugs: Make retpoline module warning conditional x86/bugs: Drop one "mitigation" from dmesg x86/nospec: Fix header guards names x86/alternative: Print unadorned pointers x86/speculation: Add basic IBPB (Indirect Branch Prediction Barrier) support x86/cpufeature: Blacklist SPEC_CTRL/PRED_CMD on early Spectre v2 microcodes x86/pti: Do not enable PTI on CPUs which are not vulnerable to Meltdown x86/msr: Add definitions for new speculation control MSRs x86/cpufeatures: Add AMD feature bits for Speculation Control x86/cpufeatures: Add Intel feature bits for Speculation Control x86/cpufeatures: Add CPUID_7_EDX CPUID leaf module/retpoline: Warn about missing retpoline in module KVM: VMX: Make indirect call speculation safe KVM: x86: Make indirect calls in emulator speculation safe
2 parents 9426335 + 64e1672 commit 6304672

File tree

22 files changed

+324
-100
lines changed

22 files changed

+324
-100
lines changed

arch/x86/entry/entry_32.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,8 @@ ENTRY(__switch_to_asm)
252252
* exist, overwrite the RSB with entries which capture
253253
* speculative execution to prevent attack.
254254
*/
255-
FILL_RETURN_BUFFER %ebx, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW
255+
/* Clobbers %ebx */
256+
FILL_RETURN_BUFFER RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW
256257
#endif
257258

258259
/* restore callee-saved registers */

arch/x86/entry/entry_64.S

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,8 @@ ENTRY(__switch_to_asm)
499499
* exist, overwrite the RSB with entries which capture
500500
* speculative execution to prevent attack.
501501
*/
502-
FILL_RETURN_BUFFER %r12, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW
502+
/* Clobbers %rbx */
503+
FILL_RETURN_BUFFER RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW
503504
#endif
504505

505506
/* restore callee-saved registers */

arch/x86/include/asm/asm-prototypes.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,7 @@ INDIRECT_THUNK(dx)
3838
INDIRECT_THUNK(si)
3939
INDIRECT_THUNK(di)
4040
INDIRECT_THUNK(bp)
41+
asmlinkage void __fill_rsb(void);
42+
asmlinkage void __clear_rsb(void);
43+
4144
#endif /* CONFIG_RETPOLINE */

arch/x86/include/asm/cpufeature.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ enum cpuid_leafs
2929
CPUID_8000_000A_EDX,
3030
CPUID_7_ECX,
3131
CPUID_8000_0007_EBX,
32+
CPUID_7_EDX,
3233
};
3334

3435
#ifdef CONFIG_X86_FEATURE_NAMES
@@ -79,8 +80,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
7980
CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 15, feature_bit) || \
8081
CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 16, feature_bit) || \
8182
CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 17, feature_bit) || \
83+
CHECK_BIT_IN_MASK_WORD(REQUIRED_MASK, 18, feature_bit) || \
8284
REQUIRED_MASK_CHECK || \
83-
BUILD_BUG_ON_ZERO(NCAPINTS != 18))
85+
BUILD_BUG_ON_ZERO(NCAPINTS != 19))
8486

8587
#define DISABLED_MASK_BIT_SET(feature_bit) \
8688
( CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 0, feature_bit) || \
@@ -101,8 +103,9 @@ extern const char * const x86_bug_flags[NBUGINTS*32];
101103
CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 15, feature_bit) || \
102104
CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 16, feature_bit) || \
103105
CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 17, feature_bit) || \
106+
CHECK_BIT_IN_MASK_WORD(DISABLED_MASK, 18, feature_bit) || \
104107
DISABLED_MASK_CHECK || \
105-
BUILD_BUG_ON_ZERO(NCAPINTS != 18))
108+
BUILD_BUG_ON_ZERO(NCAPINTS != 19))
106109

107110
#define cpu_has(c, bit) \
108111
(__builtin_constant_p(bit) && REQUIRED_MASK_BIT_SET(bit) ? 1 : \

arch/x86/include/asm/cpufeatures.h

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
/*
1414
* Defines x86 CPU feature bits
1515
*/
16-
#define NCAPINTS 18 /* N 32-bit words worth of info */
16+
#define NCAPINTS 19 /* N 32-bit words worth of info */
1717
#define NBUGINTS 1 /* N 32-bit bug flags */
1818

1919
/*
@@ -203,15 +203,15 @@
203203
#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */
204204
#define X86_FEATURE_SME ( 7*32+10) /* AMD Secure Memory Encryption */
205205
#define X86_FEATURE_PTI ( 7*32+11) /* Kernel Page Table Isolation enabled */
206-
#define X86_FEATURE_RETPOLINE ( 7*32+12) /* Generic Retpoline mitigation for Spectre variant 2 */
207-
#define X86_FEATURE_RETPOLINE_AMD ( 7*32+13) /* AMD Retpoline mitigation for Spectre variant 2 */
206+
#define X86_FEATURE_RETPOLINE ( 7*32+12) /* "" Generic Retpoline mitigation for Spectre variant 2 */
207+
#define X86_FEATURE_RETPOLINE_AMD ( 7*32+13) /* "" AMD Retpoline mitigation for Spectre variant 2 */
208208
#define X86_FEATURE_INTEL_PPIN ( 7*32+14) /* Intel Processor Inventory Number */
209209
#define X86_FEATURE_CDP_L2 ( 7*32+15) /* Code and Data Prioritization L2 */
210-
#define X86_FEATURE_AVX512_4VNNIW ( 7*32+16) /* AVX-512 Neural Network Instructions */
211-
#define X86_FEATURE_AVX512_4FMAPS ( 7*32+17) /* AVX-512 Multiply Accumulation Single precision */
212210

213211
#define X86_FEATURE_MBA ( 7*32+18) /* Memory Bandwidth Allocation */
214-
#define X86_FEATURE_RSB_CTXSW ( 7*32+19) /* Fill RSB on context switches */
212+
#define X86_FEATURE_RSB_CTXSW ( 7*32+19) /* "" Fill RSB on context switches */
213+
214+
#define X86_FEATURE_USE_IBPB ( 7*32+21) /* "" Indirect Branch Prediction Barrier enabled */
215215

216216
/* Virtualization flags: Linux defined, word 8 */
217217
#define X86_FEATURE_TPR_SHADOW ( 8*32+ 0) /* Intel TPR Shadow */
@@ -272,6 +272,9 @@
272272
#define X86_FEATURE_CLZERO (13*32+ 0) /* CLZERO instruction */
273273
#define X86_FEATURE_IRPERF (13*32+ 1) /* Instructions Retired Count */
274274
#define X86_FEATURE_XSAVEERPTR (13*32+ 2) /* Always save/restore FP error pointers */
275+
#define X86_FEATURE_IBPB (13*32+12) /* Indirect Branch Prediction Barrier */
276+
#define X86_FEATURE_IBRS (13*32+14) /* Indirect Branch Restricted Speculation */
277+
#define X86_FEATURE_STIBP (13*32+15) /* Single Thread Indirect Branch Predictors */
275278

276279
/* Thermal and Power Management Leaf, CPUID level 0x00000006 (EAX), word 14 */
277280
#define X86_FEATURE_DTHERM (14*32+ 0) /* Digital Thermal Sensor */
@@ -320,6 +323,13 @@
320323
#define X86_FEATURE_SUCCOR (17*32+ 1) /* Uncorrectable error containment and recovery */
321324
#define X86_FEATURE_SMCA (17*32+ 3) /* Scalable MCA */
322325

326+
/* Intel-defined CPU features, CPUID level 0x00000007:0 (EDX), word 18 */
327+
#define X86_FEATURE_AVX512_4VNNIW (18*32+ 2) /* AVX-512 Neural Network Instructions */
328+
#define X86_FEATURE_AVX512_4FMAPS (18*32+ 3) /* AVX-512 Multiply Accumulation Single precision */
329+
#define X86_FEATURE_SPEC_CTRL (18*32+26) /* "" Speculation Control (IBRS + IBPB) */
330+
#define X86_FEATURE_INTEL_STIBP (18*32+27) /* "" Single Thread Indirect Branch Predictors */
331+
#define X86_FEATURE_ARCH_CAPABILITIES (18*32+29) /* IA32_ARCH_CAPABILITIES MSR (Intel) */
332+
323333
/*
324334
* BUG word(s)
325335
*/

arch/x86/include/asm/disabled-features.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
#define DISABLED_MASK15 0
7878
#define DISABLED_MASK16 (DISABLE_PKU|DISABLE_OSPKE|DISABLE_LA57|DISABLE_UMIP)
7979
#define DISABLED_MASK17 0
80-
#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 18)
80+
#define DISABLED_MASK18 0
81+
#define DISABLED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19)
8182

8283
#endif /* _ASM_X86_DISABLED_FEATURES_H */

arch/x86/include/asm/msr-index.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@
3939

4040
/* Intel MSRs. Some also available on other CPUs */
4141

42+
#define MSR_IA32_SPEC_CTRL 0x00000048 /* Speculation Control */
43+
#define SPEC_CTRL_IBRS (1 << 0) /* Indirect Branch Restricted Speculation */
44+
#define SPEC_CTRL_STIBP (1 << 1) /* Single Thread Indirect Branch Predictors */
45+
46+
#define MSR_IA32_PRED_CMD 0x00000049 /* Prediction Command */
47+
#define PRED_CMD_IBPB (1 << 0) /* Indirect Branch Prediction Barrier */
48+
4249
#define MSR_PPIN_CTL 0x0000004e
4350
#define MSR_PPIN 0x0000004f
4451

@@ -57,6 +64,11 @@
5764
#define SNB_C3_AUTO_UNDEMOTE (1UL << 28)
5865

5966
#define MSR_MTRRcap 0x000000fe
67+
68+
#define MSR_IA32_ARCH_CAPABILITIES 0x0000010a
69+
#define ARCH_CAP_RDCL_NO (1 << 0) /* Not susceptible to Meltdown */
70+
#define ARCH_CAP_IBRS_ALL (1 << 1) /* Enhanced IBRS support */
71+
6072
#define MSR_IA32_BBL_CR_CTL 0x00000119
6173
#define MSR_IA32_BBL_CR_CTL3 0x0000011e
6274

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

Lines changed: 18 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,12 @@
11
/* SPDX-License-Identifier: GPL-2.0 */
22

3-
#ifndef __NOSPEC_BRANCH_H__
4-
#define __NOSPEC_BRANCH_H__
3+
#ifndef _ASM_X86_NOSPEC_BRANCH_H_
4+
#define _ASM_X86_NOSPEC_BRANCH_H_
55

66
#include <asm/alternative.h>
77
#include <asm/alternative-asm.h>
88
#include <asm/cpufeatures.h>
99

10-
/*
11-
* Fill the CPU return stack buffer.
12-
*
13-
* Each entry in the RSB, if used for a speculative 'ret', contains an
14-
* infinite 'pause; lfence; jmp' loop to capture speculative execution.
15-
*
16-
* This is required in various cases for retpoline and IBRS-based
17-
* mitigations for the Spectre variant 2 vulnerability. Sometimes to
18-
* eliminate potentially bogus entries from the RSB, and sometimes
19-
* purely to ensure that it doesn't get empty, which on some CPUs would
20-
* allow predictions from other (unwanted!) sources to be used.
21-
*
22-
* We define a CPP macro such that it can be used from both .S files and
23-
* inline assembly. It's possible to do a .macro and then include that
24-
* from C via asm(".include <asm/nospec-branch.h>") but let's not go there.
25-
*/
26-
27-
#define RSB_CLEAR_LOOPS 32 /* To forcibly overwrite all entries */
28-
#define RSB_FILL_LOOPS 16 /* To avoid underflow */
29-
30-
/*
31-
* Google experimented with loop-unrolling and this turned out to be
32-
* the optimal version — two calls, each with their own speculation
33-
* trap should their return address end up getting used, in a loop.
34-
*/
35-
#define __FILL_RETURN_BUFFER(reg, nr, sp) \
36-
mov $(nr/2), reg; \
37-
771: \
38-
call 772f; \
39-
773: /* speculation trap */ \
40-
pause; \
41-
lfence; \
42-
jmp 773b; \
43-
772: \
44-
call 774f; \
45-
775: /* speculation trap */ \
46-
pause; \
47-
lfence; \
48-
jmp 775b; \
49-
774: \
50-
dec reg; \
51-
jnz 771b; \
52-
add $(BITS_PER_LONG/8) * nr, sp;
53-
5410
#ifdef __ASSEMBLY__
5511

5612
/*
@@ -121,17 +77,10 @@
12177
#endif
12278
.endm
12379

124-
/*
125-
* A simpler FILL_RETURN_BUFFER macro. Don't make people use the CPP
126-
* monstrosity above, manually.
127-
*/
128-
.macro FILL_RETURN_BUFFER reg:req nr:req ftr:req
80+
/* This clobbers the BX register */
81+
.macro FILL_RETURN_BUFFER nr:req ftr:req
12982
#ifdef CONFIG_RETPOLINE
130-
ANNOTATE_NOSPEC_ALTERNATIVE
131-
ALTERNATIVE "jmp .Lskip_rsb_\@", \
132-
__stringify(__FILL_RETURN_BUFFER(\reg,\nr,%_ASM_SP)) \
133-
\ftr
134-
.Lskip_rsb_\@:
83+
ALTERNATIVE "", "call __clear_rsb", \ftr
13584
#endif
13685
.endm
13786

@@ -206,17 +155,20 @@ extern char __indirect_thunk_end[];
206155
static inline void vmexit_fill_RSB(void)
207156
{
208157
#ifdef CONFIG_RETPOLINE
209-
unsigned long loops;
210-
211-
asm volatile (ANNOTATE_NOSPEC_ALTERNATIVE
212-
ALTERNATIVE("jmp 910f",
213-
__stringify(__FILL_RETURN_BUFFER(%0, RSB_CLEAR_LOOPS, %1)),
214-
X86_FEATURE_RETPOLINE)
215-
"910:"
216-
: "=r" (loops), ASM_CALL_CONSTRAINT
217-
: : "memory" );
158+
alternative_input("",
159+
"call __fill_rsb",
160+
X86_FEATURE_RETPOLINE,
161+
ASM_NO_INPUT_CLOBBER(_ASM_BX, "memory"));
218162
#endif
219163
}
220164

165+
static inline void indirect_branch_prediction_barrier(void)
166+
{
167+
alternative_input("",
168+
"call __ibp_barrier",
169+
X86_FEATURE_USE_IBPB,
170+
ASM_NO_INPUT_CLOBBER("eax", "ecx", "edx", "memory"));
171+
}
172+
221173
#endif /* __ASSEMBLY__ */
222-
#endif /* __NOSPEC_BRANCH_H__ */
174+
#endif /* _ASM_X86_NOSPEC_BRANCH_H_ */

arch/x86/include/asm/processor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -971,4 +971,7 @@ bool xen_set_default_idle(void);
971971

972972
void stop_this_cpu(void *dummy);
973973
void df_debug(struct pt_regs *regs, long error_code);
974+
975+
void __ibp_barrier(void);
976+
974977
#endif /* _ASM_X86_PROCESSOR_H */

arch/x86/include/asm/required-features.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
#define REQUIRED_MASK15 0
107107
#define REQUIRED_MASK16 (NEED_LA57)
108108
#define REQUIRED_MASK17 0
109-
#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 18)
109+
#define REQUIRED_MASK18 0
110+
#define REQUIRED_MASK_CHECK BUILD_BUG_ON_ZERO(NCAPINTS != 19)
110111

111112
#endif /* _ASM_X86_REQUIRED_FEATURES_H */

arch/x86/kernel/alternative.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ recompute_jump(struct alt_instr *a, u8 *orig_insn, u8 *repl_insn, u8 *insnbuf)
298298
tgt_rip = next_rip + o_dspl;
299299
n_dspl = tgt_rip - orig_insn;
300300

301-
DPRINTK("target RIP: %p, new_displ: 0x%x", tgt_rip, n_dspl);
301+
DPRINTK("target RIP: %px, new_displ: 0x%x", tgt_rip, n_dspl);
302302

303303
if (tgt_rip - orig_insn >= 0) {
304304
if (n_dspl - 2 <= 127)
@@ -355,7 +355,7 @@ static void __init_or_module noinline optimize_nops(struct alt_instr *a, u8 *ins
355355
add_nops(instr + (a->instrlen - a->padlen), a->padlen);
356356
local_irq_restore(flags);
357357

358-
DUMP_BYTES(instr, a->instrlen, "%p: [%d:%d) optimized NOPs: ",
358+
DUMP_BYTES(instr, a->instrlen, "%px: [%d:%d) optimized NOPs: ",
359359
instr, a->instrlen - a->padlen, a->padlen);
360360
}
361361

@@ -376,7 +376,7 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start,
376376
u8 *instr, *replacement;
377377
u8 insnbuf[MAX_PATCH_LEN];
378378

379-
DPRINTK("alt table %p -> %p", start, end);
379+
DPRINTK("alt table %px, -> %px", start, end);
380380
/*
381381
* The scan order should be from start to end. A later scanned
382382
* alternative code can overwrite previously scanned alternative code.
@@ -400,14 +400,14 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start,
400400
continue;
401401
}
402402

403-
DPRINTK("feat: %d*32+%d, old: (%p, len: %d), repl: (%p, len: %d), pad: %d",
403+
DPRINTK("feat: %d*32+%d, old: (%px len: %d), repl: (%px, len: %d), pad: %d",
404404
a->cpuid >> 5,
405405
a->cpuid & 0x1f,
406406
instr, a->instrlen,
407407
replacement, a->replacementlen, a->padlen);
408408

409-
DUMP_BYTES(instr, a->instrlen, "%p: old_insn: ", instr);
410-
DUMP_BYTES(replacement, a->replacementlen, "%p: rpl_insn: ", replacement);
409+
DUMP_BYTES(instr, a->instrlen, "%px: old_insn: ", instr);
410+
DUMP_BYTES(replacement, a->replacementlen, "%px: rpl_insn: ", replacement);
411411

412412
memcpy(insnbuf, replacement, a->replacementlen);
413413
insnbuf_sz = a->replacementlen;
@@ -433,7 +433,7 @@ void __init_or_module noinline apply_alternatives(struct alt_instr *start,
433433
a->instrlen - a->replacementlen);
434434
insnbuf_sz += a->instrlen - a->replacementlen;
435435
}
436-
DUMP_BYTES(insnbuf, insnbuf_sz, "%p: final_insn: ", instr);
436+
DUMP_BYTES(insnbuf, insnbuf_sz, "%px: final_insn: ", instr);
437437

438438
text_poke_early(instr, insnbuf, insnbuf_sz);
439439
}

arch/x86/kernel/cpu/bugs.c

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/init.h>
1212
#include <linux/utsname.h>
1313
#include <linux/cpu.h>
14+
#include <linux/module.h>
1415

1516
#include <asm/nospec-branch.h>
1617
#include <asm/cmdline.h>
@@ -90,10 +91,31 @@ static const char *spectre_v2_strings[] = {
9091
};
9192

9293
#undef pr_fmt
93-
#define pr_fmt(fmt) "Spectre V2 mitigation: " fmt
94+
#define pr_fmt(fmt) "Spectre V2 : " fmt
9495

9596
static enum spectre_v2_mitigation spectre_v2_enabled = SPECTRE_V2_NONE;
9697

98+
#ifdef RETPOLINE
99+
static bool spectre_v2_bad_module;
100+
101+
bool retpoline_module_ok(bool has_retpoline)
102+
{
103+
if (spectre_v2_enabled == SPECTRE_V2_NONE || has_retpoline)
104+
return true;
105+
106+
pr_err("System may be vunerable to spectre v2\n");
107+
spectre_v2_bad_module = true;
108+
return false;
109+
}
110+
111+
static inline const char *spectre_v2_module_string(void)
112+
{
113+
return spectre_v2_bad_module ? " - vulnerable module loaded" : "";
114+
}
115+
#else
116+
static inline const char *spectre_v2_module_string(void) { return ""; }
117+
#endif
118+
97119
static void __init spec2_print_if_insecure(const char *reason)
98120
{
99121
if (boot_cpu_has_bug(X86_BUG_SPECTRE_V2))
@@ -249,6 +271,12 @@ static void __init spectre_v2_select_mitigation(void)
249271
setup_force_cpu_cap(X86_FEATURE_RSB_CTXSW);
250272
pr_info("Filling RSB on context switch\n");
251273
}
274+
275+
/* Initialize Indirect Branch Prediction Barrier if supported */
276+
if (boot_cpu_has(X86_FEATURE_IBPB)) {
277+
setup_force_cpu_cap(X86_FEATURE_USE_IBPB);
278+
pr_info("Enabling Indirect Branch Prediction Barrier\n");
279+
}
252280
}
253281

254282
#undef pr_fmt
@@ -278,6 +306,14 @@ ssize_t cpu_show_spectre_v2(struct device *dev,
278306
if (!boot_cpu_has_bug(X86_BUG_SPECTRE_V2))
279307
return sprintf(buf, "Not affected\n");
280308

281-
return sprintf(buf, "%s\n", spectre_v2_strings[spectre_v2_enabled]);
309+
return sprintf(buf, "%s%s%s\n", spectre_v2_strings[spectre_v2_enabled],
310+
boot_cpu_has(X86_FEATURE_USE_IBPB) ? ", IBPB" : "",
311+
spectre_v2_module_string());
282312
}
283313
#endif
314+
315+
void __ibp_barrier(void)
316+
{
317+
__wrmsr(MSR_IA32_PRED_CMD, PRED_CMD_IBPB, 0);
318+
}
319+
EXPORT_SYMBOL_GPL(__ibp_barrier);

0 commit comments

Comments
 (0)