Skip to content

Commit 3ba5831

Browse files
puranjaymohanborkmann
authored andcommitted
bpf: Move bpf_jit_get_prog_name() to core.c
bpf_jit_get_prog_name() will be used by all JITs when enabling support for private stack. This function is currently implemented in the x86 JIT. Move the function to core.c so that other JITs can easily use it in their implementation of private stack. Signed-off-by: Puranjay Mohan <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent b114fce commit 3ba5831

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

arch/x86/net/bpf_jit_comp.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3501,13 +3501,6 @@ int arch_prepare_bpf_dispatcher(void *image, void *buf, s64 *funcs, int num_func
35013501
return emit_bpf_dispatcher(&prog, 0, num_funcs - 1, funcs, image, buf);
35023502
}
35033503

3504-
static const char *bpf_get_prog_name(struct bpf_prog *prog)
3505-
{
3506-
if (prog->aux->ksym.prog)
3507-
return prog->aux->ksym.name;
3508-
return prog->aux->name;
3509-
}
3510-
35113504
static void priv_stack_init_guard(void __percpu *priv_stack_ptr, int alloc_size)
35123505
{
35133506
int cpu, underflow_idx = (alloc_size - PRIV_STACK_GUARD_SZ) >> 3;
@@ -3531,7 +3524,7 @@ static void priv_stack_check_guard(void __percpu *priv_stack_ptr, int alloc_size
35313524
if (stack_ptr[0] != PRIV_STACK_GUARD_VAL ||
35323525
stack_ptr[underflow_idx] != PRIV_STACK_GUARD_VAL) {
35333526
pr_err("BPF private stack overflow/underflow detected for prog %sx\n",
3534-
bpf_get_prog_name(prog));
3527+
bpf_jit_get_prog_name(prog));
35353528
break;
35363529
}
35373530
}

include/linux/filter.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1278,6 +1278,8 @@ int bpf_jit_get_func_addr(const struct bpf_prog *prog,
12781278
const struct bpf_insn *insn, bool extra_pass,
12791279
u64 *func_addr, bool *func_addr_fixed);
12801280

1281+
const char *bpf_jit_get_prog_name(struct bpf_prog *prog);
1282+
12811283
struct bpf_prog *bpf_jit_blind_constants(struct bpf_prog *fp);
12821284
void bpf_jit_prog_release_other(struct bpf_prog *fp, struct bpf_prog *fp_other);
12831285

kernel/bpf/core.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,6 +1297,13 @@ int bpf_jit_get_func_addr(const struct bpf_prog *prog,
12971297
return 0;
12981298
}
12991299

1300+
const char *bpf_jit_get_prog_name(struct bpf_prog *prog)
1301+
{
1302+
if (prog->aux->ksym.prog)
1303+
return prog->aux->ksym.name;
1304+
return prog->aux->name;
1305+
}
1306+
13001307
static int bpf_jit_blind_insn(const struct bpf_insn *from,
13011308
const struct bpf_insn *aux,
13021309
struct bpf_insn *to_buff,

0 commit comments

Comments
 (0)