1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2020-2022 Loongson Technology Corporation Limited
6 * Copyright (C) 1994 - 2000, 2001, 2003 Ralf Baechle
7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc.
8 * Copyright (C) 2001 MIPS Technologies, Inc.
12 #include <asm/asmmacro.h>
13 #include <asm/loongarch.h>
14 #include <asm/regdef.h>
15 #include <asm/stackframe.h>
16 #include <asm/thread_info.h>
19 .cfi_sections .debug_frame
21 SYM_FUNC_START(handle_syscall)
22 csrrd t0, PERCPU_BASE_KS
28 addi.d sp, sp, -PT_SIZE
30 cfi_rel_offset sp, PT_R3
32 csrrd t2, LOONGARCH_CSR_PRMD
34 csrrd t2, LOONGARCH_CSR_CRMD
36 csrrd t2, LOONGARCH_CSR_EUEN
38 csrrd t2, LOONGARCH_CSR_ECFG
40 csrrd t2, LOONGARCH_CSR_ESTAT
51 csrrd ra, LOONGARCH_CSR_ERA
53 cfi_rel_offset ra, PT_ERA
63 csrxchg t1, t1, LOONGARCH_CSR_CRMD
67 li.d tp, ~_THREAD_MASK
74 SYM_FUNC_END(handle_syscall)
75 _ASM_NOKPROBE(handle_syscall)
77 SYM_CODE_START(ret_from_fork)
78 bl schedule_tail # a0 = struct task_struct *prev
80 bl syscall_exit_to_user_mode
84 SYM_CODE_END(ret_from_fork)
86 SYM_CODE_START(ret_from_kernel_thread)
87 bl schedule_tail # a0 = struct task_struct *prev
91 bl syscall_exit_to_user_mode
95 SYM_CODE_END(ret_from_kernel_thread)