2005-04-17 06:20:36 +08:00
|
|
|
/*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1995, 96, 97, 98, 99, 2000, 01 by Ralf Baechle
|
|
|
|
* Copyright (C) 1999, 2000 Silicon Graphics, Inc.
|
|
|
|
* Copyright (C) 2001 MIPS Technologies, Inc.
|
|
|
|
*/
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <asm/asm.h>
|
|
|
|
#include <asm/asmmacro.h>
|
2006-07-07 21:07:18 +08:00
|
|
|
#include <asm/irqflags.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
#include <asm/mipsregs.h>
|
|
|
|
#include <asm/regdef.h>
|
|
|
|
#include <asm/stackframe.h>
|
|
|
|
#include <asm/thread_info.h>
|
|
|
|
#include <asm/unistd.h>
|
|
|
|
|
|
|
|
#ifndef CONFIG_MIPS32_O32
|
|
|
|
/* No O32, so define handle_sys here */
|
|
|
|
#define handle_sysn32 handle_sys
|
|
|
|
#endif
|
|
|
|
|
2013-01-22 19:59:30 +08:00
|
|
|
.align 5
|
2005-04-17 06:20:36 +08:00
|
|
|
NESTED(handle_sysn32, PT_SIZE, sp)
|
|
|
|
#ifndef CONFIG_MIPS32_O32
|
|
|
|
.set noat
|
|
|
|
SAVE_SOME
|
2006-09-26 22:43:40 +08:00
|
|
|
TRACE_IRQS_ON_RELOAD
|
2005-04-17 06:20:36 +08:00
|
|
|
STI
|
|
|
|
.set at
|
|
|
|
#endif
|
|
|
|
|
|
|
|
dsubu t0, v0, __NR_N32_Linux # check syscall number
|
2018-12-13 17:07:36 +08:00
|
|
|
sltiu t0, t0, __NR_N32_Linux_syscalls
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
#ifndef CONFIG_MIPS32_O32
|
|
|
|
ld t1, PT_EPC(sp) # skip syscall on return
|
|
|
|
daddiu t1, 4 # skip to next instruction
|
|
|
|
sd t1, PT_EPC(sp)
|
|
|
|
#endif
|
|
|
|
beqz t0, not_n32_scall
|
|
|
|
|
|
|
|
sd a3, PT_R26(sp) # save a3 for syscall restarting
|
|
|
|
|
2013-05-29 07:02:18 +08:00
|
|
|
li t1, _TIF_WORK_SYSCALL_ENTRY
|
2005-04-17 06:20:36 +08:00
|
|
|
LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
|
|
|
|
and t0, t1, t0
|
|
|
|
bnez t0, n32_syscall_trace_entry
|
|
|
|
|
2015-09-25 15:17:42 +08:00
|
|
|
syscall_common:
|
2016-03-29 16:35:31 +08:00
|
|
|
dsll t0, v0, 3 # offset into table
|
|
|
|
ld t2, (sysn32_call_table - (__NR_N32_Linux * 8))(t0)
|
|
|
|
|
2005-04-17 06:20:36 +08:00
|
|
|
jalr t2 # Do The Real Thing (TM)
|
|
|
|
|
|
|
|
li t0, -EMAXERRNO - 1 # error?
|
|
|
|
sltu t0, t0, v0
|
|
|
|
sd t0, PT_R7(sp) # set error flag
|
|
|
|
beqz t0, 1f
|
|
|
|
|
2010-09-29 01:50:37 +08:00
|
|
|
ld t1, PT_R2(sp) # syscall number
|
2005-04-17 06:20:36 +08:00
|
|
|
dnegu v0 # error
|
2010-09-29 01:50:37 +08:00
|
|
|
sd t1, PT_R0(sp) # save it for syscall restarting
|
2005-04-17 06:20:36 +08:00
|
|
|
1: sd v0, PT_R2(sp) # result
|
|
|
|
|
2012-05-06 04:11:35 +08:00
|
|
|
j syscall_exit_partial
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------------ */
|
|
|
|
|
|
|
|
n32_syscall_trace_entry:
|
|
|
|
SAVE_STATIC
|
|
|
|
move a0, sp
|
2015-08-13 15:47:59 +08:00
|
|
|
move a1, v0
|
2011-05-19 16:21:29 +08:00
|
|
|
jal syscall_trace_enter
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2015-09-25 15:17:42 +08:00
|
|
|
bltz v0, 1f # seccomp failed? Skip syscall
|
2014-01-22 22:40:02 +08:00
|
|
|
|
2005-12-01 00:24:57 +08:00
|
|
|
RESTORE_STATIC
|
2016-03-29 16:35:31 +08:00
|
|
|
ld v0, PT_R2(sp) # Restore syscall (maybe modified)
|
2005-04-17 06:20:36 +08:00
|
|
|
ld a0, PT_R4(sp) # Restore argument registers
|
|
|
|
ld a1, PT_R5(sp)
|
|
|
|
ld a2, PT_R6(sp)
|
|
|
|
ld a3, PT_R7(sp)
|
|
|
|
ld a4, PT_R8(sp)
|
|
|
|
ld a5, PT_R9(sp)
|
2016-03-29 16:35:31 +08:00
|
|
|
|
|
|
|
dsubu t2, v0, __NR_N32_Linux # check (new) syscall number
|
2018-12-13 17:07:36 +08:00
|
|
|
sltiu t0, t2, __NR_N32_Linux_syscalls
|
2016-03-29 16:35:31 +08:00
|
|
|
beqz t0, not_n32_scall
|
|
|
|
|
2015-09-25 15:17:42 +08:00
|
|
|
j syscall_common
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2015-09-25 15:17:42 +08:00
|
|
|
1: j syscall_exit
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
not_n32_scall:
|
|
|
|
/* This is not an n32 compatibility syscall, pass it on to
|
|
|
|
the n64 syscall handlers. */
|
|
|
|
j handle_sys64
|
|
|
|
|
|
|
|
END(handle_sysn32)
|
|
|
|
|
2019-01-02 22:56:17 +08:00
|
|
|
#define __SYSCALL(nr, entry) PTR entry
|
2012-07-12 20:02:41 +08:00
|
|
|
.type sysn32_call_table, @object
|
2005-04-17 06:20:36 +08:00
|
|
|
EXPORT(sysn32_call_table)
|
2018-12-13 17:07:39 +08:00
|
|
|
#include <asm/syscall_table_64_n32.h>
|
|
|
|
#undef __SYSCALL
|