putuser_64.S 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. #define ENTER CFI_STARTPROC ; \
  32. GET_THREAD_INFO(%rbx)
  33. #define EXIT ret ; \
  34. CFI_ENDPROC
  35. .text
  36. ENTRY(__put_user_1)
  37. ENTER
  38. cmp TI_addr_limit(%rbx),%rcx
  39. jae bad_put_user
  40. 1: movb %al,(%rcx)
  41. xor %eax,%eax
  42. EXIT
  43. ENDPROC(__put_user_1)
  44. ENTRY(__put_user_2)
  45. ENTER
  46. mov TI_addr_limit(%rbx),%rbx
  47. sub $1, %rbx
  48. cmp %rbx ,%rcx
  49. jae bad_put_user
  50. 2: movw %ax,(%rcx)
  51. xor %eax,%eax
  52. EXIT
  53. ENDPROC(__put_user_2)
  54. ENTRY(__put_user_4)
  55. ENTER
  56. mov TI_addr_limit(%rbx),%rbx
  57. sub $3, %rbx
  58. cmp %rbx, %rcx
  59. jae bad_put_user
  60. 3: movl %eax,(%rcx)
  61. xor %eax,%eax
  62. EXIT
  63. ENDPROC(__put_user_4)
  64. ENTRY(__put_user_8)
  65. ENTER
  66. mov TI_addr_limit(%rbx),%rbx
  67. sub $7, %rbx
  68. cmp %rbx, %rcx
  69. jae bad_put_user
  70. 4: movq %rax,(%rcx)
  71. xor %eax,%eax
  72. EXIT
  73. ENDPROC(__put_user_8)
  74. bad_put_user:
  75. CFI_STARTPROC
  76. mov $(-EFAULT),%rax
  77. EXIT
  78. END(bad_put_user)
  79. .section __ex_table,"a"
  80. .quad 1b,bad_put_user
  81. .quad 2b,bad_put_user
  82. .quad 3b,bad_put_user
  83. .quad 4b,bad_put_user
  84. .previous