All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] LoongArch: Modify handle_syscall
@ 2022-06-15  1:39 Tiezhu Yang
  2022-06-15  1:39 ` [RFC PATCH 1/2] LoongArch: Only clone and clone3 need to call SAVE_STATIC Tiezhu Yang
  2022-06-15  1:39 ` [RFC PATCH 2/2] LoongArch: No need to call RESTORE_ALL_AND_RET for all syscalls Tiezhu Yang
  0 siblings, 2 replies; 3+ messages in thread
From: Tiezhu Yang @ 2022-06-15  1:39 UTC (permalink / raw)
  To: Huacai Chen, WANG Xuerui; +Cc: Xuefeng Li, Jianmin Lv, Jun Yi, linux-kernel

Tiezhu Yang (2):
  LoongArch: Only clone and clone3 need to call SAVE_STATIC
  LoongArch: No need to call RESTORE_ALL_AND_RET for all syscalls

 arch/loongarch/include/asm/stackframe.h | 10 ++++++++++
 arch/loongarch/kernel/entry.S           | 25 ++++++++++++++++++++++++-
 2 files changed, 34 insertions(+), 1 deletion(-)

-- 
2.1.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [RFC PATCH 1/2] LoongArch: Only clone and clone3 need to call SAVE_STATIC
  2022-06-15  1:39 [RFC PATCH 0/2] LoongArch: Modify handle_syscall Tiezhu Yang
@ 2022-06-15  1:39 ` Tiezhu Yang
  2022-06-15  1:39 ` [RFC PATCH 2/2] LoongArch: No need to call RESTORE_ALL_AND_RET for all syscalls Tiezhu Yang
  1 sibling, 0 replies; 3+ messages in thread
From: Tiezhu Yang @ 2022-06-15  1:39 UTC (permalink / raw)
  To: Huacai Chen, WANG Xuerui; +Cc: Xuefeng Li, Jianmin Lv, Jun Yi, linux-kernel

In handle_syscall, it is unnecessary to call SAVE_STATIC for all syscalls,
only clone and clone3 need to do this operation, so it is better to check
the syscall number before call SAVE_STATIC.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 arch/loongarch/kernel/entry.S | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/loongarch/kernel/entry.S b/arch/loongarch/kernel/entry.S
index d5b3dbc..551b6ec 100644
--- a/arch/loongarch/kernel/entry.S
+++ b/arch/loongarch/kernel/entry.S
@@ -14,6 +14,7 @@
 #include <asm/regdef.h>
 #include <asm/stackframe.h>
 #include <asm/thread_info.h>
+#include <asm/unistd.h>
 
 	.text
 	.cfi_sections	.debug_frame
@@ -56,8 +57,20 @@ SYM_FUNC_START(handle_syscall)
 	cfi_st	u0, PT_R21
 	cfi_st	fp, PT_R22
 
+	/*
+	 * Syscall number held in a7.
+	 * If syscall number is __NR_clone and __NR_clone3, call SAVE_STATIC.
+	 */
+	li.w	t3, __NR_clone
+	beq	a7, t3, 1f
+	li.w	t3, __NR_clone3
+	beq	a7, t3, 1f
+	b	2f
+
+1:
 	SAVE_STATIC
 
+2:
 	move	u0, t0
 	li.d	tp, ~_THREAD_MASK
 	and	tp, tp, sp
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [RFC PATCH 2/2] LoongArch: No need to call RESTORE_ALL_AND_RET for all syscalls
  2022-06-15  1:39 [RFC PATCH 0/2] LoongArch: Modify handle_syscall Tiezhu Yang
  2022-06-15  1:39 ` [RFC PATCH 1/2] LoongArch: Only clone and clone3 need to call SAVE_STATIC Tiezhu Yang
@ 2022-06-15  1:39 ` Tiezhu Yang
  1 sibling, 0 replies; 3+ messages in thread
From: Tiezhu Yang @ 2022-06-15  1:39 UTC (permalink / raw)
  To: Huacai Chen, WANG Xuerui; +Cc: Xuefeng Li, Jianmin Lv, Jun Yi, linux-kernel

In handle_syscall, it is unnecessary to call RESTORE_ALL_AND_RET for all
syscalls, clone and clone3 should call RESTORE_STATIC_SOME_AND_RET, and
the other syscalls should call RESTORE_SOME_AND_RET.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 arch/loongarch/include/asm/stackframe.h | 10 ++++++++++
 arch/loongarch/kernel/entry.S           | 12 +++++++++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/arch/loongarch/include/asm/stackframe.h b/arch/loongarch/include/asm/stackframe.h
index 4ca9530..9869b39 100644
--- a/arch/loongarch/include/asm/stackframe.h
+++ b/arch/loongarch/include/asm/stackframe.h
@@ -216,4 +216,14 @@
 	RESTORE_SP_AND_RET \docfi
 	.endm
 
+	.macro	RESTORE_STATIC_SOME_AND_RET docfi=0
+	RESTORE_STATIC \docfi
+	RESTORE_SOME \docfi
+	RESTORE_SP_AND_RET \docfi
+	.endm
+
+	.macro	RESTORE_SOME_AND_RET docfi=0
+	RESTORE_SOME \docfi
+	RESTORE_SP_AND_RET \docfi
+	.endm
 #endif /* _ASM_STACKFRAME_H */
diff --git a/arch/loongarch/kernel/entry.S b/arch/loongarch/kernel/entry.S
index 551b6ec..8176094 100644
--- a/arch/loongarch/kernel/entry.S
+++ b/arch/loongarch/kernel/entry.S
@@ -78,7 +78,17 @@ SYM_FUNC_START(handle_syscall)
 	move	a0, sp
 	bl	do_syscall
 
-	RESTORE_ALL_AND_RET
+	/*
+	 * Syscall number held in a7.
+	 * If syscall number is __NR_clone and __NR_clone3, call RESTORE_STATIC_SOME_AND_RET.
+	 */
+	li.w	t3, __NR_clone
+	beq	a7, t3, 3f
+	li.w	t3, __NR_clone3
+	beq	a7, t3, 3f
+	RESTORE_SOME_AND_RET
+3:
+	RESTORE_STATIC_SOME_AND_RET
 SYM_FUNC_END(handle_syscall)
 
 SYM_CODE_START(ret_from_fork)
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-15  1:39 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-15  1:39 [RFC PATCH 0/2] LoongArch: Modify handle_syscall Tiezhu Yang
2022-06-15  1:39 ` [RFC PATCH 1/2] LoongArch: Only clone and clone3 need to call SAVE_STATIC Tiezhu Yang
2022-06-15  1:39 ` [RFC PATCH 2/2] LoongArch: No need to call RESTORE_ALL_AND_RET for all syscalls Tiezhu Yang

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.