[RFC PATCH 1/2] LoongArch: Only clone and clone3 need to call SAVE_STATIC

From: Tiezhu Yang
Date: Tue Jun 14 2022 - 21:39:25 EST


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@xxxxxxxxxxx>
---
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