All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stafford Horne <shorne@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Jonas Bonn <jonas@southpole.se>, Petr Mladek <pmladek@suse.com>,
	Chris Down <chris@chrisdown.name>, Marc Zyngier <maz@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Randy Dunlap <rdunlap@infradead.org>,
	Openrisc <openrisc@lists.librecores.org>,
	Andrey Bacherov <bandvig@mail.ru>
Subject: [PATCH v3 04/13] openrisc: Add syscall details to emergency syscall debugging
Date: Sat, 21 May 2022 22:13:14 +0900	[thread overview]
Message-ID: <20220521131323.631209-5-shorne@gmail.com> (raw)
In-Reply-To: <20220521131323.631209-1-shorne@gmail.com>

When bringing linux on the or1k Marocchino we ran into issues starting
init.  This patch adds the syscall number and return address to
assist tracing syscalls even before strace is able to be used.

By default this is all disabled but a developer could adjust the ifdef
to enable debugging.

Cc: Andrey Bacherov <bandvig@mail.ru>
Signed-off-by: Stafford Horne <shorne@gmail.com>
---
 arch/openrisc/kernel/entry.S | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/arch/openrisc/kernel/entry.S b/arch/openrisc/kernel/entry.S
index 3ca1b1f490b9..54a87bba35ca 100644
--- a/arch/openrisc/kernel/entry.S
+++ b/arch/openrisc/kernel/entry.S
@@ -601,7 +601,7 @@ UNHANDLED_EXCEPTION(_vector_0xb00,0xb00)
  */
 
 _string_syscall_return:
-	.string "syscall return %ld \n\r\0"
+	.string "syscall r9:0x%08x -> syscall(%ld) return %ld\0"
 	.align 4
 
 ENTRY(_sys_call_handler)
@@ -679,15 +679,25 @@ _syscall_return:
 _syscall_debug:
 	l.movhi r3,hi(_string_syscall_return)
 	l.ori   r3,r3,lo(_string_syscall_return)
-	l.ori   r27,r0,1
+	l.ori   r27,r0,2
 	l.sw    -4(r1),r27
 	l.sw    -8(r1),r11
-	l.addi  r1,r1,-8
+	l.lwz	r29,PT_ORIG_GPR11(r1)
+	l.sw    -12(r1),r29
+	l.lwz	r29,PT_GPR9(r1)
+	l.sw    -16(r1),r29
 	l.movhi r27,hi(_printk)
 	l.ori   r27,r27,lo(_printk)
 	l.jalr  r27
-	 l.nop
-	l.addi  r1,r1,8
+	 l.addi  r1,r1,-16
+	l.addi  r1,r1,16
+#endif
+#if 0
+_syscall_show_regs:
+	l.movhi r27,hi(show_registers)
+	l.ori   r27,r27,lo(show_registers)
+	l.jalr  r27
+	 l.or	r3,r1,r1
 #endif
 
 _syscall_check_trace_leave:
-- 
2.31.1


WARNING: multiple messages have this Message-ID (diff)
From: Stafford Horne <shorne@gmail.com>
To: LKML <linux-kernel@vger.kernel.org>
Cc: Openrisc <openrisc@lists.librecores.org>,
	Stafford Horne <shorne@gmail.com>,
	Andrey Bacherov <bandvig@mail.ru>,
	Jonas Bonn <jonas@southpole.se>,
	Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>,
	Randy Dunlap <rdunlap@infradead.org>,
	Petr Mladek <pmladek@suse.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Marc Zyngier <maz@kernel.org>, Chris Down <chris@chrisdown.name>
Subject: [PATCH v3 04/13] openrisc: Add syscall details to emergency syscall debugging
Date: Sat, 21 May 2022 22:13:14 +0900	[thread overview]
Message-ID: <20220521131323.631209-5-shorne@gmail.com> (raw)
In-Reply-To: <20220521131323.631209-1-shorne@gmail.com>

When bringing linux on the or1k Marocchino we ran into issues starting
init.  This patch adds the syscall number and return address to
assist tracing syscalls even before strace is able to be used.

By default this is all disabled but a developer could adjust the ifdef
to enable debugging.

Cc: Andrey Bacherov <bandvig@mail.ru>
Signed-off-by: Stafford Horne <shorne@gmail.com>
---
 arch/openrisc/kernel/entry.S | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/arch/openrisc/kernel/entry.S b/arch/openrisc/kernel/entry.S
