Re: [PATCH v4 14/18] static_call: Add static_cond_call()

From: Peter Zijlstra
Date: Wed May 06 2020 - 14:16:35 EST


On Wed, May 06, 2020 at 01:09:24PM -0500, Josh Poimboeuf wrote:

> #define __ARCH_DEFINE_STATIC_CALL_TRAMP(name, insns) \
> asm(".pushsection .static_call.text, \"ax\" \n" \
> ".align 4 \n" \
> ".globl " STATIC_CALL_TRAMP_STR(name) " \n" \
> STATIC_CALL_TRAMP_STR(name) ": \n" \
> insns " \n" \
> ".type " STATIC_CALL_TRAMP_STR(name) ", @function \n" \
> ".size " STATIC_CALL_TRAMP_STR(name) ", . - " STATIC_CALL_TRAMP_STR(name) " \n" \
> ".popsection \n")
>
> #define ARCH_DEFINE_STATIC_CALL_TRAMP(name, func) \
> __ARCH_DEFINE_STATIC_CALL_TRAMP(name, "jmp.d32 " # func)

Note that this one is now:

.byte 0xe9; .long #func - (. + 4);

due to clang not actually understanding jmp.d32 :-(

> #define ARCH_DEFINE_STATIC_CALL_RETTRAMP(name, func) \
> __ARCH_DEFINE_STATIC_CALL_TRAMP(name, "ret; nop; nop; nop; nop")
>
> I like it. Makes it easy to see the differences between the tramps.

OK, ok.. changed :-)