getuser.S
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:2k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  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. /*
  12.  * __get_user_X
  13.  *
  14.  * Inputs: %rax contains the address
  15.  *
  16.  * Outputs: %rax is error code (0 or -EFAULT)
  17.  * %rdx contains zero-extended value
  18.  * 
  19.  * %rbx is destroyed.
  20.  *
  21.  * These functions should not modify any other registers,
  22.  * as they get called from within inline assembly.
  23.  */
  24. #include <linux/linkage.h>
  25. #include <asm/page.h>
  26. #include <asm/errno.h>
  27. #include <asm/current.h>
  28. #include <asm/offset.h>
  29. #include <asm/calling.h>
  30. .text
  31. .p2align
  32. .globl __get_user_1
  33. __get_user_1:
  34. GET_CURRENT(%rbx)
  35. cmpq tsk_addr_limit(%rbx),%rax
  36. jae bad_get_user
  37. 1: movzb (%rax),%edx
  38. xorq %rax,%rax
  39. ret
  40. .p2align
  41. .globl __get_user_2
  42. __get_user_2:
  43. GET_CURRENT(%rbx) 
  44. addq $1,%rax
  45. jc bad_get_user
  46. cmpq tsk_addr_limit(%rbx),%rax 
  47. jae  bad_get_user
  48. 2: movzwl -1(%rax),%edx
  49. xorq %rax,%rax
  50. ret
  51. .p2align
  52. .globl __get_user_4
  53. __get_user_4:
  54. GET_CURRENT(%rbx) 
  55. addq $3,%rax
  56. jc bad_get_user
  57. cmpq tsk_addr_limit(%rbx),%rax 
  58. jae bad_get_user
  59. 3: movl -3(%rax),%edx
  60. xorq %rax,%rax
  61. ret
  62. .p2align
  63. .globl __get_user_8
  64. __get_user_8:
  65. GET_CURRENT(%rbx) 
  66. addq $7,%rax
  67. jc bad_get_user
  68. cmpq tsk_addr_limit(%rbx),%rax
  69. jae bad_get_user
  70. 4: movq -7(%rax),%rdx
  71. xorq %rax,%rax
  72. ret
  73. ENTRY(bad_get_user)
  74. bad_get_user:
  75. xorq %rdx,%rdx
  76. movq $(-EFAULT),%rax
  77. ret
  78. .section __ex_table,"a"
  79. .quad 1b,bad_get_user
  80. .quad 2b,bad_get_user
  81. .quad 3b,bad_get_user
  82. .quad 4b,bad_get_user
  83. .previous