2023-07-25 08:46:31

by Tiezhu Yang

[permalink] [raw]
Subject: [PATCH v1 0/6] Add objtool and orc support for LoongArch

Due to work adjustment, it is my pleasure and duty to go on with this work
from now on. As discussed with Youling offline to reach an agreement, I'll
make this patch series as simple and clear as possible, maybe this is going
to progress in the right direction.

This version is based on 6.5-rc1, the patches apply cleanly to the latest
objtool/core branch of tip/tip.git tree too, most of the changes are under
tools/objtool/arch/loongarch and arch/loongarch.

To be honest, there still exist some objtool warnings, I will try my best
to fix them in the later versions or the other separate patches.

Tiezhu Yang (6):
objtool/LoongArch: Enable objtool to be built
objtool/LoongArch: Implement instruction decoder
objtool/x86: Separate arch-specific and generic parts
objtool/LoongArch: Enable orc to be built
objtool: Add skipped member in struct reloc
LoongArch: Add ORC unwinder support

arch/loongarch/Kconfig | 2 +
arch/loongarch/Kconfig.debug | 11 +
arch/loongarch/Makefile | 16 +
arch/loongarch/include/asm/Kbuild | 1 +
arch/loongarch/include/asm/bug.h | 1 +
arch/loongarch/include/asm/module.h | 7 +
arch/loongarch/include/asm/orc_header.h | 19 +
arch/loongarch/include/asm/orc_lookup.h | 34 ++
arch/loongarch/include/asm/orc_types.h | 58 ++
arch/loongarch/include/asm/stackframe.h | 3 +
arch/loongarch/include/asm/unwind.h | 22 +-
arch/loongarch/include/asm/unwind_hints.h | 23 +
arch/loongarch/kernel/Makefile | 3 +
arch/loongarch/kernel/entry.S | 2 +
arch/loongarch/kernel/genex.S | 2 +
arch/loongarch/kernel/head.S | 1 +
arch/loongarch/kernel/module.c | 21 +-
arch/loongarch/kernel/relocate_kernel.S | 11 +-
arch/loongarch/kernel/setup.c | 2 +
arch/loongarch/kernel/stacktrace.c | 1 +
arch/loongarch/kernel/unwind_orc.c | 586 +++++++++++++++++++++
arch/loongarch/kernel/vmlinux.lds.S | 3 +
arch/loongarch/power/Makefile | 2 +
arch/loongarch/vdso/Makefile | 2 +
include/linux/compiler.h | 9 +
scripts/Makefile | 5 +-
tools/arch/loongarch/include/asm/inst.h | 159 ++++++
tools/arch/loongarch/include/asm/orc_types.h | 58 ++
tools/include/linux/bitops.h | 11 +
tools/objtool/Makefile | 4 +
tools/objtool/arch/loongarch/Build | 3 +
tools/objtool/arch/loongarch/decode.c | 406 ++++++++++++++
.../objtool/arch/loongarch/include/arch/cfi_regs.h | 21 +
tools/objtool/arch/loongarch/include/arch/elf.h | 30 ++
.../objtool/arch/loongarch/include/arch/special.h | 33 ++
tools/objtool/arch/loongarch/orc.c | 158 ++++++
tools/objtool/arch/loongarch/special.c | 15 +
tools/objtool/arch/x86/Build | 1 +
tools/objtool/arch/x86/orc.c | 169 ++++++
tools/objtool/check.c | 16 +-
tools/objtool/elf.c | 6 +
tools/objtool/include/objtool/check.h | 9 +
tools/objtool/include/objtool/elf.h | 1 +
tools/objtool/include/objtool/orc.h | 11 +
tools/objtool/orc_dump.c | 69 +--
tools/objtool/orc_gen.c | 93 +---
46 files changed, 1949 insertions(+), 171 deletions(-)
create mode 100644 arch/loongarch/include/asm/orc_header.h
create mode 100644 arch/loongarch/include/asm/orc_lookup.h
create mode 100644 arch/loongarch/include/asm/orc_types.h
create mode 100644 arch/loongarch/include/asm/unwind_hints.h
create mode 100644 arch/loongarch/kernel/unwind_orc.c
create mode 100644 tools/arch/loongarch/include/asm/inst.h
create mode 100644 tools/arch/loongarch/include/asm/orc_types.h
create mode 100644 tools/objtool/arch/loongarch/Build
create mode 100644 tools/objtool/arch/loongarch/decode.c
create mode 100644 tools/objtool/arch/loongarch/include/arch/cfi_regs.h
create mode 100644 tools/objtool/arch/loongarch/include/arch/elf.h
create mode 100644 tools/objtool/arch/loongarch/include/arch/special.h
create mode 100644 tools/objtool/arch/loongarch/orc.c
create mode 100644 tools/objtool/arch/loongarch/special.c
create mode 100644 tools/objtool/arch/x86/orc.c
create mode 100644 tools/objtool/include/objtool/orc.h

