[ammarfaizi2-block:tglx/devel/depthtracking 45/45] arch/x86/kernel/callthunks.c:416:5: warning: no previous prototype for 'setup_padding_thunks'

From: kernel test robot
Date: Thu Jul 21 2022 - 05:20:51 EST


tree: https://github.com/ammarfaizi2/linux-block tglx/devel/depthtracking
head: 714d29e3e7e3faac27142424ae2533163ddd3a46
commit: 714d29e3e7e3faac27142424ae2533163ddd3a46 [45/45] x06/callthunks: Put thunks into compiler provided padding area
config: x86_64-randconfig-a002 (https://download.01.org/0day-ci/archive/20220721/202207211741.FD7bX7pW-lkp@xxxxxxxxx/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/ammarfaizi2/linux-block/commit/714d29e3e7e3faac27142424ae2533163ddd3a46
git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block
git fetch --no-tags ammarfaizi2-block tglx/devel/depthtracking
git checkout 714d29e3e7e3faac27142424ae2533163ddd3a46
# save the config file
mkdir build_dir && cp config build_dir/.config
make 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@xxxxxxxxx>

All warnings (new ones prefixed by >>):

>> arch/x86/kernel/callthunks.c:416:5: warning: no previous prototype for 'setup_padding_thunks' [-Wmissing-prototypes]
416 | int setup_padding_thunks(s32 *start, s32 *end, struct thunk_mem_area *area,
| ^~~~~~~~~~~~~~~~~~~~


vim +/setup_padding_thunks +416 arch/x86/kernel/callthunks.c

415
> 416 int setup_padding_thunks(s32 *start, s32 *end, struct thunk_mem_area *area,
417 struct module_layout *layout)
418 {
419 int gap, nthunks = 0, idx = 0, padsize;
420 s32 *s;
421
422 padsize = 1 << CONFIG_FUNCTION_PADDING_ORDER;
423 if (callthunk_desc.template_size > padsize)
424 return 0;
425
426 gap = padsize - callthunk_desc.template_size;
427
428 for (s = start; s < end; s++) {
429 void *thunk, *tp, *dest = (void *)s + *s;
430 unsigned long key = (unsigned long)dest;
431 int fail, i;
432 u8 opcode;
433
434 if (is_inittext(layout, dest)) {
435 prdbg("Ignoring init dest: %pS %px\n", dest, dest);
436 continue;
437 }
438
439 /* Multiple symbols can have the same location. */
440 if (btree_lookup64(&call_thunks, key)) {
441 prdbg("Ignoring duplicate dest: %pS %px\n", dest, dest);
442 continue;
443 }
444
445 thunk = tp = dest - 16;
446 prdbg("Probing dest: %pS %px at %px\n", dest, dest, tp);
447 pagefault_disable();
448 fail = 0;
449 for (i = 0; !fail && i < 16; i++) {
450 if (get_kernel_nofault(opcode, tp + i)) {
451 fail = 1;
452 } else if (opcode != 0xcc) {
453 fail = 2;
454 }
455 }
456 pagefault_enable();
457 switch (fail) {
458 case 1:
459 prdbg("Faulted for dest: %pS %px\n", dest, dest);
460 nthunks++;
461 continue;
462 case 2:
463 prdbg("No padding for dest: %pS %px\n", dest, dest);
464 nthunks++;
465 continue;
466 }
467
468 prdbg("Thunk for dest: %pS %px at %px\n", dest, dest, tp);
469 memcpy(tp, callthunk_desc.template, callthunk_desc.template_size);
470 tp += callthunk_desc.template_size;
471
472 switch (gap) {
473 case 0: break;
474 case 1:
475 case 2:
476 case 3:
477 case 4:
478 case 5:
479 case 6:
480 case 7:
481 case 8:
482 memcpy(tp, x86_nops[gap], gap);
483 break;
484 default:
485 __text_gen_insn(tp, JMP32_INSN_OPCODE, tp, dest,
486 JMP32_INSN_SIZE);
487 tp += JMP32_INSN_SIZE;
488 *(u8*)tp = 0xcc;
489 break;
490 }
491
492 if (area->dests) {
493 prdbg("Insert %px at index %d\n", dest, idx);
494 area->dests[idx++] = key;
495 }
496
497 fail = btree_insert64(&call_thunks, key, (void *)thunk, GFP_KERNEL);
498 if (fail)
499 return fail;
500
501 area->nthunks++;
502 }
503 return 0;
504 }
505

--
0-DAY CI Kernel Test Service
https://01.org/lkp