index 3ca1b1f490b9..54a87bba35ca 100644
--- a/arch/openrisc/kernel/entry.S
+++ b/arch/openrisc/kernel/entry.S
@@ -601,7 +601,7 @@ UNHANDLED_EXCEPTION(_vector_0xb00,0xb00)
  */
 
 _string_syscall_return:
-	.string "syscall return %ld \n\r\0"
+	.string "syscall r9:0x%08x -> syscall(%ld) return %ld\0"
 	.align 4
 
 ENTRY(_sys_call_handler)
@@ -679,15 +679,25 @@ _syscall_return:
 _syscall_debug:
 	l.movhi r3,hi(_string_syscall_return)
 	l.ori   r3,r3,lo(_string_syscall_return)
-	l.ori   r27,r0,1
+	l.ori   r27,r0,2
 	l.sw    -4(r1),r27
 	l.sw    -8(r1),r11
-	l.addi  r1,r1,-8
+	l.lwz	r29,PT_ORIG_GPR11(r1)
+	l.sw    -12(r1),r29
+	l.lwz	r29,PT_GPR9(r1)
+	l.sw    -16(r1),r29
 	l.movhi r27,hi(_printk)
 	l.ori   r27,r27,lo(_printk)
 	l.jalr  r27
-	 l.nop
-	l.addi  r1,r1,8
+	 l.addi  r1,r1,-16
+	l.addi  r1,r1,16
+#endif
+#if 0
+_syscall_show_regs:
+	l.movhi r27,hi(show_registers)
+	l.ori   r27,r27,lo(show_registers)
+	l.jalr  r27
+	 l.or	r3,r1,r1
 #endif
 
 _syscall_check_trace_leave:
-- 
2.31.1


  parent reply	other threads:[~2022-05-21 13:13 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-21 13:13 [PATCH v3 00/13] OpenRISC misc cleanups for 5.19 Stafford Horne
2022-05-21 13:13 ` Stafford Horne
2022-05-21 13:13 ` [PATCH v3 01/13] openrisc: Add gcc machine instruction flag configuration Stafford Horne
2022-05-21 13:13   ` Stafford Horne
2022-05-21 13:13 ` [PATCH v3 02/13] openrisc: Cleanup emergency print handling Stafford Horne
2022-05-21 13:13   ` Stafford Horne
2022-05-21 13:13 ` [PATCH v3 03/13] openrisc: Add support for liteuart emergency printing Stafford Horne
2022-05-21 13:13   ` Stafford Horne
2022-05-21 13:13 ` Stafford Horne [this message]
2022-05-21 13:13   ` [PATCH v3 04/13] openrisc: Add syscall details to emergency syscall debugging Stafford Horne
2022-05-21 13:13 ` [PATCH v3 05/13] openrisc: Pretty print show_registers memory dumps Stafford Horne
2022-05-21 13:13   ` Stafford Horne
2022-05-21 13:13 ` [PATCH v3 06/13] openrisc: Update litex defconfig to support glibc userland Stafford Horne
2022-05-21 13:13   ` Stafford Horne
2022-05-21 13:13 ` [PATCH v3 07/13] openrisc/traps: Declare file scope symbols as static Stafford Horne
2022-05-21 13:13   ` Stafford Horne
2022-05-21 13:13 ` [PATCH v3 08/13] openrisc/traps: Remove die_if_kernel function Stafford Horne
2022-05-21 13:13   ` Stafford Horne
2022-05-21 13:13 ` [PATCH v3 09/13] openrisc/traps: Declare unhandled_exception for asmlinkage Stafford Horne
2022-05-21 13:13   ` Stafford Horne
2022-05-21 13:13 ` [PATCH v3 10/13] openrisc/time: Fix symbol scope warnings Stafford Horne
2022-05-21 13:13   ` Stafford Horne
2022-05-21 13:13 ` [PATCH v3 11/13] openrisc/delay: Add include to fix symbol not declared warning Stafford Horne
2022-05-21 13:13   ` Stafford Horne
2022-05-21 13:13 ` [PATCH v3 12/13] openrisc/fault: Fix symbol scope warnings Stafford Horne
2022-05-21 13:13   ` Stafford Horne
2022-05-21 13:13 ` [PATCH v3 13/13] openrisc: Remove unused IMMU tlb workardound Stafford Horne
2022-05-21 13:13   ` Stafford Horne

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220521131323.631209-5-shorne@gmail.com \
    --to=shorne@gmail.com \
    --cc=bandvig@mail.ru \
    --cc=chris@chrisdown.name \
    --cc=jonas@southpole.se \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=maz@kernel.org \
    --cc=openrisc@lists.librecores.org \
    --cc=pmladek@suse.com \
    --cc=rdunlap@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.