putuser.S 1.8 KB

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