scall64-n64.S 2.7 KB

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