--
2.1.0



2023-07-25 12:28:19

by Peter Zijlstra

[permalink] [raw]
Subject: Re: [PATCH v1 0/6] Add objtool and orc support for LoongArch

On Tue, Jul 25, 2023 at 04:15:04PM +0800, Tiezhu Yang wrote:

> To be honest, there still exist some objtool warnings, I will try my best
> to fix them in the later versions or the other separate patches.

Please give us some examples of what's still going wrong. Are you
running into jump-tables? IIRC I've not seen code for those yet.

2023-08-09 10:33:15

by Tiezhu Yang

[permalink] [raw]
Subject: Re: [PATCH v1 0/6] Add objtool and orc support for LoongArch



On 07/25/2023 08:01 PM, Peter Zijlstra wrote:
> On Tue, Jul 25, 2023 at 04:15:04PM +0800, Tiezhu Yang wrote:
>
>> To be honest, there still exist some objtool warnings, I will try my best
>> to fix them in the later versions or the other separate patches.
>
> Please give us some examples of what's still going wrong. Are you
> running into jump-tables? IIRC I've not seen code for those yet.
>

Sorry for the late reply, I did more analysis and test recently.
I have already addressed most of the objtool warnings, discussed
offline with compiler engineers, sent separate patch to maillist
or modified the related code locally.

For example,
arch/loongarch/mm/fault.o: warning: objtool: no_context.part.0() falls
through to next function do_sigsegv()
[PATCH] LoongArch: Remove noreturn attribute for die()
https://lore.kernel.org/loongarch/[email protected]/

Additionally, when I update the latest upstream gcc and binutils,
it generates more objtool warnings, like this:
init/version.o: warning: objtool: early_hostname+0x20: sibling call from
callable instruction with modified stack frame

[fedora@linux 6.5.test]$ gcc --version
gcc (GCC) 14.0.0 20230803 (experimental)
[fedora@linux 6.5.test]$ as --version
GNU assembler (GNU Binutils) 2.41.50.20230803
[fedora@linux 6.5.test]$ objdump -M no-aliases -D init/version.o
0000000000000000 <early_hostname>:
0: 00150085 or $a1, $a0, $zero
4: 1a000004 pcalau12i $a0, 0
8: 02ffc063 addi.d $sp, $sp, -16
c: 02810406 addi.w $a2, $zero, 65
10: 02c00084 addi.d $a0, $a0, 0
14: 29c02061 st.d $ra, $sp, 8
18: 54000000 bl 0 # 18 <early_hostname+0x18>
1c: 0281000c addi.w $t0, $zero, 64
20: 6c001584 bgeu $t0, $a0, 20 # 34 <.L2>
24: 1a000004 pcalau12i $a0, 0
28: 02810005 addi.w $a1, $zero, 64
2c: 02c00084 addi.d $a0, $a0, 0
30: 54000000 bl 0 # 30 <early_hostname+0x30>

0000000000000034 <.L2>:
34: 28c02061 ld.d $ra, $sp, 8
38: 00150004 or $a0, $zero, $zero
3c: 02c04063 addi.d $sp, $sp, 16
40: 4c000020 jirl $zero, $ra, 0

A preliminary analysis shows that the common functions is_sibling_call()
and add_jump_destinations() in tools/objtool/check.c need to be modified
to handle the case "reloc->sym->type == STT_NOTYPE", I will send a patch
in the next week.

Thanks,
Tiezhu