Skip to content

Commit e6aa136

Browse files
jpoimboesuryasaimadhu
authored andcommitted
x86/speculation: Fix firmware entry SPEC_CTRL handling
The firmware entry code may accidentally clear STIBP or SSBD. Fix that. Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Borislav Petkov <[email protected]>
1 parent b2620fa commit e6aa136

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

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

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -285,18 +285,16 @@ extern u64 spec_ctrl_current(void);
285285
*/
286286
#define firmware_restrict_branch_speculation_start() \
287287
do { \
288-
u64 val = x86_spec_ctrl_base | SPEC_CTRL_IBRS; \
289-
\
290288
preempt_disable(); \
291-
alternative_msr_write(MSR_IA32_SPEC_CTRL, val, \
289+
alternative_msr_write(MSR_IA32_SPEC_CTRL, \
290+
spec_ctrl_current() | SPEC_CTRL_IBRS, \
292291
X86_FEATURE_USE_IBRS_FW); \
293292
} while (0)
294293

295294
#define firmware_restrict_branch_speculation_end() \
296295
do { \
297-
u64 val = x86_spec_ctrl_base; \
298-
\
299-
alternative_msr_write(MSR_IA32_SPEC_CTRL, val, \
296+
alternative_msr_write(MSR_IA32_SPEC_CTRL, \
297+
spec_ctrl_current(), \
300298
X86_FEATURE_USE_IBRS_FW); \
301299
preempt_enable(); \
302300
} while (0)

0 commit comments

Comments
 (0)