Skip to content

Commit d1d7283

Browse files
chenhengqiKernel Patches Daemon
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. 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") Signed-off-by: Hengqi Chen <[email protected]>
1 parent 3ad7a80 commit d1d7283

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

arch/loongarch/net/bpf_jit.c

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

1297-
if (!is_kernel_text((unsigned long)ip) &&
1298-
!is_bpf_text_address((unsigned long)ip))
1297+
if (!is_bpf_text_address((unsigned long)ip))
1298+
/* Only poking bpf text is supported. Since kernel function
1299+
* entry is set up by ftrace, we reply on ftrace to poke kernel
1300+
* functions.
1301+
*/
12991302
return -ENOTSUPP;
13001303

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

0 commit comments

Comments
 (0)