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 <jpoimboe@kernel.org>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Borislav Petkov <bp@suse.de>
This commit is contained in:
Josh Poimboeuf
2022-06-27 10:34:00 +02:00
committed by Borislav Petkov
parent d7caac991f
commit b2620facef
3 changed files with 0 additions and 6 deletions
-2
View File
@@ -698,7 +698,6 @@ SYM_CODE_START(__switch_to_asm)
movl %ebx, PER_CPU_VAR(__stack_chk_guard) movl %ebx, PER_CPU_VAR(__stack_chk_guard)
#endif #endif
#ifdef CONFIG_RETPOLINE
/* /*
* When switching from a shallower to a deeper call stack * When switching from a shallower to a deeper call stack
* the RSB may either underflow or use entries populated * the RSB may either underflow or use entries populated
@@ -707,7 +706,6 @@ SYM_CODE_START(__switch_to_asm)
* speculative execution to prevent attack. * speculative execution to prevent attack.
*/ */
FILL_RETURN_BUFFER %ebx, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW FILL_RETURN_BUFFER %ebx, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW
#endif
/* Restore flags or the incoming task to restore AC state. */ /* Restore flags or the incoming task to restore AC state. */
popfl popfl
-2
View File
@@ -255,7 +255,6 @@ SYM_FUNC_START(__switch_to_asm)
movq %rbx, PER_CPU_VAR(fixed_percpu_data) + stack_canary_offset movq %rbx, PER_CPU_VAR(fixed_percpu_data) + stack_canary_offset
#endif #endif
#ifdef CONFIG_RETPOLINE
/* /*
* When switching from a shallower to a deeper call stack * When switching from a shallower to a deeper call stack
* the RSB may either underflow or use entries populated * the RSB may either underflow or use entries populated
@@ -264,7 +263,6 @@ SYM_FUNC_START(__switch_to_asm)
* speculative execution to prevent attack. * speculative execution to prevent attack.
*/ */
FILL_RETURN_BUFFER %r12, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW FILL_RETURN_BUFFER %r12, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW
#endif
/* restore callee-saved registers */ /* restore callee-saved registers */
popq %r15 popq %r15
-2
View File
@@ -122,11 +122,9 @@
* monstrosity above, manually. * monstrosity above, manually.
*/ */
.macro FILL_RETURN_BUFFER reg:req nr:req ftr:req .macro FILL_RETURN_BUFFER reg:req nr:req ftr:req
#ifdef CONFIG_RETPOLINE
ALTERNATIVE "jmp .Lskip_rsb_\@", "", \ftr ALTERNATIVE "jmp .Lskip_rsb_\@", "", \ftr
__FILL_RETURN_BUFFER(\reg,\nr,%_ASM_SP) __FILL_RETURN_BUFFER(\reg,\nr,%_ASM_SP)
.Lskip_rsb_\@: .Lskip_rsb_\@:
#endif
.endm .endm
/* /*