2023-12-16 06:54:15

by Youling Tang

[permalink] [raw]
Subject: [PATCH] checkstack: Add loongarch support for scripts/checkstack.pl

From: Youling Tang <[email protected]>

scripts/checkstack.pl lacks support for the loongarch architecture. Add
support to detect "addi.{w,d} $sp, $sp, -FRAME_SIZE" stack frame generation
instruction.

Signed-off-by: Youling Tang <[email protected]>
---
scripts/checkstack.pl | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
index f27d552aec43..e9d01b999b74 100755
--- a/scripts/checkstack.pl
+++ b/scripts/checkstack.pl
@@ -16,6 +16,7 @@
# sparc port by Martin Habets <[email protected]>
# ppc64le port by Breno Leitao <[email protected]>
# riscv port by Wadim Mueller <[email protected]>
+# loongarch port by Youling Tang <[email protected]>
#
# Usage:
# objdump -d vmlinux | scripts/checkstack.pl [arch]
@@ -104,6 +105,9 @@ my (@stack, $re, $dre, $sub, $x, $xs, $funcre, $min_stack);
} elsif ($arch =~ /^riscv(64)?$/) {
#ffffffff8036e868: c2010113 addi sp,sp,-992
$re = qr/.*addi.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
+ } elsif ($arch =~ /^loongarch(32|64)?$/) {
+ #9000000000224708: 02ff4063 addi.d $sp, $sp, -48(0xfd0)
+ $re = qr/.*addi\..*sp, .*sp, -([0-9]{1,8}).*/o;
} else {
print("wrong or unknown architecture \"$arch\"\n");
exit
--
2.40.0



2023-12-16 12:15:27

by Huacai Chen

[permalink] [raw]
Subject: Re: [PATCH] checkstack: Add loongarch support for scripts/checkstack.pl

Acked-by: Huacai Chen <[email protected]>

On Sat, Dec 16, 2023 at 2:48 PM Youling Tang <[email protected]> wrote:
>
> From: Youling Tang <[email protected]>
>
> scripts/checkstack.pl lacks support for the loongarch architecture. Add
> support to detect "addi.{w,d} $sp, $sp, -FRAME_SIZE" stack frame generation
> instruction.
>
> Signed-off-by: Youling Tang <[email protected]>
> ---
> scripts/checkstack.pl | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
> index f27d552aec43..e9d01b999b74 100755
> --- a/scripts/checkstack.pl
> +++ b/scripts/checkstack.pl
> @@ -16,6 +16,7 @@
> # sparc port by Martin Habets <[email protected]>
> # ppc64le port by Breno Leitao <[email protected]>
> # riscv port by Wadim Mueller <[email protected]>
> +# loongarch port by Youling Tang <[email protected]>
> #
> # Usage:
> # objdump -d vmlinux | scripts/checkstack.pl [arch]
> @@ -104,6 +105,9 @@ my (@stack, $re, $dre, $sub, $x, $xs, $funcre, $min_stack);
> } elsif ($arch =~ /^riscv(64)?$/) {
> #ffffffff8036e868: c2010113 addi sp,sp,-992
> $re = qr/.*addi.*sp,sp,-(([0-9]{2}|[3-9])[0-9]{2})/o;
> + } elsif ($arch =~ /^loongarch(32|64)?$/) {
> + #9000000000224708: 02ff4063 addi.d $sp, $sp, -48(0xfd0)
> + $re = qr/.*addi\..*sp, .*sp, -([0-9]{1,8}).*/o;
> } else {
> print("wrong or unknown architecture \"$arch\"\n");
> exit
> --
> 2.40.0
>