Messages in this thread | | | Date | Mon, 15 Nov 2021 07:21:21 +0800 | From | kernel test robot <> | Subject | [ast-bpf:relo_core 9/19] tools/lib/bpf/relo_core.c:1348:1: warning: the frame size of 1136 bytes is larger than 1024 bytes |
| |
tree: https://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf.git relo_core head: f17ef55e5e0bac0d11d3186cd1c468b5a1e047d7 commit: 03c354f8c71c2478c421d5552d284e0befb03861 [9/19] bpf: Prepare relo_core.c for kernel duty. config: arc-randconfig-r043-20211115 (attached as .config) compiler: arceb-elf-gcc (GCC) 11.2.0 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 # https://git.kernel.org/pub/scm/linux/kernel/git/ast/bpf.git/commit/?id=03c354f8c71c2478c421d5552d284e0befb03861 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 03c354f8c71c2478c421d5552d284e0befb03861 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=arc
If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@intel.com>
All warnings (new ones prefixed by >>):
tools/lib/bpf/relo_core.c: In function 'bpf_core_apply_relo_insn': >> tools/lib/bpf/relo_core.c:1348:1: warning: the frame size of 1136 bytes is larger than 1024 bytes [-Wframe-larger-than=] 1348 | } | ^
vim +1348 tools/lib/bpf/relo_core.c
b0588390dbcedc Alexei Starovoitov 2021-07-20 1147 b0588390dbcedc Alexei Starovoitov 2021-07-20 1148 /* b0588390dbcedc Alexei Starovoitov 2021-07-20 1149 * CO-RE relocate single instruction. b0588390dbcedc Alexei Starovoitov 2021-07-20 1150 * b0588390dbcedc Alexei Starovoitov 2021-07-20 1151 * The outline and important points of the algorithm: b0588390dbcedc Alexei Starovoitov 2021-07-20 1152 * 1. For given local type, find corresponding candidate target types. b0588390dbcedc Alexei Starovoitov 2021-07-20 1153 * Candidate type is a type with the same "essential" name, ignoring b0588390dbcedc Alexei Starovoitov 2021-07-20 1154 * everything after last triple underscore (___). E.g., `sample`, b0588390dbcedc Alexei Starovoitov 2021-07-20 1155 * `sample___flavor_one`, `sample___flavor_another_one`, are all candidates b0588390dbcedc Alexei Starovoitov 2021-07-20 1156 * for each other. Names with triple underscore are referred to as b0588390dbcedc Alexei Starovoitov 2021-07-20 1157 * "flavors" and are useful, among other things, to allow to b0588390dbcedc Alexei Starovoitov 2021-07-20 1158 * specify/support incompatible variations of the same kernel struct, which b0588390dbcedc Alexei Starovoitov 2021-07-20 1159 * might differ between different kernel versions and/or build b0588390dbcedc Alexei Starovoitov 2021-07-20 1160 * configurations. b0588390dbcedc Alexei Starovoitov 2021-07-20 1161 * b0588390dbcedc Alexei Starovoitov 2021-07-20 1162 * N.B. Struct "flavors" could be generated by bpftool's BTF-to-C b0588390dbcedc Alexei Starovoitov 2021-07-20 1163 * converter, when deduplicated BTF of a kernel still contains more than b0588390dbcedc Alexei Starovoitov 2021-07-20 1164 * one different types with the same name. In that case, ___2, ___3, etc b0588390dbcedc Alexei Starovoitov 2021-07-20 1165 * are appended starting from second name conflict. But start flavors are b0588390dbcedc Alexei Starovoitov 2021-07-20 1166 * also useful to be defined "locally", in BPF program, to extract same b0588390dbcedc Alexei Starovoitov 2021-07-20 1167 * data from incompatible changes between different kernel b0588390dbcedc Alexei Starovoitov 2021-07-20 1168 * versions/configurations. For instance, to handle field renames between b0588390dbcedc Alexei Starovoitov 2021-07-20 1169 * kernel versions, one can use two flavors of the struct name with the b0588390dbcedc Alexei Starovoitov 2021-07-20 1170 * same common name and use conditional relocations to extract that field, b0588390dbcedc Alexei Starovoitov 2021-07-20 1171 * depending on target kernel version. b0588390dbcedc Alexei Starovoitov 2021-07-20 1172 * 2. For each candidate type, try to match local specification to this b0588390dbcedc Alexei Starovoitov 2021-07-20 1173 * candidate target type. Matching involves finding corresponding b0588390dbcedc Alexei Starovoitov 2021-07-20 1174 * high-level spec accessors, meaning that all named fields should match, b0588390dbcedc Alexei Starovoitov 2021-07-20 1175 * as well as all array accesses should be within the actual bounds. Also, b0588390dbcedc Alexei Starovoitov 2021-07-20 1176 * types should be compatible (see bpf_core_fields_are_compat for details). b0588390dbcedc Alexei Starovoitov 2021-07-20 1177 * 3. It is supported and expected that there might be multiple flavors b0588390dbcedc Alexei Starovoitov 2021-07-20 1178 * matching the spec. As long as all the specs resolve to the same set of b0588390dbcedc Alexei Starovoitov 2021-07-20 1179 * offsets across all candidates, there is no error. If there is any b0588390dbcedc Alexei Starovoitov 2021-07-20 1180 * ambiguity, CO-RE relocation will fail. This is necessary to accomodate b0588390dbcedc Alexei Starovoitov 2021-07-20 1181 * imprefection of BTF deduplication, which can cause slight duplication of b0588390dbcedc Alexei Starovoitov 2021-07-20 1182 * the same BTF type, if some directly or indirectly referenced (by b0588390dbcedc Alexei Starovoitov 2021-07-20 1183 * pointer) type gets resolved to different actual types in different b0588390dbcedc Alexei Starovoitov 2021-07-20 1184 * object files. If such situation occurs, deduplicated BTF will end up b0588390dbcedc Alexei Starovoitov 2021-07-20 1185 * with two (or more) structurally identical types, which differ only in b0588390dbcedc Alexei Starovoitov 2021-07-20 1186 * types they refer to through pointer. This should be OK in most cases and b0588390dbcedc Alexei Starovoitov 2021-07-20 1187 * is not an error. b0588390dbcedc Alexei Starovoitov 2021-07-20 1188 * 4. Candidate types search is performed by linearly scanning through all b0588390dbcedc Alexei Starovoitov 2021-07-20 1189 * types in target BTF. It is anticipated that this is overall more b0588390dbcedc Alexei Starovoitov 2021-07-20 1190 * efficient memory-wise and not significantly worse (if not better) b0588390dbcedc Alexei Starovoitov 2021-07-20 1191 * CPU-wise compared to prebuilding a map from all local type names to b0588390dbcedc Alexei Starovoitov 2021-07-20 1192 * a list of candidate type names. It's also sped up by caching resolved b0588390dbcedc Alexei Starovoitov 2021-07-20 1193 * list of matching candidates per each local "root" type ID, that has at b0588390dbcedc Alexei Starovoitov 2021-07-20 1194 * least one bpf_core_relo associated with it. This list is shared b0588390dbcedc Alexei Starovoitov 2021-07-20 1195 * between multiple relocations for the same type ID and is updated as some b0588390dbcedc Alexei Starovoitov 2021-07-20 1196 * of the candidates are pruned due to structural incompatibility. b0588390dbcedc Alexei Starovoitov 2021-07-20 1197 */ b0588390dbcedc Alexei Starovoitov 2021-07-20 1198 int bpf_core_apply_relo_insn(const char *prog_name, struct bpf_insn *insn, b0588390dbcedc Alexei Starovoitov 2021-07-20 1199 int insn_idx, b0588390dbcedc Alexei Starovoitov 2021-07-20 1200 const struct bpf_core_relo *relo, b0588390dbcedc Alexei Starovoitov 2021-07-20 1201 int relo_idx, b0588390dbcedc Alexei Starovoitov 2021-07-20 1202 const struct btf *local_btf, b0588390dbcedc Alexei Starovoitov 2021-07-20 1203 struct bpf_core_cand_list *cands) b0588390dbcedc Alexei Starovoitov 2021-07-20 1204 { b0588390dbcedc Alexei Starovoitov 2021-07-20 1205 struct bpf_core_spec local_spec, cand_spec, targ_spec = {}; b0588390dbcedc Alexei Starovoitov 2021-07-20 1206 struct bpf_core_relo_res cand_res, targ_res; b0588390dbcedc Alexei Starovoitov 2021-07-20 1207 const struct btf_type *local_type; b0588390dbcedc Alexei Starovoitov 2021-07-20 1208 const char *local_name; b0588390dbcedc Alexei Starovoitov 2021-07-20 1209 __u32 local_id; b0588390dbcedc Alexei Starovoitov 2021-07-20 1210 const char *spec_str; b0588390dbcedc Alexei Starovoitov 2021-07-20 1211 int i, j, err; b0588390dbcedc Alexei Starovoitov 2021-07-20 1212 b0588390dbcedc Alexei Starovoitov 2021-07-20 1213 local_id = relo->type_id; 9954f5c668fde7 Alexei Starovoitov 2021-09-30 1214 local_type = btf_type_by_id(local_btf, local_id); b0588390dbcedc Alexei Starovoitov 2021-07-20 1215 if (!local_type) b0588390dbcedc Alexei Starovoitov 2021-07-20 1216 return -EINVAL; b0588390dbcedc Alexei Starovoitov 2021-07-20 1217 b0588390dbcedc Alexei Starovoitov 2021-07-20 1218 local_name = btf__name_by_offset(local_btf, local_type->name_off); b0588390dbcedc Alexei Starovoitov 2021-07-20 1219 if (!local_name) b0588390dbcedc Alexei Starovoitov 2021-07-20 1220 return -EINVAL; b0588390dbcedc Alexei Starovoitov 2021-07-20 1221 b0588390dbcedc Alexei Starovoitov 2021-07-20 1222 spec_str = btf__name_by_offset(local_btf, relo->access_str_off); b0588390dbcedc Alexei Starovoitov 2021-07-20 1223 if (str_is_empty(spec_str)) b0588390dbcedc Alexei Starovoitov 2021-07-20 1224 return -EINVAL; b0588390dbcedc Alexei Starovoitov 2021-07-20 1225 b0588390dbcedc Alexei Starovoitov 2021-07-20 1226 err = bpf_core_parse_spec(local_btf, local_id, spec_str, relo->kind, &local_spec); b0588390dbcedc Alexei Starovoitov 2021-07-20 1227 if (err) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1228 pr_warn("prog '%s': relo #%d: parsing [%d] %s %s + %s failed: %d\n", b0588390dbcedc Alexei Starovoitov 2021-07-20 1229 prog_name, relo_idx, local_id, btf_kind_str(local_type), b0588390dbcedc Alexei Starovoitov 2021-07-20 1230 str_is_empty(local_name) ? "<anon>" : local_name, b0588390dbcedc Alexei Starovoitov 2021-07-20 1231 spec_str, err); b0588390dbcedc Alexei Starovoitov 2021-07-20 1232 return -EINVAL; b0588390dbcedc Alexei Starovoitov 2021-07-20 1233 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1234 b0588390dbcedc Alexei Starovoitov 2021-07-20 1235 pr_debug("prog '%s': relo #%d: kind <%s> (%d), spec is ", prog_name, b0588390dbcedc Alexei Starovoitov 2021-07-20 1236 relo_idx, core_relo_kind_str(relo->kind), relo->kind); 03c354f8c71c24 Alexei Starovoitov 2021-09-07 1237 bpf_core_dump_spec(prog_name, LIBBPF_DEBUG, &local_spec); b0588390dbcedc Alexei Starovoitov 2021-07-20 1238 libbpf_print(LIBBPF_DEBUG, "\n"); b0588390dbcedc Alexei Starovoitov 2021-07-20 1239 b0588390dbcedc Alexei Starovoitov 2021-07-20 1240 /* TYPE_ID_LOCAL relo is special and doesn't need candidate search */ b0588390dbcedc Alexei Starovoitov 2021-07-20 1241 if (relo->kind == BPF_TYPE_ID_LOCAL) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1242 targ_res.validate = true; b0588390dbcedc Alexei Starovoitov 2021-07-20 1243 targ_res.poison = false; b0588390dbcedc Alexei Starovoitov 2021-07-20 1244 targ_res.orig_val = local_spec.root_type_id; b0588390dbcedc Alexei Starovoitov 2021-07-20 1245 targ_res.new_val = local_spec.root_type_id; b0588390dbcedc Alexei Starovoitov 2021-07-20 1246 goto patch_insn; b0588390dbcedc Alexei Starovoitov 2021-07-20 1247 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1248 b0588390dbcedc Alexei Starovoitov 2021-07-20 1249 /* libbpf doesn't support candidate search for anonymous types */ b0588390dbcedc Alexei Starovoitov 2021-07-20 1250 if (str_is_empty(spec_str)) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1251 pr_warn("prog '%s': relo #%d: <%s> (%d) relocation doesn't support anonymous types\n", b0588390dbcedc Alexei Starovoitov 2021-07-20 1252 prog_name, relo_idx, core_relo_kind_str(relo->kind), relo->kind); b0588390dbcedc Alexei Starovoitov 2021-07-20 1253 return -EOPNOTSUPP; b0588390dbcedc Alexei Starovoitov 2021-07-20 1254 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1255 b0588390dbcedc Alexei Starovoitov 2021-07-20 1256 b0588390dbcedc Alexei Starovoitov 2021-07-20 1257 for (i = 0, j = 0; i < cands->len; i++) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1258 err = bpf_core_spec_match(&local_spec, cands->cands[i].btf, b0588390dbcedc Alexei Starovoitov 2021-07-20 1259 cands->cands[i].id, &cand_spec); b0588390dbcedc Alexei Starovoitov 2021-07-20 1260 if (err < 0) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1261 pr_warn("prog '%s': relo #%d: error matching candidate #%d ", b0588390dbcedc Alexei Starovoitov 2021-07-20 1262 prog_name, relo_idx, i); 03c354f8c71c24 Alexei Starovoitov 2021-09-07 1263 bpf_core_dump_spec(prog_name, LIBBPF_WARN, &cand_spec); b0588390dbcedc Alexei Starovoitov 2021-07-20 1264 libbpf_print(LIBBPF_WARN, ": %d\n", err); b0588390dbcedc Alexei Starovoitov 2021-07-20 1265 return err; b0588390dbcedc Alexei Starovoitov 2021-07-20 1266 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1267 b0588390dbcedc Alexei Starovoitov 2021-07-20 1268 pr_debug("prog '%s': relo #%d: %s candidate #%d ", prog_name, b0588390dbcedc Alexei Starovoitov 2021-07-20 1269 relo_idx, err == 0 ? "non-matching" : "matching", i); 03c354f8c71c24 Alexei Starovoitov 2021-09-07 1270 bpf_core_dump_spec(prog_name, LIBBPF_DEBUG, &cand_spec); b0588390dbcedc Alexei Starovoitov 2021-07-20 1271 libbpf_print(LIBBPF_DEBUG, "\n"); b0588390dbcedc Alexei Starovoitov 2021-07-20 1272 b0588390dbcedc Alexei Starovoitov 2021-07-20 1273 if (err == 0) b0588390dbcedc Alexei Starovoitov 2021-07-20 1274 continue; b0588390dbcedc Alexei Starovoitov 2021-07-20 1275 b0588390dbcedc Alexei Starovoitov 2021-07-20 1276 err = bpf_core_calc_relo(prog_name, relo, relo_idx, &local_spec, &cand_spec, &cand_res); b0588390dbcedc Alexei Starovoitov 2021-07-20 1277 if (err) b0588390dbcedc Alexei Starovoitov 2021-07-20 1278 return err; b0588390dbcedc Alexei Starovoitov 2021-07-20 1279 b0588390dbcedc Alexei Starovoitov 2021-07-20 1280 if (j == 0) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1281 targ_res = cand_res; b0588390dbcedc Alexei Starovoitov 2021-07-20 1282 targ_spec = cand_spec; b0588390dbcedc Alexei Starovoitov 2021-07-20 1283 } else if (cand_spec.bit_offset != targ_spec.bit_offset) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1284 /* if there are many field relo candidates, they b0588390dbcedc Alexei Starovoitov 2021-07-20 1285 * should all resolve to the same bit offset b0588390dbcedc Alexei Starovoitov 2021-07-20 1286 */ b0588390dbcedc Alexei Starovoitov 2021-07-20 1287 pr_warn("prog '%s': relo #%d: field offset ambiguity: %u != %u\n", b0588390dbcedc Alexei Starovoitov 2021-07-20 1288 prog_name, relo_idx, cand_spec.bit_offset, b0588390dbcedc Alexei Starovoitov 2021-07-20 1289 targ_spec.bit_offset); b0588390dbcedc Alexei Starovoitov 2021-07-20 1290 return -EINVAL; b0588390dbcedc Alexei Starovoitov 2021-07-20 1291 } else if (cand_res.poison != targ_res.poison || cand_res.new_val != targ_res.new_val) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1292 /* all candidates should result in the same relocation b0588390dbcedc Alexei Starovoitov 2021-07-20 1293 * decision and value, otherwise it's dangerous to b0588390dbcedc Alexei Starovoitov 2021-07-20 1294 * proceed due to ambiguity b0588390dbcedc Alexei Starovoitov 2021-07-20 1295 */ b0588390dbcedc Alexei Starovoitov 2021-07-20 1296 pr_warn("prog '%s': relo #%d: relocation decision ambiguity: %s %u != %s %u\n", b0588390dbcedc Alexei Starovoitov 2021-07-20 1297 prog_name, relo_idx, b0588390dbcedc Alexei Starovoitov 2021-07-20 1298 cand_res.poison ? "failure" : "success", cand_res.new_val, b0588390dbcedc Alexei Starovoitov 2021-07-20 1299 targ_res.poison ? "failure" : "success", targ_res.new_val); b0588390dbcedc Alexei Starovoitov 2021-07-20 1300 return -EINVAL; b0588390dbcedc Alexei Starovoitov 2021-07-20 1301 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1302 b0588390dbcedc Alexei Starovoitov 2021-07-20 1303 cands->cands[j++] = cands->cands[i]; b0588390dbcedc Alexei Starovoitov 2021-07-20 1304 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1305 b0588390dbcedc Alexei Starovoitov 2021-07-20 1306 /* b0588390dbcedc Alexei Starovoitov 2021-07-20 1307 * For BPF_FIELD_EXISTS relo or when used BPF program has field b0588390dbcedc Alexei Starovoitov 2021-07-20 1308 * existence checks or kernel version/config checks, it's expected b0588390dbcedc Alexei Starovoitov 2021-07-20 1309 * that we might not find any candidates. In this case, if field b0588390dbcedc Alexei Starovoitov 2021-07-20 1310 * wasn't found in any candidate, the list of candidates shouldn't b0588390dbcedc Alexei Starovoitov 2021-07-20 1311 * change at all, we'll just handle relocating appropriately, b0588390dbcedc Alexei Starovoitov 2021-07-20 1312 * depending on relo's kind. b0588390dbcedc Alexei Starovoitov 2021-07-20 1313 */ b0588390dbcedc Alexei Starovoitov 2021-07-20 1314 if (j > 0) b0588390dbcedc Alexei Starovoitov 2021-07-20 1315 cands->len = j; b0588390dbcedc Alexei Starovoitov 2021-07-20 1316 b0588390dbcedc Alexei Starovoitov 2021-07-20 1317 /* b0588390dbcedc Alexei Starovoitov 2021-07-20 1318 * If no candidates were found, it might be both a programmer error, b0588390dbcedc Alexei Starovoitov 2021-07-20 1319 * as well as expected case, depending whether instruction w/ b0588390dbcedc Alexei Starovoitov 2021-07-20 1320 * relocation is guarded in some way that makes it unreachable (dead b0588390dbcedc Alexei Starovoitov 2021-07-20 1321 * code) if relocation can't be resolved. This is handled in b0588390dbcedc Alexei Starovoitov 2021-07-20 1322 * bpf_core_patch_insn() uniformly by replacing that instruction with b0588390dbcedc Alexei Starovoitov 2021-07-20 1323 * BPF helper call insn (using invalid helper ID). If that instruction b0588390dbcedc Alexei Starovoitov 2021-07-20 1324 * is indeed unreachable, then it will be ignored and eliminated by b0588390dbcedc Alexei Starovoitov 2021-07-20 1325 * verifier. If it was an error, then verifier will complain and point b0588390dbcedc Alexei Starovoitov 2021-07-20 1326 * to a specific instruction number in its log. b0588390dbcedc Alexei Starovoitov 2021-07-20 1327 */ b0588390dbcedc Alexei Starovoitov 2021-07-20 1328 if (j == 0) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1329 pr_debug("prog '%s': relo #%d: no matching targets found\n", b0588390dbcedc Alexei Starovoitov 2021-07-20 1330 prog_name, relo_idx); b0588390dbcedc Alexei Starovoitov 2021-07-20 1331 b0588390dbcedc Alexei Starovoitov 2021-07-20 1332 /* calculate single target relo result explicitly */ b0588390dbcedc Alexei Starovoitov 2021-07-20 1333 err = bpf_core_calc_relo(prog_name, relo, relo_idx, &local_spec, NULL, &targ_res); b0588390dbcedc Alexei Starovoitov 2021-07-20 1334 if (err) b0588390dbcedc Alexei Starovoitov 2021-07-20 1335 return err; b0588390dbcedc Alexei Starovoitov 2021-07-20 1336 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1337 b0588390dbcedc Alexei Starovoitov 2021-07-20 1338 patch_insn: b0588390dbcedc Alexei Starovoitov 2021-07-20 1339 /* bpf_core_patch_insn() should know how to handle missing targ_spec */ b0588390dbcedc Alexei Starovoitov 2021-07-20 1340 err = bpf_core_patch_insn(prog_name, insn, insn_idx, relo, relo_idx, &targ_res); b0588390dbcedc Alexei Starovoitov 2021-07-20 1341 if (err) { b0588390dbcedc Alexei Starovoitov 2021-07-20 1342 pr_warn("prog '%s': relo #%d: failed to patch insn #%u: %d\n", b0588390dbcedc Alexei Starovoitov 2021-07-20 1343 prog_name, relo_idx, relo->insn_off / 8, err); b0588390dbcedc Alexei Starovoitov 2021-07-20 1344 return -EINVAL; b0588390dbcedc Alexei Starovoitov 2021-07-20 1345 } b0588390dbcedc Alexei Starovoitov 2021-07-20 1346 b0588390dbcedc Alexei Starovoitov 2021-07-20 1347 return 0; b0588390dbcedc Alexei Starovoitov 2021-07-20 @1348 }
:::::: The code at line 1348 was first introduced by commit :::::: b0588390dbcedcd74fab6ffb8afe8d52380fd8b6 libbpf: Split CO-RE logic into relo_core.c.
:::::: TO: Alexei Starovoitov <ast@kernel.org> :::::: CC: Andrii Nakryiko <andrii@kernel.org>
--- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org [unhandled content-type:application/gzip] | |