scall64-n32.S 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 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/thread_info.h>
  18. #include <asm/unistd.h>
  19. #ifndef CONFIG_MIPS32_O32
  20. /* No O32, so define handle_sys here */
  21. #define handle_sysn32 handle_sys
  22. #endif
  23. .align 5
  24. NESTED(handle_sysn32, PT_SIZE, sp)
  25. #ifndef CONFIG_MIPS32_O32
  26. .set noat
  27. SAVE_SOME
  28. TRACE_IRQS_ON_RELOAD
  29. STI
  30. .set at
  31. #endif
  32. dsubu t0, v0, __NR_N32_Linux # check syscall number
  33. sltiu t0, t0, __NR_N32_Linux_syscalls
  34. #ifndef CONFIG_MIPS32_O32
  35. ld t1, PT_EPC(sp) # skip syscall on return
  36. daddiu t1, 4 # skip to next instruction
  37. sd t1, PT_EPC(sp)
  38. #endif
  39. beqz t0, not_n32_scall
  40. sd a3, PT_R26(sp) # save a3 for syscall restarting
  41. li t1, _TIF_WORK_SYSCALL_ENTRY
  42. LONG_L t0, TI_FLAGS($28) # syscall tracing enabled?
  43. and t0, t1, t0
  44. bnez t0, n32_syscall_trace_entry
  45. syscall_common:
  46. dsll t0, v0, 3 # offset into table
  47. ld t2, (sysn32_call_table - (__NR_N32_Linux * 8))(t0)
  48. jalr t2 # Do The Real Thing (TM)
  49. li t0, -EMAXERRNO - 1 # error?
  50. sltu t0, t0, v0
  51. sd t0, PT_R7(sp) # set error flag
  52. beqz t0, 1f
  53. ld t1, PT_R2(sp) # syscall number
  54. dnegu v0 # error
  55. sd t1, PT_R0(sp) # save it for syscall restarting
  56. 1: sd v0, PT_R2(sp) # result
  57. j syscall_exit_partial
  58. /* ------------------------------------------------------------------------ */
  59. n32_syscall_trace_entry:
  60. SAVE_STATIC
  61. move a0, sp
  62. move a1, v0
  63. jal syscall_trace_enter
  64. bltz v0, 1f # seccomp failed? Skip syscall
  65. RESTORE_STATIC
  66. ld v0, PT_R2(sp) # Restore syscall (maybe modified)
  67. ld a0, PT_R4(sp) # Restore argument registers
  68. ld a1, PT_R5(sp)
  69. ld a2, PT_R6(sp)
  70. ld a3, PT_R7(sp)
  71. ld a4, PT_R8(sp)
  72. ld a5, PT_R9(sp)
  73. dsubu t2, v0, __NR_N32_Linux # check (new) syscall number
  74. sltiu t0, t2, __NR_N32_Linux_syscalls
  75. beqz t0, not_n32_scall
  76. j syscall_common
  77. 1: j syscall_exit
  78. not_n32_scall:
  79. /* This is not an n32 compatibility syscall, pass it on to
  80. the n64 syscall handlers. */
  81. j handle_sys64
  82. END(handle_sysn32)
  83. #define __SYSCALL(nr, entry) PTR_WD entry
  84. .type sysn32_call_table, @object
  85. EXPORT(sysn32_call_table)
  86. #include <asm/syscall_table_n32.h>