]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
x86/speculation: Remove unnecessary retpoline alternatives
authorAlexandre Chartre <alexandre.chartre@oracle.com>
Tue, 11 Sep 2018 11:23:45 +0000 (13:23 +0200)
committerBrian Maly <brian.maly@oracle.com>
Mon, 22 Oct 2018 17:21:17 +0000 (13:21 -0400)
Now that the X86_FEATURE_RETPOLINE is always set, some assembly
alternatives can be simplied or even removed. Also add early
check of retpoline_enabled_key in CALL_NOSPEC to avoid an extra
call into thunk when retpoline is disabled.

Signed-off-by: Alexandre Chartre <alexandre.chartre@oracle.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@oracle.com>
(cherry picked from UEK5 commit eb88d822befdc73952ae7c00cfcbce9ff5aad574)

Orabug: 28607548

Signed-off-by: Alexandre Chartre <alexandre.chartre@oracle.com>
Reviewed-by: Darren Kenny <darren.kenny@oracle.com>
Reviewed-by: Mihai Carabas <mihai.carabas@oracle.com>
Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Signed-off-by: Brian Maly <brian.maly@oracle.com>
arch/x86/include/asm/nospec-branch.h

index 7c9c2f337d4e18c30f994e38368a41232958bd57..aed5f8476f3bf49e5694565421dc398b59c08e0c 100644 (file)
@@ -95,8 +95,7 @@
        STATIC_JUMP_IF_TRUE .Lretpoline_jmp_\@, retpoline_enabled_key, def=0
        jmp     *\reg
 .Lretpoline_jmp_\@:
-       ALTERNATIVE_2 __stringify(jmp *\reg),                           \
-               __stringify(RETPOLINE_JMP \reg), X86_FEATURE_RETPOLINE, \
+       ALTERNATIVE __stringify(RETPOLINE_JMP \reg), \
                __stringify(lfence; jmp *\reg), X86_FEATURE_RETPOLINE_AMD
 #else
        jmp     *\reg
        call    *\reg
        jmp     .Ldone_call_\@
 .Lretpoline_call_\@:
-       ALTERNATIVE_2 __stringify(call *\reg),                          \
-               __stringify(RETPOLINE_CALL \reg), X86_FEATURE_RETPOLINE,\
+       ALTERNATIVE __stringify(RETPOLINE_CALL \reg), \
                __stringify(lfence; call *\reg), X86_FEATURE_RETPOLINE_AMD
 .Ldone_call_\@:
 #else
  * the 64-bit one is dependent on RETPOLINE not CONFIG_RETPOLINE.
  */
 # define CALL_NOSPEC                                           \
-       ALTERNATIVE(                                            \
-       "call *%[thunk_target]\n",                              \
-       "call __x86_indirect_thunk_%V[thunk_target]\n",         \
-       X86_FEATURE_RETPOLINE)
+       "901: .byte " __stringify(STATIC_KEY_INIT_NOP) "\n"     \
+       ".pushsection __jump_table, \"aw\"\n"                   \
+       _ASM_ALIGN "\n"                                         \
+       _ASM_PTR "901b, 902f, retpoline_enabled_key\n"          \
+       ".popsection\n"                                         \
+       "       call *%[thunk_target];\n"                       \
+       "       jmp   903f;\n"                                  \
+       "       .align 16\n"                                    \
+       "902:   call __x86_indirect_thunk_%V[thunk_target];\n"  \
+       "903:"
+
 # define THUNK_TARGET(addr) [thunk_target] "r" (addr)
 
 #elif defined(CONFIG_X86_32) && defined(CONFIG_RETPOLINE)