History

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.

Josh Poimboeuf committed 4 years ago

Commit b2620fa1 parent d7caac93 files · +0 −6Browse files

Unified · Split

3 files
  1. arch/x86/entry/entry_32.S +0 −2
  2. arch/x86/entry/entry_64.S +0 −2
  3. arch/x86/include/asm/nospec-branch.h +0 −2
arch/x86/entry/entry_32.S+0−2
@@ -698,7 +698,6 @@ SYM_CODE_START(__switch_to_asm) · 697 unmodified lines
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) · 2 unmodified lines
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+0−2
@@ -255,7 +255,6 @@ SYM_FUNC_START(__switch_to_asm) · 254 unmodified lines
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) · 2 unmodified lines
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+0−2
@@ -122,11 +122,9 @@ · 121 unmodified lines
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 /*