Re: [RESEND][PATCH v3 09/17] x86/static_call: Add out-of-line static call implementation

From: Borislav Petkov
Date: Thu Mar 26 2020 - 10:57:20 EST


On Tue, Mar 24, 2020 at 02:56:12PM +0100, Peter Zijlstra wrote:
> +static void __static_call_transform(void *insn, u8 opcode, void *func)
> +{
> + const void *code = text_gen_insn(opcode, (long)insn, (long)func);
> +
> + if (WARN_ONCE(*(u8 *)insn != opcode,
> + "unexpected static call insn opcode 0x%x at %pS\n",
> + opcode, insn))
> + return;
> +
> + if (memcmp(insn, code, CALL_INSN_SIZE) == 0)
> + return;
> +
> + text_poke_bp(insn, code, CALL_INSN_SIZE, NULL);

Right, this is working with CALL_INSN_SIZE but ...

> +}
> +
> +void arch_static_call_transform(void *site, void *tramp, void *func)
> +{
> + mutex_lock(&text_mutex);
> +
> + if (tramp)
> + __static_call_transform(tramp, JMP32_INSN_OPCODE, func);

... it gets called with JMP32_INSN_OPCODE too. I mean, both lengths are
equal and all - it is just a bit confusing at a first glance. Maybe slap
a small comment that it is ok.

Thx.

--
Regards/Gruss,
Boris.

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