Re: [PATCH v2 8/9] riscv: introduce interfaces to patch kernel code

From: kbuild test robot
Date: Mon Mar 09 2020 - 09:12:55 EST


Hi Zong,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on v5.6-rc5]
[also build test ERROR on next-20200306]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url: https://github.com/0day-ci/linux/commits/Zong-Li/Support-strict-kernel-memory-permissions-for-security/20200309-172554
base: 2c523b344dfa65a3738e7039832044aa133c75fb
config: riscv-nommu_virt_defconfig (attached as .config)
compiler: riscv64-linux-gcc (GCC) 7.5.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=riscv

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@xxxxxxxxx>

All errors (new ones prefixed by >>):

In file included from arch/riscv//kernel/patch.c:6:0:
arch/riscv//kernel/patch.c: In function 'riscv_insn_write':
>> arch/riscv//kernel/patch.c:63:25: error: 'patch_lock' undeclared (first use in this function); did you mean 'patch_map'?
raw_spin_lock_irqsave(&patch_lock, flags);
^
include/linux/spinlock.h:250:34: note: in definition of macro 'raw_spin_lock_irqsave'
flags = _raw_spin_lock_irqsave(lock); \
^~~~
arch/riscv//kernel/patch.c:63:25: note: each undeclared identifier is reported only once for each function it appears in
raw_spin_lock_irqsave(&patch_lock, flags);
^
include/linux/spinlock.h:250:34: note: in definition of macro 'raw_spin_lock_irqsave'
flags = _raw_spin_lock_irqsave(lock); \
^~~~
>> arch/riscv//kernel/patch.c:66:25: error: 'FIX_TEXT_POKE1' undeclared (first use in this function)
patch_map(addr + len, FIX_TEXT_POKE1);
^~~~~~~~~~~~~~
>> arch/riscv//kernel/patch.c:68:26: error: 'FIX_TEXT_POKE0' undeclared (first use in this function); did you mean 'FIX_TEXT_POKE1'?
waddr = patch_map(addr, FIX_TEXT_POKE0);
^~~~~~~~~~~~~~
FIX_TEXT_POKE1

vim +63 arch/riscv//kernel/patch.c

55
56 static int __kprobes riscv_insn_write(void *addr, const void *insn, size_t len)
57 {
58 void *waddr = addr;
59 bool across_pages = (((uintptr_t) addr & ~PAGE_MASK) + len) > PAGE_SIZE;
60 unsigned long flags = 0;
61 int ret;
62
> 63 raw_spin_lock_irqsave(&patch_lock, flags);
64
65 if (across_pages)
> 66 patch_map(addr + len, FIX_TEXT_POKE1);
67
> 68 waddr = patch_map(addr, FIX_TEXT_POKE0);
69
70 ret = probe_kernel_write(waddr, insn, len);
71
72 patch_unmap(FIX_TEXT_POKE0);
73
74 if (across_pages)
75 patch_unmap(FIX_TEXT_POKE1);
76
77 raw_spin_unlock_irqrestore(&patch_lock, flags);
78
79 return ret;
80 }
81

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip