Re: [PATCH v2 08/11] arm64/static_call: Fix static call CFI violations

Peter Zijlstra
2023-03-22T14:20:41Z

On Wed, Mar 22, 2023 at 12:22:07PM +0000, Mark Rutland wrote:
> On Tue, Mar 21, 2023 at 09:00:14PM -0700, Josh Poimboeuf wrote:

> > +++ b/arch/arm64/include/asm/static_call.h
> > @@ -0,0 +1,29 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +#ifndef _ASM_ARM64_STATIC_CALL_H
> > +#define _ASM_ARM64_STATIC_CALL_H
> > +
> > +/*
> > + * Make a dummy reference to a function pointer in C to force the compiler to
> > + * emit a __kcfi_typeid_ symbol for asm to use.
> > + */
> > +#define GEN_CFI_SYM(func) \
> > + static typeof(func) __used __section(".discard.cfi") *__UNIQUE_ID(cfi) = func
> > +
> > +
> > +/* Generate a CFI-compliant static call NOP function */
> > +#define __ARCH_DEFINE_STATIC_CALL_CFI(name, insns) \
> > + asm(".align 4 \n" \

Should this ^ be:

__ALIGN_STR "\n" \

> > + ".word __kcfi_typeid_" name " \n" \
> > + ".globl " name " \n" \
> > + name ": \n" \
> > + "bti c \n" \
> > + insns " \n" \
> > + "ret \n" \
> > + ".type " name ", @function \n" \
> > + ".size " name ", . - " name " \n")

Also, Mark, I think you can remove __ALIGN and __ALIGN_STR from
arch/arm64/include/linkage.h they're very similar to the generic one.