arm64/cfi,bpf: Support kCFI + BPF on arm64
authorPuranjay Mohan <puranjay12@gmail.com>
Fri, 1 Aug 2025 00:10:08 +0000 (00:10 +0000)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 1 Aug 2025 01:23:54 +0000 (18:23 -0700)
commit710618c760c0a3267221517d78f4cfb65ca7b882
treedc898c0a4e48e41b508530e364c9d36f2dc4e92f
parentf1befc82addda926c8301436123d041bf3249505
arm64/cfi,bpf: Support kCFI + BPF on arm64

Currently, bpf_dispatcher_*_func() is marked with `__nocfi` therefore
calling BPF programs from this interface doesn't cause CFI warnings.

When BPF programs are called directly from C: from BPF helpers or
struct_ops, CFI warnings are generated.

Implement proper CFI prologues for the BPF programs and callbacks and
drop __nocfi for arm64. Fix the trampoline generation code to emit kCFI
prologue when a struct_ops trampoline is being prepared.

Signed-off-by: Puranjay Mohan <puranjay12@gmail.com>
Co-developed-by: Maxwell Bland <mbland@motorola.com>
Signed-off-by: Maxwell Bland <mbland@motorola.com>
Co-developed-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
Tested-by: Dao Huang <huangdao1@oppo.com>
Acked-by: Will Deacon <will@kernel.org>
Link: https://lore.kernel.org/r/20250801001004.1859976-8-samitolvanen@google.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
arch/arm64/include/asm/cfi.h [new file with mode: 0644]
arch/arm64/net/bpf_jit_comp.c