On 2024/8/30 18:00, Xu Kuohai wrote: > On 8/30/2024 5:08 PM, Leon Hwang wrote: >> >> >> On 30/8/24 15:37, Xu Kuohai wrote: >>> On 8/27/2024 10:23 AM, Leon Hwang wrote: >>>> >> [...] >> >> This approach is really cool! >> >> I want an alike approach on x86. But I failed. Because, on x86, it's an >> indirect call to "call *rdx", aka "bpf_func(ctx, insnsi)". >> >> Let us imagine the arch_run_bpf() on x86: >> >> unsigned int __naked arch_run_bpf(const void *ctx, const struct bpf_insn >> *insnsi, bpf_func_t bpf_func) >> { >> asm ( >> "pushq %rbp\n\t" >> "movq %rsp, %rbp\n\t" >> "xor %rax, %rax\n\t" >> "pushq %rax\n\t" >> "movq %rsp, %rax\n\t" >> "callq *%rdx\n\t" >> "leave\n\t" >> "ret\n\t" >> ); >> } >> >> If we can change "callq *%rdx" to a direct call, it'll be really >> wonderful to resolve this tailcall issue on x86. >> > > Right, so we need static call here, perhaps we can create a custom > static call trampoline to setup tail call counter. > >> How to introduce arch_bpf_run() for all JIT backends? >> > > Seems we can not avoid arch specific code. One approach could be > to define a default __weak function to call bpf_func directly, > and let each arch to provide its own overridden implementation. > Hi Xu Kuohai, Can you send a separate patch to fix this issue on arm64? After you fixing it, I'll send the patch to fix it on x64. Thanks, Leon