[PATCH 0/4] LoongArch: Add unwinder support

Qing Zhang posted 4 patches 3 years, 8 months ago
arch/loongarch/Kconfig                  |   6 +
arch/loongarch/Kconfig.debug            |  28 ++++
arch/loongarch/include/asm/inst.h       |  52 +++++++
arch/loongarch/include/asm/processor.h  |   9 ++
arch/loongarch/include/asm/stacktrace.h |  22 +++
arch/loongarch/include/asm/switch_to.h  |  14 +-
arch/loongarch/include/asm/uaccess.h    |   4 +-
arch/loongarch/include/asm/unwind.h     |  45 +++++++
arch/loongarch/kernel/Makefile          |   4 +
arch/loongarch/kernel/asm-offsets.c     |   2 +
arch/loongarch/kernel/process.c         |  64 +++++++++
arch/loongarch/kernel/stacktrace.c      |  79 +++++++++++
arch/loongarch/kernel/switch.S          |   2 +
arch/loongarch/kernel/traps.c           |  27 ++--
arch/loongarch/kernel/unwind_guess.c    |  65 +++++++++
arch/loongarch/kernel/unwind_prologue.c | 172 ++++++++++++++++++++++++
16 files changed, 577 insertions(+), 18 deletions(-)
create mode 100644 arch/loongarch/include/asm/unwind.h
create mode 100644 arch/loongarch/kernel/stacktrace.c
create mode 100644 arch/loongarch/kernel/unwind_guess.c
create mode 100644 arch/loongarch/kernel/unwind_prologue.c
[PATCH 0/4] LoongArch: Add unwinder support
Posted by Qing Zhang 3 years, 8 months ago
This series in order to add stacktrace suport, Some upcoming features require
these changes, like trace, divide unwinder into guess unwinder and prologue
unwinder is to add new unwinders in the future, eg:unwind_frame, unwind_orc .etc.
Three stages when we do unwind,
  1) unwind_start(), the prapare of unwinding, fill unwind_state.
  2) unwind_done(), judge whether the unwind process is finished or not.
  3) unwind_next_frame(), unwind the next frame.

