Re: [PATCH 08/10] ARM: kprobes: Make a frame pointer on __kretprobe_trampoline

From: kernel test robot
Date: Sat Oct 16 2021 - 06:39:00 EST


Hi Masami,

I love your patch! Yet something to improve:

[auto build test ERROR on rostedt-trace/for-next]
[also build test ERROR on next-20211015]
[cannot apply to arm64/for-next/core tip/x86/core linus/master v5.15-rc5]
[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]

url: https://github.com/0day-ci/linux/commits/Masami-Hiramatsu/kprobes-Make-KUnit-and-add-stacktrace-on-kretprobe-tests/20211015-205329
base: https://git.kernel.org/pub/scm/linux/kernel/git/rostedt/linux-trace.git for-next
config: arm-randconfig-r016-20211015 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 6069a6a5049497a32a50a49661c2f4169078bdba)
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
# install arm cross compiling tool for clang build
# apt-get install binutils-arm-linux-gnueabi
# https://github.com/0day-ci/linux/commit/4039c4f80aba40806049567ad4f916bc4b9c1576
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Masami-Hiramatsu/kprobes-Make-KUnit-and-add-stacktrace-on-kretprobe-tests/20211015-205329
git checkout 4039c4f80aba40806049567ad4f916bc4b9c1576
# save the attached .config to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=arm SHELL=/bin/bash

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

All errors (new ones prefixed by >>):

arch/arm/probes/kprobes/core.c:236:16: warning: no previous prototype for function 'kprobe_handler' [-Wmissing-prototypes]
void __kprobes kprobe_handler(struct pt_regs *regs)
^
arch/arm/probes/kprobes/core.c:236:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
void __kprobes kprobe_handler(struct pt_regs *regs)
^
static
>> arch/arm/probes/kprobes/core.c:379:38: error: writeback register not allowed in register list
"ldr lr, =__kretprobe_trampoline \n\t"
^
<inline asm>:2:13: note: instantiated into assembly here
stmdb sp!, {sp, lr, pc}
^
1 warning and 1 error generated.


vim +379 arch/arm/probes/kprobes/core.c

367
368 /*
369 * When a retprobed function returns, trampoline_handler() is called,
370 * calling the kretprobe's handler. We construct a struct pt_regs to
371 * give a view of registers r0-r11, sp, lr, and pc to the user
372 * return-handler. This is not a complete pt_regs structure, but that
373 * should be enough for stacktrace from the return handler with or
374 * without pt_regs.
375 */
376 void __naked __kprobes __kretprobe_trampoline(void)
377 {
378 __asm__ __volatile__ (
> 379 "ldr lr, =__kretprobe_trampoline \n\t"
380 "stmdb sp!, {sp, lr, pc} \n\t"
381 #ifdef CONFIG_FRAME_POINTER
382 /* __kretprobe_trampoline makes a framepointer on pt_regs. */
383 #ifdef CONFIG_CC_IS_CLANG
384 /* In clang case, pt_regs->ip = lr. */
385 "stmdb sp!, {lr} \n\t"
386 "stmdb sp!, {r0 - r11} \n\t"
387 /* fp points regs->r11 (fp) */
388 "add fp, sp, #44 \n\t"
389 #else /* !CONFIG_CC_IS_CLANG */
390 /* In gcc case, pt_regs->ip = fp. */
391 "stmdb sp!, {fp} \n\t"
392 "stmdb sp!, {r0 - r11} \n\t"
393 /* fp points regs->r15 (pc) */
394 "add fp, sp, #60 \n\t"
395 #endif /* CONFIG_CC_IS_CLANG */
396 #else /* !CONFIG_FRAME_POINTER */
397 "sub sp, sp, #4 \n\t"
398 "stmdb sp!, {r0 - r11} \n\t"
399 #endif /* CONFIG_FRAME_POINTER */
400 "mov r0, sp \n\t"
401 "bl trampoline_handler \n\t"
402 "mov lr, r0 \n\t"
403 "ldmia sp!, {r0 - r11} \n\t"
404 "add sp, sp, #16 \n\t"
405 #ifdef CONFIG_THUMB2_KERNEL
406 "bx lr \n\t"
407 #else
408 "mov pc, lr \n\t"
409 #endif
410 : : : "memory");
411 }
412

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

Attachment: .config.gz
Description: application/gzip