Re: [PATCH 1/9] objtool,x86: Replace alternatives with .retpoline_sites

From: Borislav Petkov
Date: Wed Oct 13 2021 - 09:29:40 EST


On Wed, Oct 13, 2021 at 02:22:18PM +0200, Peter Zijlstra wrote:
> Instead of writing complete alternatives, simply provide a list of all
> the retpoline thunk calls. Then the kernel is free to do with them as
> it pleases. Simpler code all-round.
>
> Signed-off-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
> ---
> arch/x86/kernel/vmlinux.lds.S | 12 +++
> arch/x86/lib/retpoline.S | 42 ------------
> tools/objtool/arch/x86/decode.c | 126 +++++++-----------------------------
> tools/objtool/elf.c | 84 ------------------------
> tools/objtool/include/objtool/elf.h | 1
> 5 files changed, 38 insertions(+), 227 deletions(-)
>
> --- a/arch/x86/kernel/vmlinux.lds.S
> +++ b/arch/x86/kernel/vmlinux.lds.S
> @@ -273,6 +273,18 @@ SECTIONS
> }

#ifdef CONFIG_RETPOLINE around it I guess...

> /*
> + * List of instructions that call/jmp/jcc to retpoline thunks
> + * __x86_indirect_thunk_*(). These instructions can be patched along
> + * with alternatives, after which the section can be freed.
> + */
> + . = ALIGN(8);
> + .retpoline_sites : AT(ADDR(.retpoline_sites) - LOAD_OFFSET) {
> + __retpoline_sites = .;
> + *(.retpoline_sites)
> + __retpoline_sites_end = .;
> + }

#endif

--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette