The user handler, which can be optionally used to handle enclave exceptions, is always the same global handler provided by the SGX runtime, who wants to use such a handler instead returning on exception. Thus, there is no any non-deterministic branch prediction happening. The code path is always the same and never change. Obviously, you could change it all the time purposely but for any sane real-world use that would not make any sense. Thus, remove retpoline wrapping. Cc: x86@xxxxxxxxxx Cc: Haitao Huang <haitao.huang@xxxxxxxxxxxxxxx> CC: Sean Christopherson <sean.j.christopherson@xxxxxxxxx> Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Cc: Borislav Petkov <bp@xxxxxxxxx> Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx> Cc: Andy Lutomirski <luto@xxxxxxxxxxxxxx> Cc: Cedric Xing <cedric.xing@xxxxxxxxx> Signed-off-by: Jarkko Sakkinen <jarkko.sakkinen@xxxxxxxxxxxxxxx> --- arch/x86/entry/vdso/vsgx.S | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/arch/x86/entry/vdso/vsgx.S b/arch/x86/entry/vdso/vsgx.S index 8f8190ab9ed5..5f65bb22014f 100644 --- a/arch/x86/entry/vdso/vsgx.S +++ b/arch/x86/entry/vdso/vsgx.S @@ -129,7 +129,7 @@ SYM_FUNC_START(__vdso_sgx_enter_enclave) /* Load the callback pointer to %rax and invoke it via retpoline. */ mov SGX_ENCLAVE_RUN_USER_HANDLER(%rax), %rax - call .Lretpoline + call *%rax /* Undo the post-exit %rsp adjustment. */ lea 0x10(%rsp, %rbx), %rsp @@ -143,13 +143,6 @@ SYM_FUNC_START(__vdso_sgx_enter_enclave) jle .Lout jmp .Lenter_enclave -.Lretpoline: - call 2f -1: pause - lfence - jmp 1b -2: mov %rax, (%rsp) - ret .cfi_endproc _ASM_VDSO_EXTABLE_HANDLE(.Lenclu_eenter_eresume, .Lhandle_exception) -- 2.25.1