Re: [PATCH v4 09/17] perf/core: Use static_call to optimize perf_guest_info_callbacks

From: Carlos Llamas

Date: Wed Mar 11 2026 - 19:06:56 EST


On Mon, Mar 09, 2026 at 10:31:56PM +0000, Sami Tolvanen wrote:
> Hi Carlos,
>
> If you need a stub with a matching CFI type for an arbitrary function,
> perhaps you can do something like this (arm64, untested):
>
> #define DEFINE_TYPED_STUB_RET0(name, reffunc) \
> typeof(reffunc) name; \
> __ADDRESSABLE(name); \
> asm( \
> " " __ALIGN_STR " \n" \
> " .4byte __kcfi_typeid_" #name " \n" \
> #name ": \n" \
> " bti c \n" \
> " mov x0, xzr \n" \
> " ret " \
> )
>
> For the !CONFIG_CFI case, or architectures that implement static calls,
> you can probably just point the stub to __static_call_return0:
>
> #define DEFINE_TYPED_STUB_RET0(name, reffunc) \
> typeof(reffunc) name __asm__("__static_call_return0")
>
> Sami

Alright, I've sent out a patch for this here:
https://lore.kernel.org/all/20260311225822.1565895-1-cmllamas@xxxxxxxxxx/

It might seem "incomplete" because it only handles the RET0 case and it
doesn't export the stubs either. However, I didn't find any static_calls
for which the lack of these things would be an issue.

I can address such things in a v2 if really needed though.

Cheers,
--
Carlos Llamas