Skip to content

Commit 7c97739

Browse files
jpoimboeIngo Molnar
authored andcommitted
objtool/loongarch: Add unwind hints in prepare_frametrace()
If 'regs' points to a local stack variable, prepare_frametrace() stores all registers to the stack. This confuses objtool as it expects them to be restored from the stack later. The stores don't affect stack tracing, so use unwind hints to hide them from objtool. Fixes the following warnings: arch/loongarch/kernel/traps.o: warning: objtool: show_stack+0xe0: stack state mismatch: reg1[22]=-1+0 reg2[22]=-2-160 arch/loongarch/kernel/traps.o: warning: objtool: show_stack+0xe0: stack state mismatch: reg1[23]=-1+0 reg2[23]=-2-152 Fixes: cb8a2ef ("LoongArch: Add ORC stack unwinder support") Reported-by: kernel test robot <lkp@intel.com> Tested-by: Tiezhu Yang <yangtiezhu@loongson.cn> Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Linus Torvalds <torvalds@linux-foundation.org> Link: https://lore.kernel.org/r/270cadd8040dda74db2307f23497bb68e65db98d.1743481539.git.jpoimboe@kernel.org Closes: https://lore.kernel.org/oe-kbuild-all/202503280703.OARM8SrY-lkp@intel.com/
1 parent 6309a5c commit 7c97739

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

arch/loongarch/include/asm/stacktrace.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <asm/asm.h>
99
#include <asm/ptrace.h>
1010
#include <asm/loongarch.h>
11+
#include <asm/unwind_hints.h>
1112
#include <linux/stringify.h>
1213

1314
enum stack_type {
@@ -43,6 +44,7 @@ int get_stack_info(unsigned long stack, struct task_struct *task, struct stack_i
4344
static __always_inline void prepare_frametrace(struct pt_regs *regs)
4445
{
4546
__asm__ __volatile__(
47+
UNWIND_HINT_SAVE
4648
/* Save $ra */
4749
STORE_ONE_REG(1)
4850
/* Use $ra to save PC */
@@ -80,6 +82,7 @@ static __always_inline void prepare_frametrace(struct pt_regs *regs)
8082
STORE_ONE_REG(29)
8183
STORE_ONE_REG(30)
8284
STORE_ONE_REG(31)
85+
UNWIND_HINT_RESTORE
8386
: "=m" (regs->csr_era)
8487
: "r" (regs->regs)
8588
: "memory");

arch/loongarch/include/asm/unwind_hints.h

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@
2323
UNWIND_HINT sp_reg=ORC_REG_SP type=UNWIND_HINT_TYPE_CALL
2424
.endm
2525

26-
#endif /* __ASSEMBLY__ */
26+
#else /* !__ASSEMBLY__ */
27+
28+
#define UNWIND_HINT_SAVE \
29+
UNWIND_HINT(UNWIND_HINT_TYPE_SAVE, 0, 0, 0)
30+
31+
#define UNWIND_HINT_RESTORE \
32+
UNWIND_HINT(UNWIND_HINT_TYPE_RESTORE, 0, 0, 0)
33+
34+
#endif /* !__ASSEMBLY__ */
2735

2836
#endif /* _ASM_LOONGARCH_UNWIND_HINTS_H */

0 commit comments

Comments
 (0)