Skip to content

Commit b2620fa

Browse files
jpoimboesuryasaimadhu
authored andcommitted
x86/speculation: Fix RSB filling with CONFIG_RETPOLINE=n
If a kernel is built with CONFIG_RETPOLINE=n, but the user still wants to mitigate Spectre v2 using IBRS or eIBRS, the RSB filling will be silently disabled. There's nothing retpoline-specific about RSB buffer filling. Remove the CONFIG_RETPOLINE guards around it. Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Borislav Petkov <[email protected]>
1 parent d7caac9 commit b2620fa

File tree

3 files changed

+0
-6
lines changed

3 files changed

+0
-6
lines changed

arch/x86/entry/entry_32.S

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,7 +698,6 @@ SYM_CODE_START(__switch_to_asm)
698698
movl %ebx, PER_CPU_VAR(__stack_chk_guard)
699699
#endif
700700

701-
#ifdef CONFIG_RETPOLINE
702701
/*
703702
* When switching from a shallower to a deeper call stack
704703
* the RSB may either underflow or use entries populated
@@ -707,7 +706,6 @@ SYM_CODE_START(__switch_to_asm)
707706
* speculative execution to prevent attack.
708707
*/
709708
FILL_RETURN_BUFFER %ebx, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW
710-
#endif
711709

712710
/* Restore flags or the incoming task to restore AC state. */
713711
popfl

arch/x86/entry/entry_64.S

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ SYM_FUNC_START(__switch_to_asm)
255255
movq %rbx, PER_CPU_VAR(fixed_percpu_data) + stack_canary_offset
256256
#endif
257257

258-
#ifdef CONFIG_RETPOLINE
259258
/*
260259
* When switching from a shallower to a deeper call stack
261260
* the RSB may either underflow or use entries populated
@@ -264,7 +263,6 @@ SYM_FUNC_START(__switch_to_asm)
264263
* speculative execution to prevent attack.
265264
*/
266265
FILL_RETURN_BUFFER %r12, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW
267-
#endif
268266

269267
/* restore callee-saved registers */
270268
popq %r15

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,9 @@
122122
* monstrosity above, manually.
123123
*/
124124
.macro FILL_RETURN_BUFFER reg:req nr:req ftr:req
125-
#ifdef CONFIG_RETPOLINE
126125
ALTERNATIVE "jmp .Lskip_rsb_\@", "", \ftr
127126
__FILL_RETURN_BUFFER(\reg,\nr,%_ASM_SP)
128127
.Lskip_rsb_\@:
129-
#endif
130128
.endm
131129

132130
/*

0 commit comments

Comments
 (0)