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.
Unified · Split
| @@ -698,7 +698,6 @@ SYM_CODE_START(__switch_to_asm) · 697 unmodified lines | |||
| 698 | movl %ebx, PER_CPU_VAR(__stack_chk_guard) | 698 | movl %ebx, PER_CPU_VAR(__stack_chk_guard) |
| 699 | #endif | 699 | #endif |
| 700 | 700 | ||
| 701 | #ifdef CONFIG_RETPOLINE | ||
| 702 | /* | 701 | /* |
| 703 | * When switching from a shallower to a deeper call stack | 702 | * When switching from a shallower to a deeper call stack |
| 704 | * the RSB may either underflow or use entries populated | 703 | * the RSB may either underflow or use entries populated |
| @@ -707,7 +706,6 @@ SYM_CODE_START(__switch_to_asm) · 2 unmodified lines | |||
| 707 | * speculative execution to prevent attack. | 706 | * speculative execution to prevent attack. |
| 708 | */ | 707 | */ |
| 709 | FILL_RETURN_BUFFER %ebx, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW | 708 | FILL_RETURN_BUFFER %ebx, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW |
| 710 | #endif | ||
| 711 | 709 | ||
| 712 | /* Restore flags or the incoming task to restore AC state. */ | 710 | /* Restore flags or the incoming task to restore AC state. */ |
| 713 | popfl | 711 | popfl |
| @@ -255,7 +255,6 @@ SYM_FUNC_START(__switch_to_asm) · 254 unmodified lines | |||
| 255 | movq %rbx, PER_CPU_VAR(fixed_percpu_data) + stack_canary_offset | 255 | movq %rbx, PER_CPU_VAR(fixed_percpu_data) + stack_canary_offset |
| 256 | #endif | 256 | #endif |
| 257 | 257 | ||
| 258 | #ifdef CONFIG_RETPOLINE | ||
| 259 | /* | 258 | /* |
| 260 | * When switching from a shallower to a deeper call stack | 259 | * When switching from a shallower to a deeper call stack |
| 261 | * the RSB may either underflow or use entries populated | 260 | * the RSB may either underflow or use entries populated |
| @@ -264,7 +263,6 @@ SYM_FUNC_START(__switch_to_asm) · 2 unmodified lines | |||
| 264 | * speculative execution to prevent attack. | 263 | * speculative execution to prevent attack. |
| 265 | */ | 264 | */ |
| 266 | FILL_RETURN_BUFFER %r12, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW | 265 | FILL_RETURN_BUFFER %r12, RSB_CLEAR_LOOPS, X86_FEATURE_RSB_CTXSW |
| 267 | #endif | ||
| 268 | 266 | ||
| 269 | /* restore callee-saved registers */ | 267 | /* restore callee-saved registers */ |
| 270 | popq %r15 | 268 | popq %r15 |
| @@ -122,11 +122,9 @@ · 121 unmodified lines | |||
| 122 | * monstrosity above, manually. | 122 | * monstrosity above, manually. |
| 123 | */ | 123 | */ |
| 124 | .macro FILL_RETURN_BUFFER reg:req nr:req ftr:req | 124 | .macro FILL_RETURN_BUFFER reg:req nr:req ftr:req |
| 125 | #ifdef CONFIG_RETPOLINE | ||
| 126 | ALTERNATIVE "jmp .Lskip_rsb_\@", "", \ftr | 125 | ALTERNATIVE "jmp .Lskip_rsb_\@", "", \ftr |
| 127 | __FILL_RETURN_BUFFER(\reg,\nr,%_ASM_SP) | 126 | __FILL_RETURN_BUFFER(\reg,\nr,%_ASM_SP) |
| 128 | .Lskip_rsb_\@: | 127 | .Lskip_rsb_\@: |
| 129 | #endif | ||
| 130 | .endm | 128 | .endm |
| 131 | 129 | ||
| 132 | /* | 130 | /* |