提交 52ca9446 编写于 作者: H Hongchen Zhang 提交者: openeuler-sync-bot

LoongArch: optimize for syscall return

LoongArch inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I6BWFP

--------------------------------

If the syscall is not rt_sigreturn,there is no need to do
RESTORE_STATIC and RESTORE_TEMP.
Signed-off-by: NHongchen Zhang <zhanghongchen@loongson.cn>
Change-Id: I61804bb16ce678dd39e9f197bd88d91e13b972cb
(cherry picked from commit eba5f68c)
上级 476758c6
...@@ -14,13 +14,14 @@ ...@@ -14,13 +14,14 @@
#include <asm/regdef.h> #include <asm/regdef.h>
#include <asm/stackframe.h> #include <asm/stackframe.h>
#include <asm/thread_info.h> #include <asm/thread_info.h>
#include <asm/unistd.h>
.text .text
.cfi_sections .debug_frame .cfi_sections .debug_frame
.align 5 .align 5
SYM_FUNC_START(handle_syscall) SYM_FUNC_START(handle_syscall)
csrrd t0, PERCPU_BASE_KS csrrd t0, PERCPU_BASE_KS
la.abs t1, kernelsp la.pcrel t1, kernelsp
add.d t1, t1, t0 add.d t1, t1, t0
move t2, sp move t2, sp
ld.d sp, t1, 0 ld.d sp, t1, 0
...@@ -28,11 +29,10 @@ SYM_FUNC_START(handle_syscall) ...@@ -28,11 +29,10 @@ SYM_FUNC_START(handle_syscall)
addi.d sp, sp, -PT_SIZE addi.d sp, sp, -PT_SIZE
cfi_st t2, PT_R3 cfi_st t2, PT_R3
cfi_rel_offset sp, PT_R3 cfi_rel_offset sp, PT_R3
st.d zero, sp, PT_R0
csrrd t2, LOONGARCH_CSR_PRMD csrrd t2, LOONGARCH_CSR_PRMD
st.d t2, sp, PT_PRMD st.d t2, sp, PT_PRMD
cfi_st ra, PT_R1 cfi_st ra, PT_R1
cfi_st a0, PT_R4 cfi_st a0, PT_ORIG_A0
cfi_st a1, PT_R5 cfi_st a1, PT_R5
cfi_st a2, PT_R6 cfi_st a2, PT_R6
cfi_st a3, PT_R7 cfi_st a3, PT_R7
...@@ -41,6 +41,7 @@ SYM_FUNC_START(handle_syscall) ...@@ -41,6 +41,7 @@ SYM_FUNC_START(handle_syscall)
cfi_st a6, PT_R10 cfi_st a6, PT_R10
cfi_st a7, PT_R11 cfi_st a7, PT_R11
csrrd ra, LOONGARCH_CSR_ERA csrrd ra, LOONGARCH_CSR_ERA
addi.d ra, ra, 4
st.d ra, sp, PT_ERA st.d ra, sp, PT_ERA
cfi_rel_offset ra, PT_ERA cfi_rel_offset ra, PT_ERA
...@@ -55,9 +56,17 @@ SYM_FUNC_START(handle_syscall) ...@@ -55,9 +56,17 @@ SYM_FUNC_START(handle_syscall)
and tp, tp, sp and tp, tp, sp
move a0, sp move a0, sp
move a1, a7
bl do_syscall bl do_syscall
RESTORE_ALL_AND_RET addi.w t0, zero, __NR_rt_sigreturn
bne a0, t0, 1f
RESTORE_STATIC
RESTORE_TEMP
1:
RESTORE_SOME
RESTORE_SP_AND_RET
SYM_FUNC_END(handle_syscall) SYM_FUNC_END(handle_syscall)
SYM_CODE_START(ret_from_fork) SYM_CODE_START(ret_from_fork)
......
...@@ -37,18 +37,16 @@ void *sys_call_table[__NR_syscalls] = { ...@@ -37,18 +37,16 @@ void *sys_call_table[__NR_syscalls] = {
typedef long (*sys_call_fn)(unsigned long, unsigned long, typedef long (*sys_call_fn)(unsigned long, unsigned long,
unsigned long, unsigned long, unsigned long, unsigned long); unsigned long, unsigned long, unsigned long, unsigned long);
void noinstr do_syscall(struct pt_regs *regs) unsigned long noinstr do_syscall(struct pt_regs *regs, unsigned long nr)
{ {
unsigned long nr;
sys_call_fn syscall_fn; sys_call_fn syscall_fn;
nr = regs->regs[11];
/* Set for syscall restarting */ /* Set for syscall restarting */
if (nr < NR_syscalls) if (nr < NR_syscalls)
regs->regs[0] = nr + 1; regs->regs[0] = nr + 1;
else
regs->regs[0] = 0;
regs->csr_era += 4;
regs->orig_a0 = regs->regs[4];
regs->regs[4] = -ENOSYS; regs->regs[4] = -ENOSYS;
nr = syscall_enter_from_user_mode(regs, nr); nr = syscall_enter_from_user_mode(regs, nr);
...@@ -60,4 +58,6 @@ void noinstr do_syscall(struct pt_regs *regs) ...@@ -60,4 +58,6 @@ void noinstr do_syscall(struct pt_regs *regs)
} }
syscall_exit_to_user_mode(regs); syscall_exit_to_user_mode(regs);
return nr;
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册