[PATCH bpf-next v10 2/3] cfi: Move BPF CFI types and helpers to generic code
Will Deacon
will at kernel.org
Fri Jul 18 04:39:59 PDT 2025
On Tue, Jul 15, 2025 at 10:57:36PM +0000, Sami Tolvanen wrote:
> Instead of duplicating the same code for each architecture, move
> the CFI type hash variables for BPF function types and related
> helper functions to generic CFI code, and allow architectures to
> override the function definitions if needed.
>
> Signed-off-by: Sami Tolvanen <samitolvanen at google.com>
> ---
> arch/riscv/include/asm/cfi.h | 16 ---------------
> arch/riscv/kernel/cfi.c | 24 -----------------------
> arch/x86/include/asm/cfi.h | 9 ---------
> arch/x86/kernel/alternative.c | 12 ------------
> include/linux/cfi.h | 37 +++++++++++++++++++++++++++--------
> kernel/cfi.c | 25 +++++++++++++++++++++++
> 6 files changed, 54 insertions(+), 69 deletions(-)
[...]
> @@ -27,6 +29,29 @@ enum bug_trap_type report_cfi_failure(struct pt_regs *regs, unsigned long addr,
> return BUG_TRAP_TYPE_BUG;
> }
>
> +u32 __weak cfi_get_func_hash(void *func)
> +{
> + u32 hash;
> +
> + if (get_kernel_nofault(hash, func - cfi_get_offset()))
> + return 0;
> +
> + return hash;
> +}
Do you really need the '__weak' function definition here, or could you
use an '#ifndef cfi_get_func_hash' guard, a bit like you're doing for
cfi_get_offset()?
Will
More information about the linux-arm-kernel
mailing list