you can test them by:
  1) echo t > /proc/sysrq-trigger
  2) cat /proc/*/stack
  4) ftrace: function graph
  5) uprobe: echo 1 > ./options/userstacktrace

Changes from v1 to v2:

- Add the judgment of the offset value of ra in the prologue.
  (Suggested by Youling).
- Create an inline function to check the sign bit, which is convenient
  for extending other types of immediates.  (Suggested by Jinyang).
- Fix sparse warning :
    arch/loongarch/include/asm/uaccess.h:232:32: sparse: sparse: incorrect
    type in argument 2 (different address spaces) @@     expected void const
    *from @@     got void const [noderef] __user *from @@
- Add USER_STACKTRACE support as a series.

Qing Zhang (4):
  LoongArch: Add guess unwinder support
  LoongArch: Add prologue unwinder support
  LoongArch: Add stacktrace support
  LoongArch: Add USER_STACKTRACE support

 arch/loongarch/Kconfig                  |   6 +
 arch/loongarch/Kconfig.debug            |  28 ++++
 arch/loongarch/include/asm/inst.h       |  52 +++++++
 arch/loongarch/include/asm/processor.h  |   9 ++
 arch/loongarch/include/asm/stacktrace.h |  22 +++
 arch/loongarch/include/asm/switch_to.h  |  14 +-
 arch/loongarch/include/asm/uaccess.h    |   4 +-
 arch/loongarch/include/asm/unwind.h     |  45 +++++++
 arch/loongarch/kernel/Makefile          |   4 +
 arch/loongarch/kernel/asm-offsets.c     |   2 +
 arch/loongarch/kernel/process.c         |  64 +++++++++
 arch/loongarch/kernel/stacktrace.c      |  79 +++++++++++
 arch/loongarch/kernel/switch.S          |   2 +
 arch/loongarch/kernel/traps.c           |  27 ++--
 arch/loongarch/kernel/unwind_guess.c    |  65 +++++++++
 arch/loongarch/kernel/unwind_prologue.c | 172 ++++++++++++++++++++++++
 16 files changed, 577 insertions(+), 18 deletions(-)
 create mode 100644 arch/loongarch/include/asm/unwind.h
 create mode 100644 arch/loongarch/kernel/stacktrace.c
 create mode 100644 arch/loongarch/kernel/unwind_guess.c
 create mode 100644 arch/loongarch/kernel/unwind_prologue.c

-- 
2.20.1
Re: [PATCH 0/4] LoongArch: Add unwinder support
Posted by Huacai Chen 3 years, 8 months ago
Hi, Qing,

I think we don't need to CC linux-kernel; on the other hand, CC
linux-arch and Arnd is worthy.
BTW, it seems you are missing V2 in the title.

Huacai

On Mon, Aug 1, 2022 at 8:17 PM Qing Zhang <zhangqing@loongson.cn> wrote:
>
> This series in order to add stacktrace suport, Some upcoming features require
> these changes, like trace, divide unwinder into guess unwinder and prologue
> unwinder is to add new unwinders in the future, eg:unwind_frame, unwind_orc .etc.
> Three stages when we do unwind,
>   1) unwind_start(), the prapare of unwinding, fill unwind_state.
>   2) unwind_done(), judge whether the unwind process is finished or not.
>   3) unwind_next_frame(), unwind the next frame.
>
> you can test them by:
>   1) echo t > /proc/sysrq-trigger
>   2) cat /proc/*/stack
>   4) ftrace: function graph
>   5) uprobe: echo 1 > ./options/userstacktrace
>
> Changes from v1 to v2:
>
> - Add the judgment of the offset value of ra in the prologue.
>   (Suggested by Youling).
> - Create an inline function to check the sign bit, which is convenient
>   for extending other types of immediates.  (Suggested by Jinyang).
> - Fix sparse warning :
>     arch/loongarch/include/asm/uaccess.h:232:32: sparse: sparse: incorrect
>     type in argument 2 (different address spaces) @@     expected void const
>     *from @@     got void const [noderef] __user *from @@
> - Add USER_STACKTRACE support as a series.
>
> Qing Zhang (4):
>   LoongArch: Add guess unwinder support
>   LoongArch: Add prologue unwinder support
>   LoongArch: Add stacktrace support
>   LoongArch: Add USER_STACKTRACE support
>
>  arch/loongarch/Kconfig                  |   6 +
>  arch/loongarch/Kconfig.debug            |  28 ++++
>  arch/loongarch/include/asm/inst.h       |  52 +++++++
>  arch/loongarch/include/asm/processor.h  |   9 ++
>  arch/loongarch/include/asm/stacktrace.h |  22 +++
>  arch/loongarch/include/asm/switch_to.h  |  14 +-
>  arch/loongarch/include/asm/uaccess.h    |   4 +-
>  arch/loongarch/include/asm/unwind.h     |  45 +++++++
>  arch/loongarch/kernel/Makefile          |   4 +
>  arch/loongarch/kernel/asm-offsets.c     |   2 +
>  arch/loongarch/kernel/process.c         |  64 +++++++++
>  arch/loongarch/kernel/stacktrace.c      |  79 +++++++++++
>  arch/loongarch/kernel/switch.S          |   2 +
>  arch/loongarch/kernel/traps.c           |  27 ++--
>  arch/loongarch/kernel/unwind_guess.c    |  65 +++++++++
>  arch/loongarch/kernel/unwind_prologue.c | 172 ++++++++++++++++++++++++
>  16 files changed, 577 insertions(+), 18 deletions(-)
>  create mode 100644 arch/loongarch/include/asm/unwind.h
>  create mode 100644 arch/loongarch/kernel/stacktrace.c
>  create mode 100644 arch/loongarch/kernel/unwind_guess.c
>  create mode 100644 arch/loongarch/kernel/unwind_prologue.c
>
> --
> 2.20.1
>
>
Re: [PATCH 0/4] LoongArch: Add unwinder support
Posted by zhangqing 3 years, 8 months ago

On 2022/8/1 下午11:34, Huacai Chen wrote:
> Hi, Qing,
> 
> I think we don't need to CC linux-kernel; on the other hand, CC
> linux-arch and Arnd is worthy.
> BTW, it seems you are missing V2 in the title.
> 
> Huacai

Hi, Huacai

Made a careless error...

Thanks,
-Qing

Re: [PATCH 0/4] LoongArch: Add unwinder support
Posted by Xi Ruoyao 3 years, 8 months ago
On Mon, 2022-08-01 at 23:34 +0800, Huacai Chen wrote:
> Hi, Qing,
> 
> I think we don't need to CC linux-kernel; on the other hand, CC
> linux-arch and Arnd is worthy.
> BTW, it seems you are missing V2 in the title.

https://www.kernel.org/doc/html/latest/process/submitting-patches.html#select-the-recipients-for-your-patch:
"linux-kernel@vger.kernel.org should be used by default for all
patches".

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University