putuser_64.S 1.8 KB

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