putuser_32.S 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * __put_user functions.
  3. *
  4. * (C) Copyright 2005 Linus Torvalds
  5. *
  6. * These functions have a non-standard call interface
  7. * to make them more efficient, especially as they
  8. * return an error value in addition to the "real"
  9. * return value.
  10. */
  11. #include <linux/linkage.h>
  12. #include <asm/dwarf2.h>
  13. #include <asm/thread_info.h>
  14. /*
  15. * __put_user_X
  16. *
  17. * Inputs: %eax[:%edx] contains the data
  18. * %ecx contains the address
  19. *
  20. * Outputs: %eax is error code (0 or -EFAULT)
  21. *
  22. * These functions should not modify any other registers,
  23. * as they get called from within inline assembly.
  24. */
  25. #define ENTER CFI_STARTPROC ; \
  26. GET_THREAD_INFO(%ebx)
  27. #define EXIT ret ; \
  28. CFI_ENDPROC
  29. .text
  30. ENTRY(__put_user_1)
  31. ENTER
  32. cmp TI_addr_limit(%ebx),%ecx
  33. jae bad_put_user
  34. 1: movb %al,(%ecx)
  35. xor %eax,%eax
  36. EXIT
  37. ENDPROC(__put_user_1)
  38. ENTRY(__put_user_2)
  39. ENTER
  40. mov TI_addr_limit(%ebx),%ebx
  41. sub $1,%ebx
  42. cmp %ebx,%ecx
  43. jae bad_put_user
  44. 2: movw %ax,(%ecx)
  45. xor %eax,%eax
  46. EXIT
  47. ENDPROC(__put_user_2)
  48. ENTRY(__put_user_4)
  49. ENTER
  50. mov TI_addr_limit(%ebx),%ebx
  51. sub $3,%ebx
  52. cmp %ebx,%ecx
  53. jae bad_put_user
  54. 3: movl %eax,(%ecx)
  55. xor %eax,%eax
  56. EXIT
  57. ENDPROC(__put_user_4)
  58. ENTRY(__put_user_8)
  59. ENTER
  60. mov TI_addr_limit(%ebx),%ebx
  61. sub $7,%ebx
  62. cmp %ebx,%ecx
  63. jae bad_put_user
  64. 4: movl %eax,(%ecx)
  65. 5: movl %edx,4(%ecx)
  66. xor %eax,%eax
  67. EXIT
  68. ENDPROC(__put_user_8)
  69. bad_put_user:
  70. CFI_STARTPROC
  71. movl $-14,%eax
  72. EXIT
  73. END(bad_put_user)
  74. .section __ex_table,"a"
  75. .long 1b,bad_put_user
  76. .long 2b,bad_put_user
  77. .long 3b,bad_put_user
  78. .long 4b,bad_put_user
  79. .long 5b,bad_put_user
  80. .previous