Thread (7 messages) 7 messages, 2 authors, 2025-07-22

Re: [PATCH bpf-next v12 3/3] arm64/cfi,bpf: Support kCFI + BPF on arm64

From: Sami Tolvanen <samitolvanen@google.com>
Date: 2025-07-22 14:34:18
Also in: bpf, lkml

Hi,

On Mon, Jul 21, 2025 at 8:44 PM Xu Kuohai [off-list ref] wrote:
On 7/22/2025 4:20 AM, Sami Tolvanen wrote:
quoted
+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.
quoted
+}
+
  /*
   * 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help