putuser.S 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 <asm/thread_info.h>
  12. /*
  13. * __put_user_X
  14. *
  15. * Inputs: %eax[:%edx] contains the data
  16. * %ecx contains the address
  17. *
  18. * Outputs: %eax is error code (0 or -EFAULT)
  19. *
  20. * These functions should not modify any other registers,
  21. * as they get called from within inline assembly.
  22. */
  23. #define ENTER pushl %ebx ; GET_THREAD_INFO(%ebx)
  24. #define EXIT popl %ebx ; ret
  25. .text
  26. .align 4
  27. .globl __put_user_1
  28. __put_user_1:
  29. ENTER
  30. cmpl TI_addr_limit(%ebx),%ecx
  31. jae bad_put_user
  32. 1: movb %al,(%ecx)
  33. xorl %eax,%eax
  34. EXIT
  35. .align 4
  36. .globl __put_user_2
  37. __put_user_2:
  38. ENTER
  39. movl TI_addr_limit(%ebx),%ebx
  40. subl $1,%ebx
  41. cmpl %ebx,%ecx
  42. jae bad_put_user
  43. 2: movw %ax,(%ecx)
  44. xorl %eax,%eax
  45. EXIT
  46. .align 4
  47. .globl __put_user_4
  48. __put_user_4:
  49. ENTER
  50. movl TI_addr_limit(%ebx),%ebx
  51. subl $3,%ebx
  52. cmpl %ebx,%ecx
  53. jae bad_put_user
  54. 3: movl %eax,(%ecx)
  55. xorl %eax,%eax
  56. EXIT
  57. .align 4
  58. .globl __put_user_8
  59. __put_user_8:
  60. ENTER
  61. movl TI_addr_limit(%ebx),%ebx
  62. subl $7,%ebx
  63. cmpl %ebx,%ecx
  64. jae bad_put_user
  65. 4: movl %eax,(%ecx)
  66. 5: movl %edx,4(%ecx)
  67. xorl %eax,%eax
  68. EXIT
  69. bad_put_user:
  70. movl $-14,%eax
  71. EXIT
  72. .section __ex_table,"a"
  73. .long 1b,bad_put_user
  74. .long 2b,bad_put_user
  75. .long 3b,bad_put_user
  76. .long 4b,bad_put_user
  77. .long 5b,bad_put_user
  78. .previous