[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202207142034.ALIoUjYZ-lkp@intel.com>
Date: Thu, 14 Jul 2022 20:23:57 +0800
From: kernel test robot <lkp@...el.com>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: llvm@...ts.linux.dev, kbuild-all@...ts.01.org,
linux-kernel@...r.kernel.org
Subject: [tglx-devel:depthtracking 23/38] arch/x86/kernel/callthunks.c:368:7:
warning: variable 'ret' is used uninitialized whenever 'if' condition is
true
tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git depthtracking
head: 81d2c1b17a61bfeca4b92a5d6e1fb6f5ff464826
commit: 02b09aaafc9a439ca50cc049e98f7cc945e5b294 [23/38] x86/callthunks: Add call patching for call depth tracking
config: x86_64-randconfig-a014 (https://download.01.org/0day-ci/archive/20220714/202207142034.ALIoUjYZ-lkp@intel.com/config)
compiler: clang version 15.0.0 (https://github.com/llvm/llvm-project 5e61b9c556267086ef9b743a0b57df302eef831b)
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/tglx/devel.git/commit/?id=02b09aaafc9a439ca50cc049e98f7cc945e5b294
git remote add tglx-devel https://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git
git fetch --no-tags tglx-devel depthtracking
git checkout 02b09aaafc9a439ca50cc049e98f7cc945e5b294
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash arch/x86/kernel/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@...el.com>
All warnings (new ones prefixed by >>):
>> arch/x86/kernel/callthunks.c:368:7: warning: variable 'ret' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
if (!vbuf)
^~~~~
arch/x86/kernel/callthunks.c:428:9: note: uninitialized use occurs here
return ret;
^~~
arch/x86/kernel/callthunks.c:368:3: note: remove the 'if' if its condition is always false
if (!vbuf)
^~~~~~~~~~
arch/x86/kernel/callthunks.c:332:9: note: initialize the variable 'ret' to silence this warning
int ret, text_size, size;
^
= 0
1 warning generated.
vim +368 arch/x86/kernel/callthunks.c
324
325 static __init_or_module int callthunks_setup(struct callthunk_sites *cs,
326 struct module_layout *layout)
327 {
328 u8 *tp, *thunk, *buffer, *vbuf = NULL;
329 struct paravirt_patch_site *pv;
330 unsigned int nthunks, bitpos;
331 struct thunk_mem_area *area;
332 int ret, text_size, size;
333 s32 *s;
334
335 lockdep_assert_held(&text_mutex);
336
337 prdbg("Setup %s\n", layout_getname(layout));
338 /* Calculate the number of thunks required */
339 nthunks = cs->syms_end - cs->syms_start;
340 nthunks += cs->pv_end - cs->pv_start;
341
342 /*
343 * thunk_size can be 0 when there are no intra module calls,
344 * but there might be still sites to patch.
345 */
346 if (!nthunks)
347 goto patch;
348
349 area = callthunks_alloc(nthunks);
350 if (!area)
351 return -ENOMEM;
352
353 bitpos = area->start;
354 thunk = area->tmem->base + bitpos * callthunk_desc.thunk_size;
355 tp = thunk;
356
357 prdbg("Thunk %px\n", tp);
358 /*
359 * If the memory area is already RX, use a temporary
360 * buffer. Otherwise just copy into the unused area
361 */
362 if (!area->tmem->is_rx) {
363 prdbg("Using thunk direct\n");
364 buffer = thunk;
365 } else {
366 size = nthunks * callthunk_desc.thunk_size;
367 vbuf = vmalloc(size);
> 368 if (!vbuf)
369 goto fail;
370 memset(vbuf, INT3_INSN_OPCODE, size);
371 buffer = vbuf;
372 prdbg("Using thunk vbuf %px\n", vbuf);
373 }
374
375 for (s = cs->syms_start; s < cs->syms_end; s++, bitpos++) {
376 void *dest = (void *)s + *s;
377
378 ret = callthunk_setup_one(dest, tp, buffer, layout);
379 if (ret)
380 goto fail;
381 buffer += callthunk_desc.thunk_size;
382 tp += callthunk_desc.thunk_size;
383 bitmap_set(area->tmem->map, bitpos, 1);
384 area->nthunks++;
385 }
386
387 for (pv = cs->pv_start; pv < cs->pv_end; pv++, bitpos++) {
388 ret = callthunk_setup_one(pv->instr, tp, buffer, layout);
389 if (ret)
390 goto fail;
391 buffer += callthunk_desc.thunk_size;
392 tp += callthunk_desc.thunk_size;
393 bitmap_set(area->tmem->map, bitpos, 1);
394 area->nthunks++;
395 }
396
397 text_size = tp - thunk;
398 prdbg("Thunk %px .. %px 0x%x\n", thunk, tp, text_size);
399
400 /*
401 * If thunk memory is already RX, poke the buffer into it.
402 * Otherwise make the memory RX.
403 */
404 if (vbuf)
405 text_poke_copy_locked(thunk, vbuf, text_size);
406 else
407 callthunk_area_set_rx(area);
408 sync_core();
409
410 layout->base = thunk;
411 layout->size = text_size;
412 layout->text_size = text_size;
413 layout->arch_data = area;
414
415 vfree(vbuf);
416
417 patch:
418 prdbg("Patching call sites %s\n", layout_getname(layout));
419 patch_call_sites(cs->call_start, cs->call_end, layout);
420 patch_paravirt_call_sites(cs->pv_start, cs->pv_end, layout);
421 prdbg("Patching call sites done%s\n", layout_getname(layout));
422 return 0;
423
424 fail:
425 WARN_ON_ONCE(ret);
426 callthunk_free(area, false);
427 vfree(vbuf);
428 return ret;
429 }
430
--
0-DAY CI Kernel Test Service
https://01.org/lkp
Powered by blists - more mailing lists