Re: [PATCH v7 4/5] LoongArch: Support PC-relative relocations in modules

From: kernel test robot
Date: Tue Aug 30 2022 - 09:00:34 EST


Hi Xi,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on kees/for-next/execve]
[also build test WARNING on linus/master v6.0-rc3 next-20220830]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Xi-Ruoyao/LoongArch-Support-toolchain-with-new-relocation-types/20220830-185350
base: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/execve
config: loongarch-allyesconfig (https://download.01.org/0day-ci/archive/20220830/202208302041.ANqQ0hQd-lkp@xxxxxxxxx/config)
compiler: loongarch64-linux-gcc (GCC) 12.1.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://github.com/intel-lab-lkp/linux/commit/529c0f36d2dad7dd4bcec3815f821547d9e9643c
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Xi-Ruoyao/LoongArch-Support-toolchain-with-new-relocation-types/20220830-185350
git checkout 529c0f36d2dad7dd4bcec3815f821547d9e9643c
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=loongarch SHELL=/bin/bash arch/loongarch/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 >>):

366 | [R_LARCH_NONE] = apply_r_larch_none,
| ^~~~~~~~~~~~~~~~~~
arch/loongarch/kernel/module.c:366:64: note: (near initialization for 'reloc_rela_handlers[0]')
arch/loongarch/kernel/module.c:367:64: warning: initialized field overwritten [-Woverride-init]
367 | [R_LARCH_32] = apply_r_larch_32,
| ^~~~~~~~~~~~~~~~
arch/loongarch/kernel/module.c:367:64: note: (near initialization for 'reloc_rela_handlers[1]')
arch/loongarch/kernel/module.c:368:64: warning: initialized field overwritten [-Woverride-init]
368 | [R_LARCH_64] = apply_r_larch_64,
| ^~~~~~~~~~~~~~~~
arch/loongarch/kernel/module.c:368:64: note: (near initialization for 'reloc_rela_handlers[2]')
arch/loongarch/kernel/module.c:369:64: warning: initialized field overwritten [-Woverride-init]
369 | [R_LARCH_MARK_LA] = apply_r_larch_none,
| ^~~~~~~~~~~~~~~~~~
arch/loongarch/kernel/module.c:369:64: note: (near initialization for 'reloc_rela_handlers[20]')
arch/loongarch/kernel/module.c:370:64: warning: initialized field overwritten [-Woverride-init]
370 | [R_LARCH_MARK_PCREL] = apply_r_larch_none,
| ^~~~~~~~~~~~~~~~~~
arch/loongarch/kernel/module.c:370:64: note: (near initialization for 'reloc_rela_handlers[21]')
arch/loongarch/kernel/module.c:371:64: warning: initialized field overwritten [-Woverride-init]
371 | [R_LARCH_SOP_PUSH_PCREL] = apply_r_larch_sop_push_pcrel,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/loongarch/kernel/module.c:371:64: note: (near initialization for 'reloc_rela_handlers[22]')
arch/loongarch/kernel/module.c:372:64: warning: initialized field overwritten [-Woverride-init]
372 | [R_LARCH_SOP_PUSH_ABSOLUTE] = apply_r_larch_sop_push_absolute,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/loongarch/kernel/module.c:372:64: note: (near initialization for 'reloc_rela_handlers[23]')
arch/loongarch/kernel/module.c:373:64: warning: initialized field overwritten [-Woverride-init]
373 | [R_LARCH_SOP_PUSH_DUP] = apply_r_larch_sop_push_dup,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~
arch/loongarch/kernel/module.c:373:64: note: (near initialization for 'reloc_rela_handlers[24]')
arch/loongarch/kernel/module.c:374:64: warning: initialized field overwritten [-Woverride-init]
374 | [R_LARCH_SOP_PUSH_PLT_PCREL] = apply_r_larch_sop_push_plt_pcrel,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/loongarch/kernel/module.c:374:64: note: (near initialization for 'reloc_rela_handlers[29]')
arch/loongarch/kernel/module.c:375:64: warning: initialized field overwritten [-Woverride-init]
375 | [R_LARCH_SOP_SUB ... R_LARCH_SOP_IF_ELSE] = apply_r_larch_sop,
| ^~~~~~~~~~~~~~~~~
arch/loongarch/kernel/module.c:375:64: note: (near initialization for 'reloc_rela_handlers[32]')
arch/loongarch/kernel/module.c:375:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:375:64: note: (near initialization for 'reloc_rela_handlers[33]')
arch/loongarch/kernel/module.c:375:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:375:64: note: (near initialization for 'reloc_rela_handlers[34]')
arch/loongarch/kernel/module.c:375:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:375:64: note: (near initialization for 'reloc_rela_handlers[35]')
arch/loongarch/kernel/module.c:375:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:375:64: note: (near initialization for 'reloc_rela_handlers[36]')
arch/loongarch/kernel/module.c:375:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:375:64: note: (near initialization for 'reloc_rela_handlers[37]')
arch/loongarch/kernel/module.c:376:64: warning: initialized field overwritten [-Woverride-init]
376 | [R_LARCH_SOP_POP_32_S_10_5 ... R_LARCH_SOP_POP_32_U] = apply_r_larch_sop_imm_field,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
arch/loongarch/kernel/module.c:376:64: note: (near initialization for 'reloc_rela_handlers[38]')
arch/loongarch/kernel/module.c:376:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:376:64: note: (near initialization for 'reloc_rela_handlers[39]')
arch/loongarch/kernel/module.c:376:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:376:64: note: (near initialization for 'reloc_rela_handlers[40]')
arch/loongarch/kernel/module.c:376:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:376:64: note: (near initialization for 'reloc_rela_handlers[41]')
arch/loongarch/kernel/module.c:376:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:376:64: note: (near initialization for 'reloc_rela_handlers[42]')
arch/loongarch/kernel/module.c:376:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:376:64: note: (near initialization for 'reloc_rela_handlers[43]')
arch/loongarch/kernel/module.c:376:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:376:64: note: (near initialization for 'reloc_rela_handlers[44]')
arch/loongarch/kernel/module.c:376:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:376:64: note: (near initialization for 'reloc_rela_handlers[45]')
arch/loongarch/kernel/module.c:376:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:376:64: note: (near initialization for 'reloc_rela_handlers[46]')
arch/loongarch/kernel/module.c:377:64: warning: initialized field overwritten [-Woverride-init]
377 | [R_LARCH_ADD32 ... R_LARCH_SUB64] = apply_r_larch_add_sub,
| ^~~~~~~~~~~~~~~~~~~~~
arch/loongarch/kernel/module.c:377:64: note: (near initialization for 'reloc_rela_handlers[50]')
arch/loongarch/kernel/module.c:377:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:377:64: note: (near initialization for 'reloc_rela_handlers[51]')
arch/loongarch/kernel/module.c:377:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:377:64: note: (near initialization for 'reloc_rela_handlers[52]')
arch/loongarch/kernel/module.c:377:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:377:64: note: (near initialization for 'reloc_rela_handlers[53]')
arch/loongarch/kernel/module.c:377:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:377:64: note: (near initialization for 'reloc_rela_handlers[54]')
arch/loongarch/kernel/module.c:377:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:377:64: note: (near initialization for 'reloc_rela_handlers[55]')
arch/loongarch/kernel/module.c:377:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:377:64: note: (near initialization for 'reloc_rela_handlers[56]')
arch/loongarch/kernel/module.c:378:64: warning: initialized field overwritten [-Woverride-init]
378 | [R_LARCH_B26] = apply_r_larch_b26,
| ^~~~~~~~~~~~~~~~~
arch/loongarch/kernel/module.c:378:64: note: (near initialization for 'reloc_rela_handlers[66]')
arch/loongarch/kernel/module.c:379:64: warning: initialized field overwritten [-Woverride-init]
379 | [R_LARCH_PCALA_HI20...R_LARCH_PCALA64_HI12] = apply_r_larch_pcala,
| ^~~~~~~~~~~~~~~~~~~
arch/loongarch/kernel/module.c:379:64: note: (near initialization for 'reloc_rela_handlers[71]')
arch/loongarch/kernel/module.c:379:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:379:64: note: (near initialization for 'reloc_rela_handlers[72]')
arch/loongarch/kernel/module.c:379:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:379:64: note: (near initialization for 'reloc_rela_handlers[73]')
arch/loongarch/kernel/module.c:379:64: warning: initialized field overwritten [-Woverride-init]
arch/loongarch/kernel/module.c:379:64: note: (near initialization for 'reloc_rela_handlers[74]')
arch/loongarch/kernel/module.c: In function 'apply_r_larch_pcala':
>> arch/loongarch/kernel/module.c:336:19: warning: this statement may fall through [-Wimplicit-fallthrough=]
336 | v = offset_rem >> 52;
| ~~^~~~~~~~~~~~~~~~~~
arch/loongarch/kernel/module.c:338:9: note: here
338 | case R_LARCH_PCALA_LO12:
| ^~~~


