putuser_32.S 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. pushl %ebx ; \
  27. CFI_ADJUST_CFA_OFFSET 4 ; \
  28. CFI_REL_OFFSET ebx, 0 ; \
  29. GET_THREAD_INFO(%ebx)
  30. #define EXIT popl %ebx ; \
  31. CFI_ADJUST_CFA_OFFSET -4 ; \
  32. CFI_RESTORE ebx ; \
  33. ret ; \
  34. CFI_ENDPROC
  35. .text
  36. ENTRY(__put_user_1)
  37. ENTER
  38. cmpl TI_addr_limit(%ebx),%ecx
  39. jae bad_put_user
  40. 1: movb %al,(%ecx)
  41. xorl %eax,%eax
  42. EXIT
  43. ENDPROC(__put_user_1)
  44. ENTRY(__put_user_2)
  45. ENTER
  46. movl TI_addr_limit(%ebx),%ebx
  47. subl $1,%ebx
  48. cmpl %ebx,%ecx
  49. jae bad_put_user
  50. 2: movw %ax,(%ecx)
  51. xorl %eax,%eax
  52. EXIT
  53. ENDPROC(__put_user_2)
  54. ENTRY(__put_user_4)
  55. ENTER
  56. movl TI_addr_limit(%ebx),%ebx
  57. subl $3,%ebx
  58. cmpl %ebx,%ecx
  59. jae bad_put_user
  60. 3: movl %eax,(%ecx)
  61. xorl %eax,%eax
  62. EXIT
  63. ENDPROC(__put_user_4)
  64. ENTRY(__put_user_8)
  65. ENTER
  66. movl TI_addr_limit(%ebx),%ebx
  67. subl $7,%ebx
  68. cmpl %ebx,%ecx
  69. jae bad_put_user
  70. 4: movl %eax,(%ecx)
  71. 5: movl %edx,4(%ecx)
  72. xorl %eax,%eax
  73. EXIT
  74. ENDPROC(__put_user_8)
  75. bad_put_user:
  76. CFI_STARTPROC simple
  77. CFI_DEF_CFA esp, 2*4
  78. CFI_OFFSET eip, -1*4
  79. CFI_OFFSET ebx, -2*4
  80. movl $-14,%eax
  81. EXIT
  82. END(bad_put_user)
  83. .section __ex_table,"a"
  84. .long 1b,bad_put_user
  85. .long 2b,bad_put_user
  86. .long 3b,bad_put_user
  87. .long 4b,bad_put_user
  88. .long 5b,bad_put_user
  89. .previous