Hi, Tiezhu,
Maybe "LoongArch: Add ORC stack unwinder support" is better.
On Mon, Oct 9, 2023 at 9:03 PM Tiezhu Yang <yangtiezhu@xxxxxxxxxxx> wrote:
The kernel CONFIG_UNWINDER_ORC option enables the ORC unwinder, which is
similar in concept to a DWARF unwinder. The difference is that the format
of the ORC data is much simpler than DWARF, which in turn allows the ORC
unwinder to be much simpler and faster.
+ifdef CONFIG_OBJTOOLI prefer no error out here, because without this option we can still
+# https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=ecb802d02eeb
+# https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=816029e06768
+ifeq ($(shell as --help 2>&1 | grep -e '-mthin-add-sub'),)
+ $(error Sorry, you need a newer gas version with -mthin-add-sub option)
built a runnable kernel.
+endif
+KBUILD_AFLAGS += $(call cc-option,-mthin-add-sub) $(call cc-option,-Wa$(comma)-mthin-add-sub)
+KBUILD_CFLAGS += $(call cc-option,-mthin-add-sub) $(call cc-option,-Wa$(comma)-mthin-add-sub)
+KBUILD_CFLAGS += -fno-optimize-sibling-calls -fno-jump-tables -falign-functions=4
+endif
+#define ORC_REG_BP 3Use FP instead of BP in this patch, too.
+#define ORC_REG_MAX 4
+.macro UNWIND_HINT_UNDEFINED
+ UNWIND_HINT type=UNWIND_HINT_TYPE_UNDEFINEDWe don't need to set sp_reg=ORC_REG_UNDEFINED for UNWIND_HINT_UNDEFINED?
+.endm
+We don't need to define UNWIND_HINT_END_OF_STACK?
+.macro UNWIND_HINT_EMPTY
+ UNWIND_HINT sp_reg=ORC_REG_UNDEFINED type=UNWIND_HINT_TYPE_CALL
+.endm
+We don't need to set sp_offset for UNWIND_HINT_REGS and UNWIND_HINT_FUNC?
+.macro UNWIND_HINT_REGS
+ UNWIND_HINT sp_reg=ORC_REG_SP type=UNWIND_HINT_TYPE_REGS
+.endm
+
+.macro UNWIND_HINT_FUNC
+ UNWIND_HINT sp_reg=ORC_REG_SP type=UNWIND_HINT_TYPE_CALL
+.endm
+
+#endif /* __ASSEMBLY__ */
diff --git a/arch/loongarch/kernel/entry.S b/arch/loongarch/kernel/entry.SWhy?
index 65518bb..e43115f 100644
--- a/arch/loongarch/kernel/entry.S
+++ b/arch/loongarch/kernel/entry.S
@@ -14,11 +14,13 @@
#include <asm/regdef.h>
#include <asm/stackframe.h>
#include <asm/thread_info.h>
+#include <asm/unwind_hints.h>
.text
.cfi_sections .debug_frame
.align 5
-SYM_FUNC_START(handle_syscall)
+SYM_CODE_START(handle_syscall)
+ UNWIND_HINT_UNDEFINED
csrrd t0, PERCPU_BASE_KS
diff --git a/arch/loongarch/kernel/head.S b/arch/loongarch/kernel/head.SI'm not sure but I think this isn't needed, because
index 53b883d..5664390 100644
--- a/arch/loongarch/kernel/head.S
+++ b/arch/loongarch/kernel/head.S
@@ -43,6 +43,7 @@ SYM_DATA(kernel_offset, .long _kernel_offset);
.align 12
SYM_CODE_START(kernel_entry) # kernel entry point
+ UNWIND_HINT_EMPTY
"OBJECT_FILES_NON_STANDARD_head.o :=y"
/* Config direct window and set PG */
void __init setup_arch(char **cmdline_p)I think this line should be after cpu_probe().
{
+ unwind_init();
cpu_probe();
init_environ();
diff --git a/arch/loongarch/power/Makefile b/arch/loongarch/power/Makefilehibernate_asm.o has no problem?
index 58151d0..bbd1d47 100644
--- a/arch/loongarch/power/Makefile
+++ b/arch/loongarch/power/Makefile
@@ -1,3 +1,5 @@
+OBJECT_FILES_NON_STANDARD_suspend_asm.o := y