CC: [email protected] CC: [email protected] CC: [email protected] TO: Alexei Starovoitov <[email protected]>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf.git relo_core head: bfeace99ce76472f92786d795eae779e8598e0e8 commit: 4b90a10711faf2b6751abe62a88422411c054c80 [6/12] bpf: Prepare relo_core.c for kernel duty. :::::: branch date: 7 hours ago :::::: commit date: 9 hours ago config: riscv-randconfig-c006-20210916 (attached as .config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project c8b3d7d6d6de37af68b2f379d0e37304f78e115f) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # install riscv cross compiling tool for clang build # apt-get install binutils-riscv64-linux-gnu # https://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf.git/commit/?id=4b90a10711faf2b6751abe62a88422411c054c80 git remote add ast-bpf https://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf.git git fetch --no-tags ast-bpf relo_core git checkout 4b90a10711faf2b6751abe62a88422411c054c80 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <[email protected]> clang-analyzer warnings: (new ones prefixed by >>) Suppressed 14 warnings (7 in non-user code, 7 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 18 warnings generated. Suppressed 18 warnings (11 in non-user code, 7 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 18 warnings generated. Suppressed 18 warnings (11 in non-user code, 7 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 2 warnings generated. Suppressed 2 warnings (2 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 18 warnings generated. Suppressed 18 warnings (11 in non-user code, 7 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 18 warnings generated. Suppressed 18 warnings (11 in non-user code, 7 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 13 warnings generated. Suppressed 13 warnings (6 in non-user code, 7 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 5 warnings generated. Suppressed 5 warnings (5 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 5 warnings generated. Suppressed 5 warnings (5 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 5 warnings generated. Suppressed 5 warnings (5 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 13 warnings generated. Suppressed 13 warnings (6 in non-user code, 7 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 16 warnings generated. Suppressed 16 warnings (9 in non-user code, 7 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 15 warnings generated. Suppressed 15 warnings (8 in non-user code, 7 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 14 warnings generated. Suppressed 14 warnings (7 in non-user code, 7 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 16 warnings generated. drivers/iio/accel/bma220_spi.c:63:8: warning: Excessive padding in 'struct bma220_data' (86 padding bytes, where 22 is optimal). Optimal fields order: tx_buf, spi_device, scan, lock, consider reordering the fields or adding explicit padding members [clang-analyzer-optin.performance.Padding] struct bma220_data { ~~~~~~~^~~~~~~~~~~~~ drivers/iio/accel/bma220_spi.c:63:8: note: Excessive padding in 'struct bma220_data' (86 padding bytes, where 22 is optimal). Optimal fields order: tx_buf, spi_device, scan, lock, consider reordering the fields or adding explicit padding members struct bma220_data { ~~~~~~~^~~~~~~~~~~~~ Suppressed 15 warnings (8 in non-user code, 7 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 6 warnings generated. Suppressed 6 warnings (6 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 6 warnings generated. Suppressed 6 warnings (6 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 13 warnings generated. Suppressed 13 warnings (6 in non-user code, 7 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 5 warnings generated. Suppressed 5 warnings (5 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 5 warnings generated. Suppressed 5 warnings (5 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 5 warnings generated. Suppressed 5 warnings (5 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 5 warnings generated. Suppressed 5 warnings (5 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 12 warnings generated. Suppressed 12 warnings (5 in non-user code, 7 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 6 warnings generated. Suppressed 6 warnings (6 in non-user code). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 12 warnings generated. Suppressed 12 warnings (5 in non-user code, 7 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 15 warnings generated. drivers/clocksource/timer-of.c:191:3: warning: Value stored to 'flags' is never read [clang-analyzer-deadcode.DeadStores] flags |= TIMER_OF_IRQ; ^ drivers/clocksource/timer-of.c:191:3: note: Value stored to 'flags' is never read Suppressed 14 warnings (7 in non-user code, 7 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 12 warnings generated. Suppressed 12 warnings (5 in non-user code, 7 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 16 warnings generated. Suppressed 16 warnings (8 in non-user code, 8 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 8 warnings generated. >> tools/lib/bpf/relo_core.c:1045:7: warning: Branch condition evaluates to a >> garbage value [clang-analyzer-core.uninitialized.Branch] if (res->fail_memsz_adjust) { ^ tools/lib/bpf/relo_core.c:1235:6: note: Assuming 'local_type' is non-null if (!local_type) ^~~~~~~~~~~ tools/lib/bpf/relo_core.c:1235:2: note: Taking false branch if (!local_type) ^ tools/lib/bpf/relo_core.c:1239:6: note: Assuming 'local_name' is non-null if (!local_name) ^~~~~~~~~~~ tools/lib/bpf/relo_core.c:1239:2: note: Taking false branch if (!local_name) ^ tools/lib/bpf/relo_core.c:1243:6: note: Calling 'str_is_empty' if (str_is_empty(spec_str)) ^~~~~~~~~~~~~~~~~~~~~~ include/linux/btf.h:148:9: note: Assuming 's' is non-null return !s || !s[0]; ^~ include/linux/btf.h:148:9: note: Left side of '||' is false include/linux/btf.h:148:15: note: Assuming the condition is false return !s || !s[0]; ^~~~~ include/linux/btf.h:148:2: note: Returning zero, which participates in a condition later return !s || !s[0]; ^~~~~~~~~~~~~~~~~~ tools/lib/bpf/relo_core.c:1243:6: note: Returning from 'str_is_empty' if (str_is_empty(spec_str)) ^~~~~~~~~~~~~~~~~~~~~~ tools/lib/bpf/relo_core.c:1243:2: note: Taking false branch if (str_is_empty(spec_str)) ^ tools/lib/bpf/relo_core.c:1247:6: note: Assuming 'err' is 0 if (err) { ^~~ tools/lib/bpf/relo_core.c:1247:2: note: Taking false branch if (err) { ^ tools/lib/bpf/relo_core.c:1255:2: note: Loop condition is false. Exiting loop pr_debug("prog '%s': relo #%d: kind <%s> (%d), spec is ", prog_name, ^ tools/lib/bpf/relo_core.c:69:28: note: expanded from macro 'pr_debug' #define pr_debug(fmt, ...) __pr(LIBBPF_DEBUG, fmt, ##__VA_ARGS__) ^ tools/lib/bpf/relo_core.c:59:31: note: expanded from macro '__pr' #define __pr(level, fmt, ...) \ ^ tools/lib/bpf/relo_core.c:1261:12: note: Field 'kind' is equal to BPF_TYPE_ID_LOCAL if (relo->kind == BPF_TYPE_ID_LOCAL) { ^ tools/lib/bpf/relo_core.c:1261:2: note: Taking true branch if (relo->kind == BPF_TYPE_ID_LOCAL) { ^ tools/lib/bpf/relo_core.c:1266:3: note: Control jumps to line 1360 goto patch_insn; ^ tools/lib/bpf/relo_core.c:1360:8: note: Calling 'bpf_core_patch_insn' err = bpf_core_patch_insn(prog_name, insn, insn_idx, relo, relo_idx, &targ_res); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ tools/lib/bpf/relo_core.c:1001:11: note: Field 'poison' is false if (res->poison) { ^ tools/lib/bpf/relo_core.c:1001:2: note: Taking false branch if (res->poison) { ^ tools/lib/bpf/relo_core.c:1015:2: note: Control jumps to 'case 3:' at line 1034 switch (class) { ^ tools/lib/bpf/relo_core.c:1035:12: note: Field 'validate' is true if (res->validate && insn->off != orig_val) { ^ tools/lib/bpf/relo_core.c:1035:7: note: Left side of '&&' is true if (res->validate && insn->off != orig_val) { ^ tools/lib/bpf/relo_core.c:1035:24: note: Assuming 'orig_val' is equal to field 'off' if (res->validate && insn->off != orig_val) { ^~~~~~~~~~~~~~~~~~~~~ tools/lib/bpf/relo_core.c:1035:3: note: Taking false branch if (res->validate && insn->off != orig_val) { ^ tools/lib/bpf/relo_core.c:1040:7: note: Assuming the condition is false if (new_val > SHRT_MAX) { ^~~~~~~~~~~~~~~~~~ tools/lib/bpf/relo_core.c:1040:3: note: Taking false branch if (new_val > SHRT_MAX) { ^ tools/lib/bpf/relo_core.c:1045:7: note: Branch condition evaluates to a garbage value if (res->fail_memsz_adjust) { ^~~~~~~~~~~~~~~~~~~~~~ Suppressed 7 warnings (6 in non-user code, 1 with check filters). Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well. 18 warnings generated. drivers/misc/habanalabs/gaudi/gaudi.c:1111:2: warning: Value stored to 'cb_size' is never read [clang-analyzer-deadcode.DeadStores] cb_size += gaudi_gen_wait_cb(hdev, &wait_prop); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/misc/habanalabs/gaudi/gaudi.c:1111:2: note: Value stored to 'cb_size' is never read cb_size += gaudi_gen_wait_cb(hdev, &wait_prop); ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/misc/habanalabs/gaudi/gaudi.c:1144:2: warning: Value stored to 'cb_size' is never read [clang-analyzer-deadcode.DeadStores] vim +1045 tools/lib/bpf/relo_core.c b0588390dbcedc Alexei Starovoitov 2021-07-20 974 b0588390dbcedc Alexei Starovoitov 2021-07-20 975 /* b0588390dbcedc Alexei Starovoitov 2021-07-20 976 * Patch relocatable BPF instruction. b0588390dbcedc Alexei Starovoitov 2021-07-20 977 * b0588390dbcedc Alexei Starovoitov 2021-07-20 978 * Patched value is determined by relocation kind and target specification. b0588390dbcedc Alexei Starovoitov 2021-07-20 979 * For existence relocations target spec will be NULL if field/type is not found. b0588390dbcedc Alexei Starovoitov 2021-07-20 980 * Expected insn->imm value is determined using relocation kind and local b0588390dbcedc Alexei Starovoitov 2021-07-20 981 * spec, and is checked before patching instruction. If actual insn->imm value b0588390dbcedc Alexei Starovoitov 2021-07-20 982 * is wrong, bail out with error. b0588390dbcedc Alexei Starovoitov 2021-07-20 983 * b0588390dbcedc Alexei Starovoitov 2021-07-20 984 * Currently supported classes of BPF instruction are: b0588390dbcedc Alexei Starovoitov 2021-07-20 985 * 1. rX = <imm> (assignment with immediate operand); b0588390dbcedc Alexei Starovoitov 2021-07-20 986 * 2. rX += <imm> (arithmetic operations with immediate operand); b0588390dbcedc Alexei Starovoitov 2021-07-20 987 * 3. rX = <imm64> (load with 64-bit immediate value); b0588390dbcedc Alexei Starovoitov 2021-07-20 988 * 4. rX = *(T *)(rY + <off>), where T is one of {u8, u16, u32, u64}; b0588390dbcedc Alexei Starovoitov 2021-07-20 989 * 5. *(T *)(rX + <off>) = rY, where T is one of {u8, u16, u32, u64}; b0588390dbcedc Alexei Starovoitov 2021-07-20 990 * 6. *(T *)(rX + <off>) = <imm>, where T is one of {u8, u16, u32, u64}. b0588390dbcedc Alexei Starovoitov 2021-07-20 991 */ b0588390dbcedc Alexei Starovoitov 2021-07-20 992 static int bpf_core_patch_insn(const char *prog_name, struct bpf_insn *insn, b0588390dbcedc Alexei Starovoitov 2021-07-20 993 int insn_idx, const struct bpf_core_relo *relo, b0588390dbcedc Alexei Starovoitov 2021-07-20 994 int relo_idx, const struct bpf_core_relo_res *res) b0588390dbcedc Alexei Starovoitov 2021-07-20 995 { b0588390dbcedc Alexei Starovoitov 2021-07-20 996 __u32 orig_val, new_val; b0588390dbcedc Alexei Starovoitov 2021-07-20 997 __u8 class; b0588390dbcedc Alexei Starovoitov 2021-07-20 998 b0588390dbcedc Alexei Starovoitov 2021-07-20 999 class = BPF_CLASS(insn->code); b0588390dbcedc Alexei Starovoitov 2021-07-20 1000 b0588390dbcedc Alexei Starovoitov 2021-07-20 1001 if (res->poison) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1002 poison: b0588390dbcedc Alexei Starovoitov 2021-07-20 1003 /* poison second part of ldimm64 to avoid confusing error from b0588390dbcedc Alexei Starovoitov 2021-07-20 1004 * verifier about "unknown opcode 00" b0588390dbcedc Alexei Starovoitov 2021-07-20 1005 */ b0588390dbcedc Alexei Starovoitov 2021-07-20 1006 if (is_ldimm64_insn(insn)) b0588390dbcedc Alexei Starovoitov 2021-07-20 1007 bpf_core_poison_insn(prog_name, relo_idx, insn_idx + 1, insn + 1); b0588390dbcedc Alexei Starovoitov 2021-07-20 1008 bpf_core_poison_insn(prog_name, relo_idx, insn_idx, insn); b0588390dbcedc Alexei Starovoitov 2021-07-20 1009 return 0; b0588390dbcedc Alexei Starovoitov 2021-07-20 1010 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1011 b0588390dbcedc Alexei Starovoitov 2021-07-20 1012 orig_val = res->orig_val; b0588390dbcedc Alexei Starovoitov 2021-07-20 1013 new_val = res->new_val; b0588390dbcedc Alexei Starovoitov 2021-07-20 1014 b0588390dbcedc Alexei Starovoitov 2021-07-20 1015 switch (class) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1016 case BPF_ALU: b0588390dbcedc Alexei Starovoitov 2021-07-20 1017 case BPF_ALU64: b0588390dbcedc Alexei Starovoitov 2021-07-20 1018 if (BPF_SRC(insn->code) != BPF_K) b0588390dbcedc Alexei Starovoitov 2021-07-20 1019 return -EINVAL; b0588390dbcedc Alexei Starovoitov 2021-07-20 1020 if (res->validate && insn->imm != orig_val) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1021 pr_warn("prog '%s': relo #%d: unexpected insn #%d (ALU/ALU64) value: got %u, exp %u -> %u\n", b0588390dbcedc Alexei Starovoitov 2021-07-20 1022 prog_name, relo_idx, b0588390dbcedc Alexei Starovoitov 2021-07-20 1023 insn_idx, insn->imm, orig_val, new_val); b0588390dbcedc Alexei Starovoitov 2021-07-20 1024 return -EINVAL; b0588390dbcedc Alexei Starovoitov 2021-07-20 1025 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1026 orig_val = insn->imm; b0588390dbcedc Alexei Starovoitov 2021-07-20 1027 insn->imm = new_val; b0588390dbcedc Alexei Starovoitov 2021-07-20 1028 pr_debug("prog '%s': relo #%d: patched insn #%d (ALU/ALU64) imm %u -> %u\n", b0588390dbcedc Alexei Starovoitov 2021-07-20 1029 prog_name, relo_idx, insn_idx, b0588390dbcedc Alexei Starovoitov 2021-07-20 1030 orig_val, new_val); b0588390dbcedc Alexei Starovoitov 2021-07-20 1031 break; b0588390dbcedc Alexei Starovoitov 2021-07-20 1032 case BPF_LDX: b0588390dbcedc Alexei Starovoitov 2021-07-20 1033 case BPF_ST: b0588390dbcedc Alexei Starovoitov 2021-07-20 1034 case BPF_STX: b0588390dbcedc Alexei Starovoitov 2021-07-20 1035 if (res->validate && insn->off != orig_val) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1036 pr_warn("prog '%s': relo #%d: unexpected insn #%d (LDX/ST/STX) value: got %u, exp %u -> %u\n", b0588390dbcedc Alexei Starovoitov 2021-07-20 1037 prog_name, relo_idx, insn_idx, insn->off, orig_val, new_val); b0588390dbcedc Alexei Starovoitov 2021-07-20 1038 return -EINVAL; b0588390dbcedc Alexei Starovoitov 2021-07-20 1039 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1040 if (new_val > SHRT_MAX) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1041 pr_warn("prog '%s': relo #%d: insn #%d (LDX/ST/STX) value too big: %u\n", b0588390dbcedc Alexei Starovoitov 2021-07-20 1042 prog_name, relo_idx, insn_idx, new_val); b0588390dbcedc Alexei Starovoitov 2021-07-20 1043 return -ERANGE; b0588390dbcedc Alexei Starovoitov 2021-07-20 1044 } b0588390dbcedc Alexei Starovoitov 2021-07-20 @1045 if (res->fail_memsz_adjust) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1046 pr_warn("prog '%s': relo #%d: insn #%d (LDX/ST/STX) accesses field incorrectly. " b0588390dbcedc Alexei Starovoitov 2021-07-20 1047 "Make sure you are accessing pointers, unsigned integers, or fields of matching type and size.\n", b0588390dbcedc Alexei Starovoitov 2021-07-20 1048 prog_name, relo_idx, insn_idx); b0588390dbcedc Alexei Starovoitov 2021-07-20 1049 goto poison; b0588390dbcedc Alexei Starovoitov 2021-07-20 1050 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1051 b0588390dbcedc Alexei Starovoitov 2021-07-20 1052 orig_val = insn->off; b0588390dbcedc Alexei Starovoitov 2021-07-20 1053 insn->off = new_val; b0588390dbcedc Alexei Starovoitov 2021-07-20 1054 pr_debug("prog '%s': relo #%d: patched insn #%d (LDX/ST/STX) off %u -> %u\n", b0588390dbcedc Alexei Starovoitov 2021-07-20 1055 prog_name, relo_idx, insn_idx, orig_val, new_val); b0588390dbcedc Alexei Starovoitov 2021-07-20 1056 b0588390dbcedc Alexei Starovoitov 2021-07-20 1057 if (res->new_sz != res->orig_sz) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1058 int insn_bytes_sz, insn_bpf_sz; b0588390dbcedc Alexei Starovoitov 2021-07-20 1059 b0588390dbcedc Alexei Starovoitov 2021-07-20 1060 insn_bytes_sz = insn_bpf_size_to_bytes(insn); b0588390dbcedc Alexei Starovoitov 2021-07-20 1061 if (insn_bytes_sz != res->orig_sz) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1062 pr_warn("prog '%s': relo #%d: insn #%d (LDX/ST/STX) unexpected mem size: got %d, exp %u\n", b0588390dbcedc Alexei Starovoitov 2021-07-20 1063 prog_name, relo_idx, insn_idx, insn_bytes_sz, res->orig_sz); b0588390dbcedc Alexei Starovoitov 2021-07-20 1064 return -EINVAL; b0588390dbcedc Alexei Starovoitov 2021-07-20 1065 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1066 b0588390dbcedc Alexei Starovoitov 2021-07-20 1067 insn_bpf_sz = insn_bytes_to_bpf_size(res->new_sz); b0588390dbcedc Alexei Starovoitov 2021-07-20 1068 if (insn_bpf_sz < 0) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1069 pr_warn("prog '%s': relo #%d: insn #%d (LDX/ST/STX) invalid new mem size: %u\n", b0588390dbcedc Alexei Starovoitov 2021-07-20 1070 prog_name, relo_idx, insn_idx, res->new_sz); b0588390dbcedc Alexei Starovoitov 2021-07-20 1071 return -EINVAL; b0588390dbcedc Alexei Starovoitov 2021-07-20 1072 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1073 b0588390dbcedc Alexei Starovoitov 2021-07-20 1074 insn->code = BPF_MODE(insn->code) | insn_bpf_sz | BPF_CLASS(insn->code); b0588390dbcedc Alexei Starovoitov 2021-07-20 1075 pr_debug("prog '%s': relo #%d: patched insn #%d (LDX/ST/STX) mem_sz %u -> %u\n", b0588390dbcedc Alexei Starovoitov 2021-07-20 1076 prog_name, relo_idx, insn_idx, res->orig_sz, res->new_sz); b0588390dbcedc Alexei Starovoitov 2021-07-20 1077 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1078 break; b0588390dbcedc Alexei Starovoitov 2021-07-20 1079 case BPF_LD: { b0588390dbcedc Alexei Starovoitov 2021-07-20 1080 __u64 imm; b0588390dbcedc Alexei Starovoitov 2021-07-20 1081 b0588390dbcedc Alexei Starovoitov 2021-07-20 1082 if (!is_ldimm64_insn(insn) || b0588390dbcedc Alexei Starovoitov 2021-07-20 1083 insn[0].src_reg != 0 || insn[0].off != 0 || b0588390dbcedc Alexei Starovoitov 2021-07-20 1084 insn[1].code != 0 || insn[1].dst_reg != 0 || b0588390dbcedc Alexei Starovoitov 2021-07-20 1085 insn[1].src_reg != 0 || insn[1].off != 0) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1086 pr_warn("prog '%s': relo #%d: insn #%d (LDIMM64) has unexpected form\n", b0588390dbcedc Alexei Starovoitov 2021-07-20 1087 prog_name, relo_idx, insn_idx); b0588390dbcedc Alexei Starovoitov 2021-07-20 1088 return -EINVAL; b0588390dbcedc Alexei Starovoitov 2021-07-20 1089 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1090 b0588390dbcedc Alexei Starovoitov 2021-07-20 1091 imm = insn[0].imm + ((__u64)insn[1].imm << 32); b0588390dbcedc Alexei Starovoitov 2021-07-20 1092 if (res->validate && imm != orig_val) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1093 pr_warn("prog '%s': relo #%d: unexpected insn #%d (LDIMM64) value: got %llu, exp %u -> %u\n", b0588390dbcedc Alexei Starovoitov 2021-07-20 1094 prog_name, relo_idx, b0588390dbcedc Alexei Starovoitov 2021-07-20 1095 insn_idx, (unsigned long long)imm, b0588390dbcedc Alexei Starovoitov 2021-07-20 1096 orig_val, new_val); b0588390dbcedc Alexei Starovoitov 2021-07-20 1097 return -EINVAL; b0588390dbcedc Alexei Starovoitov 2021-07-20 1098 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1099 b0588390dbcedc Alexei Starovoitov 2021-07-20 1100 insn[0].imm = new_val; b0588390dbcedc Alexei Starovoitov 2021-07-20 1101 insn[1].imm = 0; /* currently only 32-bit values are supported */ b0588390dbcedc Alexei Starovoitov 2021-07-20 1102 pr_debug("prog '%s': relo #%d: patched insn #%d (LDIMM64) imm64 %llu -> %u\n", b0588390dbcedc Alexei Starovoitov 2021-07-20 1103 prog_name, relo_idx, insn_idx, b0588390dbcedc Alexei Starovoitov 2021-07-20 1104 (unsigned long long)imm, new_val); b0588390dbcedc Alexei Starovoitov 2021-07-20 1105 break; b0588390dbcedc Alexei Starovoitov 2021-07-20 1106 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1107 default: b0588390dbcedc Alexei Starovoitov 2021-07-20 1108 pr_warn("prog '%s': relo #%d: trying to relocate unrecognized insn #%d, code:0x%x, src:0x%x, dst:0x%x, off:0x%x, imm:0x%x\n", b0588390dbcedc Alexei Starovoitov 2021-07-20 1109 prog_name, relo_idx, insn_idx, insn->code, b0588390dbcedc Alexei Starovoitov 2021-07-20 1110 insn->src_reg, insn->dst_reg, insn->off, insn->imm); b0588390dbcedc Alexei Starovoitov 2021-07-20 1111 return -EINVAL; b0588390dbcedc Alexei Starovoitov 2021-07-20 1112 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1113 b0588390dbcedc Alexei Starovoitov 2021-07-20 1114 return 0; b0588390dbcedc Alexei Starovoitov 2021-07-20 1115 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1116 :::::: The code at line 1045 was first introduced by commit :::::: b0588390dbcedcd74fab6ffb8afe8d52380fd8b6 libbpf: Split CO-RE logic into relo_core.c. :::::: TO: Alexei Starovoitov <[email protected]> :::::: CC: Andrii Nakryiko <[email protected]> --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/[email protected]
.config.gz
Description: application/gzip
_______________________________________________ kbuild mailing list -- [email protected] To unsubscribe send an email to [email protected]
