Re: [RFC][PATCH 1/5] static_call: Make NULL static calls consistent

From: Sami Tolvanen
Date: Mon Mar 13 2023 - 13:49:57 EST


On Sun, Mar 12, 2023 at 8:17 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> On Fri, Mar 10, 2023 at 05:20:04PM -0800, Josh Poimboeuf wrote:
> > 2) Create yet another "tier" of static call implementations, for
> > arches which can have the unfortunate combo of CFI_CLANG +
> > !HAVE_STATIC_CALL. CONFIG_ALMOST_DONT_HAVE_STATIC_CALL?
> >
> > The arch can define ARCH_DEFINE_STATIC_CALL_NOP() which uses inline
> > asm to create a CFI-compliant NOP/BUG/whatever version of the
> > function (insert lots of hand-waving). Is the kcfi hash available
> > to inline asm at build time?
>
> Yes, clang creates magic symbol for everything it sees a declaration
> for. This symbols can be referenced from asm, linking will make it all
> work.
>
> And yes, C sucks, you can't actually create a function definition from a
> type :/ Otherwise this could be trivially fixable.

Wouldn't creating a separate inline assembly nop function that
references the CFI hash of another function with the correct type
potentially solve this issue like Josh suggested?

Sami