Skip to content

Commit 3d770bd

Browse files
chenhengqichenhuacai
authored andcommitted
LoongArch: BPF: No text_poke() for kernel text
The current implementation of bpf_arch_text_poke() requires 5 nops at patch site which is not applicable for kernel/module functions. Because LoongArch reserves ONLY 2 nops at the function entry. With CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS=y, this can be done by ftrace instead. See the following commit for details: * commit b91e014 ("bpf: Make BPF trampoline use register_ftrace_direct() API") * commit 9cdc3b6 ("LoongArch: ftrace: Add direct call support") Cc: [email protected] Tested-by: Vincent Li <[email protected]> Signed-off-by: Hengqi Chen <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent b0f50dc commit 3d770bd

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arch/loongarch/net/bpf_jit.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,8 +1292,10 @@ int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type poke_type,
12921292
u32 old_insns[LOONGARCH_LONG_JUMP_NINSNS] = {[0 ... 4] = INSN_NOP};
12931293
u32 new_insns[LOONGARCH_LONG_JUMP_NINSNS] = {[0 ... 4] = INSN_NOP};
12941294

1295-
if (!is_kernel_text((unsigned long)ip) &&
1296-
!is_bpf_text_address((unsigned long)ip))
1295+
/* Only poking bpf text is supported. Since kernel function entry
1296+
* is set up by ftrace, we rely on ftrace to poke kernel functions.
1297+
*/
1298+
if (!is_bpf_text_address((unsigned long)ip))
12971299
return -ENOTSUPP;
12981300

12991301
ret = emit_jump_or_nops(old_addr, ip, old_insns, is_call);

0 commit comments

Comments
 (0)