Re: [RESEND][PATCH v3 10/17] x86/static_call: Add inline static call implementation for x86-64
From: Peter Zijlstra
Date: Thu Mar 26 2020 - 12:07:07 EST
On Tue, Mar 24, 2020 at 02:56:13PM +0100, Peter Zijlstra wrote:
> From: Josh Poimboeuf <jpoimboe@xxxxxxxxxx>
>
> Add the inline static call implementation for x86-64. The generated code
> is identical to the out-of-line case, except we move the trampoline into
> it's own section.
>
> Then objtool uses the trampoline section to detect all the call sites,
> which it writes into the .static_call_sites section.
>
> During boot (and module init), the call sites are patched to call
> directly into the destination function. The temporary trampoline is
> then no longer used.
> +static int read_static_call_tramps(struct objtool_file *file)
> +{
> + struct section *sec, *sc_sec = find_section_by_name(file->elf, ".static_call.text");
> + struct symbol *func;
> +
> + for_each_sec(file, sec) {
> + list_for_each_entry(func, &sec->symbol_list, list) {
> + if (func->sec == sc_sec)
> + func->static_call_tramp = true;
> + }
> + }
> +
> + return 0;
> +}
While talking Boris through this stuff, I just realized that if you use
a static_call object defined in another translation-unit, IOW. the:
STATIC_CALL_TRAMP(name)(...);
call is an external call, the above objtool rule will not detect it and
it'll stay using the trampoline...
Back to using a naming prefix I suppose.