Subject: Re: [PATCH] static_call: use CFI-compliant return0 stubs

From: Carlos Llamas <[email-masked]>
Date: Thu, 12 Mar 2026 00:16:01 +0000

On Thu, Mar 12, 2026 at 12:14:06AM +0100, Peter Zijlstra wrote:
> On Wed, Mar 11, 2026 at 10:57:40PM +0000, Carlos Llamas wrote:
> > Architectures with !HAVE_STATIC_CALL (such as arm64) rely on the generic
> > static_call implementation via indirect calls. In particular, users of
> > DEFINE_STATIC_CALL_RET0, default to the generic __static_call_return0
> > stub to optimize the unset path.
> > 
> > However, __static_call_return0 has a fixed signature of "long (*)(void)"
> > which may not match the expected prototype at callsites. This triggers
> > CFI failures when CONFIG_CFI is enabled. A trivial linux-perf command
> > does it:
> 
> *sigh*...
> 
> And ARM64 can't really do the inline thing because its immediate range
> is too small and it all turns into a mess constructing the address in a
> register and doing an indirect call anyway, right?
> 

Right, the range for the jump is very limited. I _think_ tracepoints
have managed to implement the trampoline work-around:
  arch/arm64/kernel/ftrace.c

So it looks do-able I think but a much complex route.

--
Carlos Llamas