Re: [PATCH] riscv: fgraph: Fix stack layout to match __arch_ftrace_regs argument of ftrace_return_to_handler

From: Pu Lehui
Date: Sun Mar 16 2025 - 23:06:41 EST



On 2025/3/16 9:16, kernel test robot wrote:
Hi Pu,

kernel test robot noticed the following build errors:

[auto build test ERROR on linus/master]
[also build test ERROR on v6.14-rc6 next-20250314]
[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/Pu-Lehui/riscv-fgraph-Fix-stack-layout-to-match-__arch_ftrace_regs-argument-of-ftrace_return_to_handler/20250311-212440
base: linus/master
patch link: https://lore.kernel.org/r/20250311132243.2178271-1-pulehui%40huaweicloud.com
patch subject: [PATCH] riscv: fgraph: Fix stack layout to match __arch_ftrace_regs argument of ftrace_return_to_handler
config: riscv-randconfig-001-20250316 (https://download.01.org/0day-ci/archive/20250316/202503160820.dvqMpH0g-lkp@xxxxxxxxx/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 87916f8c32ebd8e284091db9b70339df57fd1e90)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250316/202503160820.dvqMpH0g-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202503160820.dvqMpH0g-lkp@xxxxxxxxx/

All errors (new ones prefixed by >>):

<instantiation>:1:14: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
addi sp, sp, -FREGS_SIZE_ON_STACK
^
arch/riscv/kernel/mcount.S:73:2: note: while in macro instantiation
SAVE_RET_ABI_STATE
^
<instantiation>:2:17: error: unexpected token
sw ra, FREGS_RA(sp)
^
arch/riscv/kernel/mcount.S:73:2: note: while in macro instantiation
SAVE_RET_ABI_STATE
^
<instantiation>:3:17: error: unexpected token
sw s0, FREGS_S0(sp)
^
arch/riscv/kernel/mcount.S:73:2: note: while in macro instantiation
SAVE_RET_ABI_STATE
^
<instantiation>:4:17: error: unexpected token
sw a0, FREGS_A0(sp)
^
arch/riscv/kernel/mcount.S:73:2: note: while in macro instantiation
SAVE_RET_ABI_STATE
^
<instantiation>:5:17: error: unexpected token
sw a1, FREGS_A1(sp)
^
arch/riscv/kernel/mcount.S:73:2: note: while in macro instantiation
SAVE_RET_ABI_STATE
^
<instantiation>:6:15: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
addi s0, sp, FREGS_SIZE_ON_STACK
^
arch/riscv/kernel/mcount.S:73:2: note: while in macro instantiation
SAVE_RET_ABI_STATE
^
<instantiation>:1:16: error: unexpected token
lw ra, FREGS_RA(sp)
^
arch/riscv/kernel/mcount.S:77:2: note: while in macro instantiation
RESTORE_RET_ABI_STATE
^
<instantiation>:2:17: error: unexpected token
lw s0, FREGS_S0(sp)
^
arch/riscv/kernel/mcount.S:77:2: note: while in macro instantiation
RESTORE_RET_ABI_STATE
^
<instantiation>:3:17: error: unexpected token
lw a0, FREGS_A0(sp)
^
arch/riscv/kernel/mcount.S:77:2: note: while in macro instantiation
RESTORE_RET_ABI_STATE
^
<instantiation>:4:17: error: unexpected token
lw a1, FREGS_A1(sp)
^
arch/riscv/kernel/mcount.S:77:2: note: while in macro instantiation
RESTORE_RET_ABI_STATE
^
<instantiation>:5:15: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
addi sp, sp, FREGS_SIZE_ON_STACK
^
arch/riscv/kernel/mcount.S:77:2: note: while in macro instantiation
RESTORE_RET_ABI_STATE
^


Nice catch. The reason is that HAVE_DYNAMIC_FTRACE can be diabled when CONFIG_MMU=n, and lead to disable HAVE_DYNAMIC_FTRACE_WITH_ARGS. However, the current fgraph on riscv relies on the infrastructure of DYNAMIC_FTRACE_WITH_ARGS. So let's select HAVE_FUNCTION_GRAPH_TRACER depends on HAVE_DYNAMIC_FTRACE_WITH_ARGS. I will send new soon.