diff --git a/arch/loongarch/kernel/entry.S b/arch/loongarch/kernel/entry.S index 48e7e34e355e8..2dc49eda45d49 100644 --- a/arch/loongarch/kernel/entry.S +++ b/arch/loongarch/kernel/entry.S @@ -30,7 +30,8 @@ SYM_CODE_START(handle_syscall) addi.d sp, sp, -PT_SIZE cfi_st t2, PT_R3 cfi_rel_offset sp, PT_R3 - st.d zero, sp, PT_R0 + # Note it will be set in do_syscall regs->regs[0] = 0; + # st.d zero, sp, PT_R0 csrrd t2, LOONGARCH_CSR_PRMD st.d t2, sp, PT_PRMD csrrd t2, LOONGARCH_CSR_CRMD diff --git a/arch/loongarch/kernel/syscall.c b/arch/loongarch/kernel/syscall.c index b4c5acd7aa3b3..846a5777b8e57 100644 --- a/arch/loongarch/kernel/syscall.c +++ b/arch/loongarch/kernel/syscall.c @@ -44,6 +44,8 @@ void noinstr do_syscall(struct pt_regs *regs) sys_call_fn syscall_fn; nr = regs->regs[11]; + // Move from handle_syscall macro to save a memio + regs->regs[0] = 0; /* Set for syscall restarting */ if (nr < NR_syscalls) regs->regs[0] = nr + 1;