lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1655275079-17651-2-git-send-email-yangtiezhu@loongson.cn>
Date:   Wed, 15 Jun 2022 14:37:58 +0800
From:   Tiezhu Yang <yangtiezhu@...ngson.cn>
To:     Huacai Chen <chenhuacai@...nel.org>,
        WANG Xuerui <kernel@...0n.name>
Cc:     Xuefeng Li <lixuefeng@...ngson.cn>,
        Jianmin Lv <lvjianmin@...ngson.cn>, Jun Yi <yijun@...ngson.cn>,
        Rui Wang <wangrui@...ngson.cn>, linux-kernel@...r.kernel.org
Subject: [RFC PATCH v2 1/2] LoongArch: Only clone and clone3 need to call SAVE_STATIC

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.

With this patch, it can reduce many store instructions.

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

diff --git a/arch/loongarch/kernel/entry.S b/arch/loongarch/kernel/entry.S
index d5b3dbc..53ce2cb 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,21 @@ SYM_FUNC_START(handle_syscall)
 	cfi_st	u0, PT_R21
 	cfi_st	fp, PT_R22
 
+	/*
+	 * Syscall number held in a7 which is stored in PT_R11.
+	 * Only if syscall number is __NR_clone and __NR_clone3, call SAVE_STATIC.
+	 */
+	cfi_ld	t3, PT_R11
+	li.w	t4, __NR_clone
+	beq	t3, t4, 1f
+	li.w	t4, __NR_clone3
+	beq	t3, t4, 1f
+	b	2f
+
+1:
 	SAVE_STATIC
 
+2:
 	move	u0, t0
 	li.d	tp, ~_THREAD_MASK
 	and	tp, tp, sp
-- 
2.1.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