Re: [RFC][PATCH 6/7] x86/retpoline: Out-of-line retpoline

From: Peter Zijlstra
Date: Thu Apr 16 2020 - 11:23:19 EST



Bah, chunks went missing, I'll make sure to push out a working version.

On Thu, Apr 16, 2020 at 05:07:58PM +0200, Peter Zijlstra wrote:
> --- a/arch/x86/lib/retpoline.S
> +++ b/arch/x86/lib/retpoline.S
> @@ -7,15 +7,30 @@
> #include <asm/alternative-asm.h>
> #include <asm/export.h>
> #include <asm/nospec-branch.h>
> +#include <asm/unwind_hints.h>
> +#include <asm/frame.h>
>
> .macro THUNK reg
> .section .text.__x86.indirect_thunk
>
> + .align 32
> SYM_FUNC_START(__x86_indirect_thunk_\reg)
> - CFI_STARTPROC
> - JMP_NOSPEC %\reg
> - CFI_ENDPROC
> + JMP_NOSPEC \reg
> SYM_FUNC_END(__x86_indirect_thunk_\reg)
> +
> +SYM_FUNC_START_NOALIGN(__x86_retpoline_\reg)
> + ANNOTATE_INTRA_FUNCTION_CALL
> + call .Ldo_rop_\@
> +.Lspec_trap_\@:
UNWIND_HINT_EMPTY
> + pause
> + lfence
> + jmp .Lspec_trap_\@
> +.Ldo_rop_\@:
> + mov %\reg, (%_ASM_SP)
> + UNWIND_HINT_RET_OFFSET
> + ret
> +SYM_FUNC_END(__x86_retpoline_\reg)
> +
> .endm
>
> /*