tree: https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git master head: 4b3ff7dd4b69698c08ca1d51741fe773a7b30b0a commit: b1edfa9879e8a5e6040c33c157e23030176976a9 [9/23] Merge branch 'x86/cpu' config: x86_64-rhel-8.3-kselftests (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 reproduce (this is a W=1 build): # https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git/commit/?id=b1edfa9879e8a5e6040c33c157e23030176976a9 git remote add tip https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git git fetch --no-tags tip master git checkout b1edfa9879e8a5e6040c33c157e23030176976a9 # save the attached .config to linux build tree make W=1 ARCH=x86_64
If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <l...@intel.com> All errors (new ones prefixed by >>): arch/x86/net/bpf_jit_comp.c: In function 'arch_prepare_bpf_trampoline': >> arch/x86/net/bpf_jit_comp.c:2015:16: error: 'ideal_nops' undeclared (first >> use in this function) 2015 | memcpy(prog, ideal_nops[NOP_ATOMIC5], X86_PATCH_SIZE); | ^~~~~~~~~~ arch/x86/net/bpf_jit_comp.c:2015:16: note: each undeclared identifier is reported only once for each function it appears in >> arch/x86/net/bpf_jit_comp.c:2015:27: error: 'NOP_ATOMIC5' undeclared (first >> use in this function); did you mean 'GFP_ATOMIC'? 2015 | memcpy(prog, ideal_nops[NOP_ATOMIC5], X86_PATCH_SIZE); | ^~~~~~~~~~~ | GFP_ATOMIC arch/x86/net/bpf_jit_comp.c: At top level: arch/x86/net/bpf_jit_comp.c:2179:5: warning: no previous prototype for 'arch_prepare_bpf_dispatcher' [-Wmissing-prototypes] 2179 | int arch_prepare_bpf_dispatcher(void *image, s64 *funcs, int num_funcs) | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ vim +/ideal_nops +2015 arch/x86/net/bpf_jit_comp.c fec56f5890d93f Alexei Starovoitov 2019-11-14 1878 fec56f5890d93f Alexei Starovoitov 2019-11-14 1879 /* Example: fec56f5890d93f Alexei Starovoitov 2019-11-14 1880 * __be16 eth_type_trans(struct sk_buff *skb, struct net_device *dev); fec56f5890d93f Alexei Starovoitov 2019-11-14 1881 * its 'struct btf_func_model' will be nr_args=2 fec56f5890d93f Alexei Starovoitov 2019-11-14 1882 * The assembly code when eth_type_trans is executing after trampoline: fec56f5890d93f Alexei Starovoitov 2019-11-14 1883 * fec56f5890d93f Alexei Starovoitov 2019-11-14 1884 * push rbp fec56f5890d93f Alexei Starovoitov 2019-11-14 1885 * mov rbp, rsp fec56f5890d93f Alexei Starovoitov 2019-11-14 1886 * sub rsp, 16 // space for skb and dev fec56f5890d93f Alexei Starovoitov 2019-11-14 1887 * push rbx // temp regs to pass start time fec56f5890d93f Alexei Starovoitov 2019-11-14 1888 * mov qword ptr [rbp - 16], rdi // save skb pointer to stack fec56f5890d93f Alexei Starovoitov 2019-11-14 1889 * mov qword ptr [rbp - 8], rsi // save dev pointer to stack fec56f5890d93f Alexei Starovoitov 2019-11-14 1890 * call __bpf_prog_enter // rcu_read_lock and preempt_disable fec56f5890d93f Alexei Starovoitov 2019-11-14 1891 * mov rbx, rax // remember start time in bpf stats are enabled fec56f5890d93f Alexei Starovoitov 2019-11-14 1892 * lea rdi, [rbp - 16] // R1==ctx of bpf prog fec56f5890d93f Alexei Starovoitov 2019-11-14 1893 * call addr_of_jited_FENTRY_prog fec56f5890d93f Alexei Starovoitov 2019-11-14 1894 * movabsq rdi, 64bit_addr_of_struct_bpf_prog // unused if bpf stats are off fec56f5890d93f Alexei Starovoitov 2019-11-14 1895 * mov rsi, rbx // prog start time fec56f5890d93f Alexei Starovoitov 2019-11-14 1896 * call __bpf_prog_exit // rcu_read_unlock, preempt_enable and stats math fec56f5890d93f Alexei Starovoitov 2019-11-14 1897 * mov rdi, qword ptr [rbp - 16] // restore skb pointer from stack fec56f5890d93f Alexei Starovoitov 2019-11-14 1898 * mov rsi, qword ptr [rbp - 8] // restore dev pointer from stack fec56f5890d93f Alexei Starovoitov 2019-11-14 1899 * pop rbx fec56f5890d93f Alexei Starovoitov 2019-11-14 1900 * leave fec56f5890d93f Alexei Starovoitov 2019-11-14 1901 * ret fec56f5890d93f Alexei Starovoitov 2019-11-14 1902 * fec56f5890d93f Alexei Starovoitov 2019-11-14 1903 * eth_type_trans has 5 byte nop at the beginning. These 5 bytes will be fec56f5890d93f Alexei Starovoitov 2019-11-14 1904 * replaced with 'call generated_bpf_trampoline'. When it returns fec56f5890d93f Alexei Starovoitov 2019-11-14 1905 * eth_type_trans will continue executing with original skb and dev pointers. fec56f5890d93f Alexei Starovoitov 2019-11-14 1906 * fec56f5890d93f Alexei Starovoitov 2019-11-14 1907 * The assembly code when eth_type_trans is called from trampoline: fec56f5890d93f Alexei Starovoitov 2019-11-14 1908 * fec56f5890d93f Alexei Starovoitov 2019-11-14 1909 * push rbp fec56f5890d93f Alexei Starovoitov 2019-11-14 1910 * mov rbp, rsp fec56f5890d93f Alexei Starovoitov 2019-11-14 1911 * sub rsp, 24 // space for skb, dev, return value fec56f5890d93f Alexei Starovoitov 2019-11-14 1912 * push rbx // temp regs to pass start time fec56f5890d93f Alexei Starovoitov 2019-11-14 1913 * mov qword ptr [rbp - 24], rdi // save skb pointer to stack fec56f5890d93f Alexei Starovoitov 2019-11-14 1914 * mov qword ptr [rbp - 16], rsi // save dev pointer to stack fec56f5890d93f Alexei Starovoitov 2019-11-14 1915 * call __bpf_prog_enter // rcu_read_lock and preempt_disable fec56f5890d93f Alexei Starovoitov 2019-11-14 1916 * mov rbx, rax // remember start time if bpf stats are enabled fec56f5890d93f Alexei Starovoitov 2019-11-14 1917 * lea rdi, [rbp - 24] // R1==ctx of bpf prog fec56f5890d93f Alexei Starovoitov 2019-11-14 1918 * call addr_of_jited_FENTRY_prog // bpf prog can access skb and dev fec56f5890d93f Alexei Starovoitov 2019-11-14 1919 * movabsq rdi, 64bit_addr_of_struct_bpf_prog // unused if bpf stats are off fec56f5890d93f Alexei Starovoitov 2019-11-14 1920 * mov rsi, rbx // prog start time fec56f5890d93f Alexei Starovoitov 2019-11-14 1921 * call __bpf_prog_exit // rcu_read_unlock, preempt_enable and stats math fec56f5890d93f Alexei Starovoitov 2019-11-14 1922 * mov rdi, qword ptr [rbp - 24] // restore skb pointer from stack fec56f5890d93f Alexei Starovoitov 2019-11-14 1923 * mov rsi, qword ptr [rbp - 16] // restore dev pointer from stack fec56f5890d93f Alexei Starovoitov 2019-11-14 1924 * call eth_type_trans+5 // execute body of eth_type_trans fec56f5890d93f Alexei Starovoitov 2019-11-14 1925 * mov qword ptr [rbp - 8], rax // save return value fec56f5890d93f Alexei Starovoitov 2019-11-14 1926 * call __bpf_prog_enter // rcu_read_lock and preempt_disable fec56f5890d93f Alexei Starovoitov 2019-11-14 1927 * mov rbx, rax // remember start time in bpf stats are enabled fec56f5890d93f Alexei Starovoitov 2019-11-14 1928 * lea rdi, [rbp - 24] // R1==ctx of bpf prog fec56f5890d93f Alexei Starovoitov 2019-11-14 1929 * call addr_of_jited_FEXIT_prog // bpf prog can access skb, dev, return value fec56f5890d93f Alexei Starovoitov 2019-11-14 1930 * movabsq rdi, 64bit_addr_of_struct_bpf_prog // unused if bpf stats are off fec56f5890d93f Alexei Starovoitov 2019-11-14 1931 * mov rsi, rbx // prog start time fec56f5890d93f Alexei Starovoitov 2019-11-14 1932 * call __bpf_prog_exit // rcu_read_unlock, preempt_enable and stats math fec56f5890d93f Alexei Starovoitov 2019-11-14 1933 * mov rax, qword ptr [rbp - 8] // restore eth_type_trans's return value fec56f5890d93f Alexei Starovoitov 2019-11-14 1934 * pop rbx fec56f5890d93f Alexei Starovoitov 2019-11-14 1935 * leave fec56f5890d93f Alexei Starovoitov 2019-11-14 1936 * add rsp, 8 // skip eth_type_trans's frame fec56f5890d93f Alexei Starovoitov 2019-11-14 1937 * ret // return to its caller fec56f5890d93f Alexei Starovoitov 2019-11-14 1938 */ e21aa341785c67 Alexei Starovoitov 2021-03-16 1939 int arch_prepare_bpf_trampoline(struct bpf_tramp_image *im, void *image, void *image_end, 85d33df357b634 Martin KaFai Lau 2020-01-08 1940 const struct btf_func_model *m, u32 flags, 88fd9e5352fe05 KP Singh 2020-03-04 1941 struct bpf_tramp_progs *tprogs, fec56f5890d93f Alexei Starovoitov 2019-11-14 1942 void *orig_call) fec56f5890d93f Alexei Starovoitov 2019-11-14 1943 { ae24082331d9bb KP Singh 2020-03-04 1944 int ret, i, cnt = 0, nr_args = m->nr_args; fec56f5890d93f Alexei Starovoitov 2019-11-14 1945 int stack_size = nr_args * 8; 88fd9e5352fe05 KP Singh 2020-03-04 1946 struct bpf_tramp_progs *fentry = &tprogs[BPF_TRAMP_FENTRY]; 88fd9e5352fe05 KP Singh 2020-03-04 1947 struct bpf_tramp_progs *fexit = &tprogs[BPF_TRAMP_FEXIT]; ae24082331d9bb KP Singh 2020-03-04 1948 struct bpf_tramp_progs *fmod_ret = &tprogs[BPF_TRAMP_MODIFY_RETURN]; ae24082331d9bb KP Singh 2020-03-04 1949 u8 **branches = NULL; fec56f5890d93f Alexei Starovoitov 2019-11-14 1950 u8 *prog; fec56f5890d93f Alexei Starovoitov 2019-11-14 1951 fec56f5890d93f Alexei Starovoitov 2019-11-14 1952 /* x86-64 supports up to 6 arguments. 7+ can be added in the future */ fec56f5890d93f Alexei Starovoitov 2019-11-14 1953 if (nr_args > 6) fec56f5890d93f Alexei Starovoitov 2019-11-14 1954 return -ENOTSUPP; fec56f5890d93f Alexei Starovoitov 2019-11-14 1955 fec56f5890d93f Alexei Starovoitov 2019-11-14 1956 if ((flags & BPF_TRAMP_F_RESTORE_REGS) && fec56f5890d93f Alexei Starovoitov 2019-11-14 1957 (flags & BPF_TRAMP_F_SKIP_FRAME)) fec56f5890d93f Alexei Starovoitov 2019-11-14 1958 return -EINVAL; fec56f5890d93f Alexei Starovoitov 2019-11-14 1959 fec56f5890d93f Alexei Starovoitov 2019-11-14 1960 if (flags & BPF_TRAMP_F_CALL_ORIG) fec56f5890d93f Alexei Starovoitov 2019-11-14 1961 stack_size += 8; /* room for return value of orig_call */ fec56f5890d93f Alexei Starovoitov 2019-11-14 1962 fec56f5890d93f Alexei Starovoitov 2019-11-14 1963 if (flags & BPF_TRAMP_F_SKIP_FRAME) fec56f5890d93f Alexei Starovoitov 2019-11-14 1964 /* skip patched call instruction and point orig_call to actual fec56f5890d93f Alexei Starovoitov 2019-11-14 1965 * body of the kernel function. fec56f5890d93f Alexei Starovoitov 2019-11-14 1966 */ 4b3da77b72ad6b Daniel Borkmann 2019-11-22 1967 orig_call += X86_PATCH_SIZE; fec56f5890d93f Alexei Starovoitov 2019-11-14 1968 fec56f5890d93f Alexei Starovoitov 2019-11-14 1969 prog = image; fec56f5890d93f Alexei Starovoitov 2019-11-14 1970 fec56f5890d93f Alexei Starovoitov 2019-11-14 1971 EMIT1(0x55); /* push rbp */ fec56f5890d93f Alexei Starovoitov 2019-11-14 1972 EMIT3(0x48, 0x89, 0xE5); /* mov rbp, rsp */ fec56f5890d93f Alexei Starovoitov 2019-11-14 1973 EMIT4(0x48, 0x83, 0xEC, stack_size); /* sub rsp, stack_size */ fec56f5890d93f Alexei Starovoitov 2019-11-14 1974 EMIT1(0x53); /* push rbx */ fec56f5890d93f Alexei Starovoitov 2019-11-14 1975 fec56f5890d93f Alexei Starovoitov 2019-11-14 1976 save_regs(m, &prog, nr_args, stack_size); fec56f5890d93f Alexei Starovoitov 2019-11-14 1977 e21aa341785c67 Alexei Starovoitov 2021-03-16 1978 if (flags & BPF_TRAMP_F_CALL_ORIG) { e21aa341785c67 Alexei Starovoitov 2021-03-16 1979 /* arg1: mov rdi, im */ e21aa341785c67 Alexei Starovoitov 2021-03-16 1980 emit_mov_imm64(&prog, BPF_REG_1, (long) im >> 32, (u32) (long) im); e21aa341785c67 Alexei Starovoitov 2021-03-16 1981 if (emit_call(&prog, __bpf_tramp_enter, prog)) { e21aa341785c67 Alexei Starovoitov 2021-03-16 1982 ret = -EINVAL; e21aa341785c67 Alexei Starovoitov 2021-03-16 1983 goto cleanup; e21aa341785c67 Alexei Starovoitov 2021-03-16 1984 } e21aa341785c67 Alexei Starovoitov 2021-03-16 1985 } e21aa341785c67 Alexei Starovoitov 2021-03-16 1986 88fd9e5352fe05 KP Singh 2020-03-04 1987 if (fentry->nr_progs) 88fd9e5352fe05 KP Singh 2020-03-04 1988 if (invoke_bpf(m, &prog, fentry, stack_size)) fec56f5890d93f Alexei Starovoitov 2019-11-14 1989 return -EINVAL; fec56f5890d93f Alexei Starovoitov 2019-11-14 1990 ae24082331d9bb KP Singh 2020-03-04 1991 if (fmod_ret->nr_progs) { ae24082331d9bb KP Singh 2020-03-04 1992 branches = kcalloc(fmod_ret->nr_progs, sizeof(u8 *), ae24082331d9bb KP Singh 2020-03-04 1993 GFP_KERNEL); ae24082331d9bb KP Singh 2020-03-04 1994 if (!branches) ae24082331d9bb KP Singh 2020-03-04 1995 return -ENOMEM; ae24082331d9bb KP Singh 2020-03-04 1996 ae24082331d9bb KP Singh 2020-03-04 1997 if (invoke_bpf_mod_ret(m, &prog, fmod_ret, stack_size, ae24082331d9bb KP Singh 2020-03-04 1998 branches)) { ae24082331d9bb KP Singh 2020-03-04 1999 ret = -EINVAL; ae24082331d9bb KP Singh 2020-03-04 2000 goto cleanup; ae24082331d9bb KP Singh 2020-03-04 2001 } ae24082331d9bb KP Singh 2020-03-04 2002 } ae24082331d9bb KP Singh 2020-03-04 2003 fec56f5890d93f Alexei Starovoitov 2019-11-14 2004 if (flags & BPF_TRAMP_F_CALL_ORIG) { fec56f5890d93f Alexei Starovoitov 2019-11-14 2005 restore_regs(m, &prog, nr_args, stack_size); fec56f5890d93f Alexei Starovoitov 2019-11-14 2006 fec56f5890d93f Alexei Starovoitov 2019-11-14 2007 /* call original function */ ae24082331d9bb KP Singh 2020-03-04 2008 if (emit_call(&prog, orig_call, prog)) { ae24082331d9bb KP Singh 2020-03-04 2009 ret = -EINVAL; ae24082331d9bb KP Singh 2020-03-04 2010 goto cleanup; ae24082331d9bb KP Singh 2020-03-04 2011 } fec56f5890d93f Alexei Starovoitov 2019-11-14 2012 /* remember return value in a stack for bpf prog to access */ fec56f5890d93f Alexei Starovoitov 2019-11-14 2013 emit_stx(&prog, BPF_DW, BPF_REG_FP, BPF_REG_0, -8); e21aa341785c67 Alexei Starovoitov 2021-03-16 2014 im->ip_after_call = prog; b9082970478009 Stanislav Fomichev 2021-03-19 @2015 memcpy(prog, ideal_nops[NOP_ATOMIC5], X86_PATCH_SIZE); b9082970478009 Stanislav Fomichev 2021-03-19 2016 prog += X86_PATCH_SIZE; fec56f5890d93f Alexei Starovoitov 2019-11-14 2017 } fec56f5890d93f Alexei Starovoitov 2019-11-14 2018 ae24082331d9bb KP Singh 2020-03-04 2019 if (fmod_ret->nr_progs) { ae24082331d9bb KP Singh 2020-03-04 2020 /* From Intel 64 and IA-32 Architectures Optimization ae24082331d9bb KP Singh 2020-03-04 2021 * Reference Manual, 3.4.1.4 Code Alignment, Assembly/Compiler ae24082331d9bb KP Singh 2020-03-04 2022 * Coding Rule 11: All branch targets should be 16-byte ae24082331d9bb KP Singh 2020-03-04 2023 * aligned. ae24082331d9bb KP Singh 2020-03-04 2024 */ ae24082331d9bb KP Singh 2020-03-04 2025 emit_align(&prog, 16); ae24082331d9bb KP Singh 2020-03-04 2026 /* Update the branches saved in invoke_bpf_mod_ret with the ae24082331d9bb KP Singh 2020-03-04 2027 * aligned address of do_fexit. ae24082331d9bb KP Singh 2020-03-04 2028 */ ae24082331d9bb KP Singh 2020-03-04 2029 for (i = 0; i < fmod_ret->nr_progs; i++) ae24082331d9bb KP Singh 2020-03-04 2030 emit_cond_near_jump(&branches[i], prog, branches[i], ae24082331d9bb KP Singh 2020-03-04 2031 X86_JNE); ae24082331d9bb KP Singh 2020-03-04 2032 } ae24082331d9bb KP Singh 2020-03-04 2033 88fd9e5352fe05 KP Singh 2020-03-04 2034 if (fexit->nr_progs) ae24082331d9bb KP Singh 2020-03-04 2035 if (invoke_bpf(m, &prog, fexit, stack_size)) { ae24082331d9bb KP Singh 2020-03-04 2036 ret = -EINVAL; ae24082331d9bb KP Singh 2020-03-04 2037 goto cleanup; ae24082331d9bb KP Singh 2020-03-04 2038 } fec56f5890d93f Alexei Starovoitov 2019-11-14 2039 fec56f5890d93f Alexei Starovoitov 2019-11-14 2040 if (flags & BPF_TRAMP_F_RESTORE_REGS) fec56f5890d93f Alexei Starovoitov 2019-11-14 2041 restore_regs(m, &prog, nr_args, stack_size); fec56f5890d93f Alexei Starovoitov 2019-11-14 2042 ae24082331d9bb KP Singh 2020-03-04 2043 /* This needs to be done regardless. If there were fmod_ret programs, ae24082331d9bb KP Singh 2020-03-04 2044 * the return value is only updated on the stack and still needs to be ae24082331d9bb KP Singh 2020-03-04 2045 * restored to R0. ae24082331d9bb KP Singh 2020-03-04 2046 */ e21aa341785c67 Alexei Starovoitov 2021-03-16 2047 if (flags & BPF_TRAMP_F_CALL_ORIG) { e21aa341785c67 Alexei Starovoitov 2021-03-16 2048 im->ip_epilogue = prog; e21aa341785c67 Alexei Starovoitov 2021-03-16 2049 /* arg1: mov rdi, im */ e21aa341785c67 Alexei Starovoitov 2021-03-16 2050 emit_mov_imm64(&prog, BPF_REG_1, (long) im >> 32, (u32) (long) im); e21aa341785c67 Alexei Starovoitov 2021-03-16 2051 if (emit_call(&prog, __bpf_tramp_exit, prog)) { e21aa341785c67 Alexei Starovoitov 2021-03-16 2052 ret = -EINVAL; e21aa341785c67 Alexei Starovoitov 2021-03-16 2053 goto cleanup; e21aa341785c67 Alexei Starovoitov 2021-03-16 2054 } fec56f5890d93f Alexei Starovoitov 2019-11-14 2055 /* restore original return value back into RAX */ fec56f5890d93f Alexei Starovoitov 2019-11-14 2056 emit_ldx(&prog, BPF_DW, BPF_REG_0, BPF_REG_FP, -8); e21aa341785c67 Alexei Starovoitov 2021-03-16 2057 } fec56f5890d93f Alexei Starovoitov 2019-11-14 2058 fec56f5890d93f Alexei Starovoitov 2019-11-14 2059 EMIT1(0x5B); /* pop rbx */ fec56f5890d93f Alexei Starovoitov 2019-11-14 2060 EMIT1(0xC9); /* leave */ fec56f5890d93f Alexei Starovoitov 2019-11-14 2061 if (flags & BPF_TRAMP_F_SKIP_FRAME) fec56f5890d93f Alexei Starovoitov 2019-11-14 2062 /* skip our return address and return to parent */ fec56f5890d93f Alexei Starovoitov 2019-11-14 2063 EMIT4(0x48, 0x83, 0xC4, 8); /* add rsp, 8 */ fec56f5890d93f Alexei Starovoitov 2019-11-14 2064 EMIT1(0xC3); /* ret */ 85d33df357b634 Martin KaFai Lau 2020-01-08 2065 /* Make sure the trampoline generation logic doesn't overflow */ ae24082331d9bb KP Singh 2020-03-04 2066 if (WARN_ON_ONCE(prog > (u8 *)image_end - BPF_INSN_SAFETY)) { ae24082331d9bb KP Singh 2020-03-04 2067 ret = -EFAULT; ae24082331d9bb KP Singh 2020-03-04 2068 goto cleanup; ae24082331d9bb KP Singh 2020-03-04 2069 } ae24082331d9bb KP Singh 2020-03-04 2070 ret = prog - (u8 *)image; ae24082331d9bb KP Singh 2020-03-04 2071 ae24082331d9bb KP Singh 2020-03-04 2072 cleanup: ae24082331d9bb KP Singh 2020-03-04 2073 kfree(branches); ae24082331d9bb KP Singh 2020-03-04 2074 return ret; fec56f5890d93f Alexei Starovoitov 2019-11-14 2075 } fec56f5890d93f Alexei Starovoitov 2019-11-14 2076 :::::: The code at line 2015 was first introduced by commit :::::: b9082970478009b778aa9b22d5561eef35b53b63 bpf: Use NOP_ATOMIC5 instead of emit_nops(&prog, 5) for BPF_TRAMP_F_CALL_ORIG :::::: TO: Stanislav Fomichev <s...@google.com> :::::: CC: Alexei Starovoitov <a...@kernel.org> --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org
.config.gz
Description: application/gzip