[PATCH bpf-next v12 3/3] arm64/cfi,bpf: Support kCFI + BPF on arm64
Sami Tolvanen
samitolvanen at google.com
Tue Jul 22 07:33:40 PDT 2025
Hi,
On Mon, Jul 21, 2025 at 8:44 PM Xu Kuohai <xukuohai at huaweicloud.com> wrote:
>
> On 7/22/2025 4:20 AM, Sami Tolvanen wrote:
> > +static inline void emit_kcfi(u32 hash, struct jit_ctx *ctx)
> > +{
> > + if (IS_ENABLED(CONFIG_CFI_CLANG))
> > + emit(hash, ctx);
>
> I guess this won't work on big-endian cpus, since arm64 instructions
> are always stored in little-endian, but data not.
Nice catch! I'll send a new version with your suggested fix.
> > +}
> > +
> > /*
> > * Kernel addresses in the vmalloc space use at most 48 bits, and the
> > * remaining bits are guaranteed to be 0x1. So we can compose the address
> > @@ -476,7 +483,6 @@ static int build_prologue(struct jit_ctx *ctx, bool ebpf_from_cbpf)
> > const bool is_main_prog = !bpf_is_subprog(prog);
> > const u8 fp = bpf2a64[BPF_REG_FP];
> > const u8 arena_vm_base = bpf2a64[ARENA_VM_START];
> > - const int idx0 = ctx->idx;
> > int cur_offset;
> >
> > /*
> > @@ -502,6 +508,9 @@ static int build_prologue(struct jit_ctx *ctx, bool ebpf_from_cbpf)
> > *
> > */
> >
> > + emit_kcfi(is_main_prog ? cfi_bpf_hash : cfi_bpf_subprog_hash, ctx);
> > + const int idx0 = ctx->idx;
>
> move the idx0 definition back to its original position to match the
> coding style of the rest of the file?
The const definition needs to happen after emit_kcfi, because we
increment ctx->idx when CFI is enabled.
Sami
More information about the linux-arm-kernel
mailing list