Skip to content

Commit cf71b17

Browse files
mfijalkoAlexei Starovoitov
authored andcommitted
bpf: rename poke descriptor's 'ip' member to 'tailcall_target'
Reflect the actual purpose of poke->ip and rename it to poke->tailcall_target so that it will not the be confused with another poke target that will be introduced in next commit. While at it, do the same thing with poke->ip_stable - rename it to poke->tailcall_target_stable. Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent a748c69 commit cf71b17

File tree

4 files changed

+24
-20
lines changed

4 files changed

+24
-20
lines changed

arch/x86/net/bpf_jit_comp.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ static void emit_bpf_tail_call_direct(struct bpf_jit_poke_descriptor *poke,
434434
EMIT3(0x83, 0xC0, 0x01); /* add eax, 1 */
435435
EMIT2_off32(0x89, 0x85, -36 - MAX_BPF_STACK); /* mov dword ptr [rbp -548], eax */
436436

437-
poke->ip = image + (addr - X86_PATCH_SIZE);
437+
poke->tailcall_target = image + (addr - X86_PATCH_SIZE);
438438
poke->adj_off = PROLOGUE_SIZE;
439439

440440
memcpy(prog, ideal_nops[NOP_ATOMIC5], X86_PATCH_SIZE);
@@ -453,7 +453,7 @@ static void bpf_tail_call_direct_fixup(struct bpf_prog *prog)
453453

454454
for (i = 0; i < prog->aux->size_poke_tab; i++) {
455455
poke = &prog->aux->poke_tab[i];
456-
WARN_ON_ONCE(READ_ONCE(poke->ip_stable));
456+
WARN_ON_ONCE(READ_ONCE(poke->tailcall_target_stable));
457457

458458
if (poke->reason != BPF_POKE_REASON_TAIL_CALL)
459459
continue;
@@ -464,18 +464,20 @@ static void bpf_tail_call_direct_fixup(struct bpf_prog *prog)
464464
if (target) {
465465
/* Plain memcpy is used when image is not live yet
466466
* and still not locked as read-only. Once poke
467-
* location is active (poke->ip_stable), any parallel
468-
* bpf_arch_text_poke() might occur still on the
469-
* read-write image until we finally locked it as
470-
* read-only. Both modifications on the given image
471-
* are under text_mutex to avoid interference.
467+
* location is active (poke->tailcall_target_stable),
468+
* any parallel bpf_arch_text_poke() might occur
469+
* still on the read-write image until we finally
470+
* locked it as read-only. Both modifications on
471+
* the given image are under text_mutex to avoid
472+
* interference.
472473
*/
473-
ret = __bpf_arch_text_poke(poke->ip, BPF_MOD_JUMP, NULL,
474+
ret = __bpf_arch_text_poke(poke->tailcall_target,
475+
BPF_MOD_JUMP, NULL,
474476
(u8 *)target->bpf_func +
475477
poke->adj_off, false);
476478
BUG_ON(ret < 0);
477479
}
478-
WRITE_ONCE(poke->ip_stable, true);
480+
WRITE_ONCE(poke->tailcall_target_stable, true);
479481
mutex_unlock(&array->aux->poke_mutex);
480482
}
481483
}

include/linux/bpf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -697,14 +697,14 @@ enum bpf_jit_poke_reason {
697697

698698
/* Descriptor of pokes pointing /into/ the JITed image. */
699699
struct bpf_jit_poke_descriptor {
700-
void *ip;
700+
void *tailcall_target;
701701
union {
702702
struct {
703703
struct bpf_map *map;
704704
u32 key;
705705
} tail_call;
706706
};
707-
bool ip_stable;
707+
bool tailcall_target_stable;
708708
u8 adj_off;
709709
u16 reason;
710710
u32 insn_idx;

kernel/bpf/arraymap.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -918,12 +918,13 @@ static void prog_array_map_poke_run(struct bpf_map *map, u32 key,
918918
* there could be danger of use after free otherwise.
919919
* 2) Initially when we start tracking aux, the program
920920
* is not JITed yet and also does not have a kallsyms
921-
* entry. We skip these as poke->ip_stable is not
922-
* active yet. The JIT will do the final fixup before
923-
* setting it stable. The various poke->ip_stable are
924-
* successively activated, so tail call updates can
925-
* arrive from here while JIT is still finishing its
926-
* final fixup for non-activated poke entries.
921+
* entry. We skip these as poke->tailcall_target_stable
922+
* is not active yet. The JIT will do the final fixup
923+
* before setting it stable. The various
924+
* poke->tailcall_target_stable are successively
925+
* activated, so tail call updates can arrive from here
926+
* while JIT is still finishing its final fixup for
927+
* non-activated poke entries.
927928
* 3) On program teardown, the program's kallsym entry gets
928929
* removed out of RCU callback, but we can only untrack
929930
* from sleepable context, therefore bpf_arch_text_poke()
@@ -940,15 +941,15 @@ static void prog_array_map_poke_run(struct bpf_map *map, u32 key,
940941
* 5) Any other error happening below from bpf_arch_text_poke()
941942
* is a unexpected bug.
942943
*/
943-
if (!READ_ONCE(poke->ip_stable))
944+
if (!READ_ONCE(poke->tailcall_target_stable))
944945
continue;
945946
if (poke->reason != BPF_POKE_REASON_TAIL_CALL)
946947
continue;
947948
if (poke->tail_call.map != map ||
948949
poke->tail_call.key != key)
949950
continue;
950951

951-
ret = bpf_arch_text_poke(poke->ip, BPF_MOD_JUMP,
952+
ret = bpf_arch_text_poke(poke->tailcall_target, BPF_MOD_JUMP,
952953
old ? (u8 *)old->bpf_func +
953954
poke->adj_off : NULL,
954955
new ? (u8 *)new->bpf_func +

kernel/bpf/core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,8 @@ int bpf_jit_add_poke_descriptor(struct bpf_prog *prog,
775775

776776
if (size > poke_tab_max)
777777
return -ENOSPC;
778-
if (poke->ip || poke->ip_stable || poke->adj_off)
778+
if (poke->tailcall_target || poke->tailcall_target_stable ||
779+
poke->adj_off)
779780
return -EINVAL;
780781

781782
switch (poke->reason) {

0 commit comments

Comments
 (0)