getuser.S 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*
  2. * __get_user functions.
  3. *
  4. * (C) Copyright 1998 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. * __get_user_X
  14. *
  15. * Inputs: %eax contains the address
  16. *
  17. * Outputs: %eax is error code (0 or -EFAULT)
  18. * %edx contains zero-extended value
  19. *
  20. * These functions should not modify any other registers,
  21. * as they get called from within inline assembly.
  22. */
  23. .text
  24. .align 4
  25. .globl __get_user_1
  26. __get_user_1:
  27. GET_THREAD_INFO(%edx)
  28. cmpl TI_addr_limit(%edx),%eax
  29. jae bad_get_user
  30. 1: movzbl (%eax),%edx
  31. xorl %eax,%eax
  32. ret
  33. .align 4
  34. .globl __get_user_2
  35. __get_user_2:
  36. addl $1,%eax
  37. jc bad_get_user
  38. GET_THREAD_INFO(%edx)
  39. cmpl TI_addr_limit(%edx),%eax
  40. jae bad_get_user
  41. 2: movzwl -1(%eax),%edx
  42. xorl %eax,%eax
  43. ret
  44. .align 4
  45. .globl __get_user_4
  46. __get_user_4:
  47. addl $3,%eax
  48. jc bad_get_user
  49. GET_THREAD_INFO(%edx)
  50. cmpl TI_addr_limit(%edx),%eax
  51. jae bad_get_user
  52. 3: movl -3(%eax),%edx
  53. xorl %eax,%eax
  54. ret
  55. bad_get_user:
  56. xorl %edx,%edx
  57. movl $-14,%eax
  58. ret
  59. .section __ex_table,"a"
  60. .long 1b,bad_get_user
  61. .long 2b,bad_get_user
  62. .long 3b,bad_get_user
  63. .previous