getuser_64.S 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. /*
  2. * __get_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. * __get_user_X
  14. *
  15. * Inputs: %rcx contains the address.
  16. * The register is modified, but all changes are undone
  17. * before returning because the C code doesn't know about it.
  18. *
  19. * Outputs: %rax is error code (0 or -EFAULT)
  20. * %rdx contains zero-extended value
  21. *
  22. * %r8 is destroyed.
  23. *
  24. * These functions should not modify any other registers,
  25. * as they get called from within inline assembly.
  26. */
  27. #include <linux/linkage.h>
  28. #include <asm/dwarf2.h>
  29. #include <asm/page.h>
  30. #include <asm/errno.h>
  31. #include <asm/asm-offsets.h>
  32. #include <asm/thread_info.h>
  33. .text
  34. ENTRY(__get_user_1)
  35. CFI_STARTPROC
  36. GET_THREAD_INFO(%r8)
  37. cmpq threadinfo_addr_limit(%r8),%rcx
  38. jae bad_get_user
  39. 1: movzb (%rcx),%edx
  40. xorl %eax,%eax
  41. ret
  42. CFI_ENDPROC
  43. ENDPROC(__get_user_1)
  44. ENTRY(__get_user_2)
  45. CFI_STARTPROC
  46. GET_THREAD_INFO(%r8)
  47. addq $1,%rcx
  48. jc 20f
  49. cmpq threadinfo_addr_limit(%r8),%rcx
  50. jae 20f
  51. decq %rcx
  52. 2: movzwl (%rcx),%edx
  53. xorl %eax,%eax
  54. ret
  55. 20: decq %rcx
  56. jmp bad_get_user
  57. CFI_ENDPROC
  58. ENDPROC(__get_user_2)
  59. ENTRY(__get_user_4)
  60. CFI_STARTPROC
  61. GET_THREAD_INFO(%r8)
  62. addq $3,%rcx
  63. jc 30f
  64. cmpq threadinfo_addr_limit(%r8),%rcx
  65. jae 30f
  66. subq $3,%rcx
  67. 3: movl (%rcx),%edx
  68. xorl %eax,%eax
  69. ret
  70. 30: subq $3,%rcx
  71. jmp bad_get_user
  72. CFI_ENDPROC
  73. ENDPROC(__get_user_4)
  74. ENTRY(__get_user_8)
  75. CFI_STARTPROC
  76. GET_THREAD_INFO(%r8)
  77. addq $7,%rcx
  78. jc 40f
  79. cmpq threadinfo_addr_limit(%r8),%rcx
  80. jae 40f
  81. subq $7,%rcx
  82. 4: movq (%rcx),%rdx
  83. xorl %eax,%eax
  84. ret
  85. 40: subq $7,%rcx
  86. jmp bad_get_user
  87. CFI_ENDPROC
  88. ENDPROC(__get_user_8)
  89. bad_get_user:
  90. CFI_STARTPROC
  91. xorl %edx,%edx
  92. movq $(-EFAULT),%rax
  93. ret
  94. CFI_ENDPROC
  95. END(bad_get_user)
  96. .section __ex_table,"a"
  97. .quad 1b,bad_get_user
  98. .quad 2b,bad_get_user
  99. .quad 3b,bad_get_user
  100. .quad 4b,bad_get_user
  101. .previous