vim +336 arch/loongarch/kernel/module.c

315
316 static int apply_r_larch_pcala(struct module *mod, u32 *location, Elf_Addr v,
317 s64 *rela_stack, size_t *rela_stack_top, unsigned int type)
318 {
319 union loongarch_instruction *insn = (union loongarch_instruction *)location;
320 /* Use s32 for a sign-extension deliberately. */
321 s32 offset_hi20 = (void *)((v + 0x800) & ~0xfff) -
322 (void *)((Elf_Addr)location & ~0xfff);
323 Elf_Addr anchor = (((Elf_Addr)location) & ~0xfff) + offset_hi20;
324 ptrdiff_t offset_rem = (void *)v - (void *)anchor;
325
326 switch (type) {
327 case R_LARCH_PCALA_HI20:
328 v = offset_hi20 >> 12;
329 insn->reg1i20_format.immediate = v & 0xfffff;
330 break;
331 case R_LARCH_PCALA64_LO20:
332 v = offset_rem >> 32;
333 insn->reg1i20_format.immediate = v & 0xfffff;
334 break;
335 case R_LARCH_PCALA64_HI12:
> 336 v = offset_rem >> 52;
337 /* fall through */
338 case R_LARCH_PCALA_LO12:
339 insn->reg2i12_format.immediate = v & 0xfff;
340 break;
341 default:
342 pr_err("%s: Unsupport relocation type %u\n", mod->name, type);
343 return -EINVAL;
344 }
345
346 return 0;
347 }
348

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