1 /* 1 /* 2 * This file is subject to the terms and condi 2 * This file is subject to the terms and conditions of the GNU General Public 3 * License. See the file "COPYING" in the mai 3 * License. See the file "COPYING" in the main directory of this archive 4 * for more details. 4 * for more details. 5 * 5 * 6 * Copyright (C) 1995, 96, 97, 98, 99, 2000, 0 6 * Copyright (C) 1995, 96, 97, 98, 99, 2000, 01, 02 by Ralf Baechle 7 * Copyright (C) 1999, 2000 Silicon Graphics, 7 * Copyright (C) 1999, 2000 Silicon Graphics, Inc. 8 * Copyright (C) 2001 MIPS Technologies, Inc. 8 * Copyright (C) 2001 MIPS Technologies, Inc. 9 */ 9 */ 10 #include <linux/errno.h> 10 #include <linux/errno.h> 11 #include <asm/asm.h> 11 #include <asm/asm.h> 12 #include <asm/asmmacro.h> 12 #include <asm/asmmacro.h> 13 #include <asm/irqflags.h> 13 #include <asm/irqflags.h> 14 #include <asm/mipsregs.h> 14 #include <asm/mipsregs.h> 15 #include <asm/regdef.h> 15 #include <asm/regdef.h> 16 #include <asm/stackframe.h> 16 #include <asm/stackframe.h> 17 #include <asm/asm-offsets.h> 17 #include <asm/asm-offsets.h> 18 #include <asm/sysmips.h> 18 #include <asm/sysmips.h> 19 #include <asm/thread_info.h> 19 #include <asm/thread_info.h> 20 #include <asm/unistd.h> 20 #include <asm/unistd.h> >> 21 #include <asm/war.h> 21 22 22 #ifndef CONFIG_MIPS32_COMPAT !! 23 #ifndef CONFIG_BINFMT_ELF32 23 /* Neither O32 nor N32, so define handle_sys h 24 /* Neither O32 nor N32, so define handle_sys here */ 24 #define handle_sys64 handle_sys 25 #define handle_sys64 handle_sys 25 #endif 26 #endif 26 27 27 .align 5 28 .align 5 28 NESTED(handle_sys64, PT_SIZE, sp) 29 NESTED(handle_sys64, PT_SIZE, sp) 29 #if !defined(CONFIG_MIPS32_O32) && !defined(CO 30 #if !defined(CONFIG_MIPS32_O32) && !defined(CONFIG_MIPS32_N32) 30 /* 31 /* 31 * When 32-bit compatibility is config 32 * When 32-bit compatibility is configured scall_o32.S 32 * already did this. 33 * already did this. 33 */ 34 */ 34 .set noat 35 .set noat 35 SAVE_SOME 36 SAVE_SOME 36 TRACE_IRQS_ON_RELOAD 37 TRACE_IRQS_ON_RELOAD 37 STI 38 STI 38 .set at 39 .set at 39 #endif 40 #endif 40 41 41 #if !defined(CONFIG_MIPS32_O32) && !defined(CO 42 #if !defined(CONFIG_MIPS32_O32) && !defined(CONFIG_MIPS32_N32) 42 ld t1, PT_EPC(sp) # skip 43 ld t1, PT_EPC(sp) # skip syscall on return 43 daddiu t1, 4 # skip 44 daddiu t1, 4 # skip to next instruction 44 sd t1, PT_EPC(sp) 45 sd t1, PT_EPC(sp) 45 #endif 46 #endif 46 47 47 sd a3, PT_R26(sp) # save 48 sd a3, PT_R26(sp) # save a3 for syscall restarting 48 49 49 LONG_S v0, TI_SYSCALL($28) # Stor << 50 << 51 li t1, _TIF_WORK_SYSCALL_ENTRY 50 li t1, _TIF_WORK_SYSCALL_ENTRY 52 LONG_L t0, TI_FLAGS($28) # sysc 51 LONG_L t0, TI_FLAGS($28) # syscall tracing enabled? 53 and t0, t1, t0 52 and t0, t1, t0 54 bnez t0, syscall_trace_entry 53 bnez t0, syscall_trace_entry 55 54 56 syscall_common: 55 syscall_common: 57 dsubu t2, v0, __NR_64_Linux 56 dsubu t2, v0, __NR_64_Linux 58 sltiu t0, t2, __NR_64_Linux_syscalls 57 sltiu t0, t2, __NR_64_Linux_syscalls 59 beqz t0, illegal_syscall 58 beqz t0, illegal_syscall 60 59 61 dsll t0, t2, 3 # offs 60 dsll t0, t2, 3 # offset into table 62 dla t2, sys_call_table 61 dla t2, sys_call_table 63 daddu t0, t2, t0 62 daddu t0, t2, t0 64 ld t2, (t0) # sysc 63 ld t2, (t0) # syscall routine 65 beqz t2, illegal_syscall 64 beqz t2, illegal_syscall 66 65 67 jalr t2 # Do T 66 jalr t2 # Do The Real Thing (TM) 68 67 69 li t0, -EMAXERRNO - 1 # erro 68 li t0, -EMAXERRNO - 1 # error? 70 sltu t0, t0, v0 69 sltu t0, t0, v0 71 sd t0, PT_R7(sp) # set 70 sd t0, PT_R7(sp) # set error flag 72 beqz t0, 1f 71 beqz t0, 1f 73 72 74 ld t1, PT_R2(sp) # sysc 73 ld t1, PT_R2(sp) # syscall number 75 dnegu v0 # erro 74 dnegu v0 # error 76 sd t1, PT_R0(sp) # save 75 sd t1, PT_R0(sp) # save it for syscall restarting 77 1: sd v0, PT_R2(sp) # resu 76 1: sd v0, PT_R2(sp) # result 78 77 79 n64_syscall_exit: 78 n64_syscall_exit: 80 j syscall_exit_partial 79 j syscall_exit_partial 81 80 82 /* ------------------------------------------- 81 /* ------------------------------------------------------------------------ */ 83 82 84 syscall_trace_entry: 83 syscall_trace_entry: 85 SAVE_STATIC 84 SAVE_STATIC 86 move a0, sp 85 move a0, sp >> 86 move a1, v0 87 jal syscall_trace_enter 87 jal syscall_trace_enter 88 88 89 bltz v0, 1f # secc 89 bltz v0, 1f # seccomp failed? Skip syscall 90 90 91 RESTORE_STATIC 91 RESTORE_STATIC 92 ld v0, PT_R2(sp) # Rest 92 ld v0, PT_R2(sp) # Restore syscall (maybe modified) 93 ld a0, PT_R4(sp) # Rest 93 ld a0, PT_R4(sp) # Restore argument registers 94 ld a1, PT_R5(sp) 94 ld a1, PT_R5(sp) 95 ld a2, PT_R6(sp) 95 ld a2, PT_R6(sp) 96 ld a3, PT_R7(sp) 96 ld a3, PT_R7(sp) 97 ld a4, PT_R8(sp) 97 ld a4, PT_R8(sp) 98 ld a5, PT_R9(sp) 98 ld a5, PT_R9(sp) 99 j syscall_common 99 j syscall_common 100 100 101 1: j syscall_exit 101 1: j syscall_exit 102 102 103 illegal_syscall: 103 illegal_syscall: 104 /* This also isn't a 64-bit syscall, t 104 /* This also isn't a 64-bit syscall, throw an error. */ 105 li v0, ENOSYS 105 li v0, ENOSYS # error 106 sd v0, PT_R2(sp) 106 sd v0, PT_R2(sp) 107 li t0, 1 107 li t0, 1 # set error flag 108 sd t0, PT_R7(sp) 108 sd t0, PT_R7(sp) 109 j n64_syscall_exit 109 j n64_syscall_exit 110 END(handle_sys64) 110 END(handle_sys64) 111 111 112 #define __SYSCALL(nr, entry) PTR_WD entry !! 112 #define __SYSCALL(nr, entry) PTR entry 113 .align 3 113 .align 3 114 .type sys_call_table, @object 114 .type sys_call_table, @object 115 EXPORT(sys_call_table) 115 EXPORT(sys_call_table) 116 #include <asm/syscall_table_n64.h> !! 116 #include <asm/syscall_table_64_n64.h> >> 117 #undef __SYSCALL
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.