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

Linux/Unix编程

开发平台:

Unix_Linux

  1. /*
  2.  * __put_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.
  8.  */
  9. /*
  10.  * __put_user_X
  11.  *
  12.  * Inputs: %rax contains the address
  13.  * %rdx contains the value
  14.  *
  15.  * Outputs: %rax is error code (0 or -EFAULT)
  16.  * %rbx is corrupted (will contain "current_task").
  17.  *
  18.  * These functions should not modify any other registers,
  19.  * as they get called from within inline assembly.
  20.  */
  21. /* FIXME: putuser.S should be really merged with getuser.S, and preprocessor should be used to keep code duplication lower */
  22. #include <linux/linkage.h>
  23. #include <asm/page.h>
  24. #include <asm/errno.h>
  25. #include <asm/current.h>
  26. #include <asm/offset.h>
  27. .text
  28. .p2align
  29. .globl __put_user_1
  30. __put_user_1:
  31. GET_CURRENT(%rbx)
  32. cmpq tsk_addr_limit(%rbx),%rax
  33. jae bad_put_user
  34. 1: movb %dl,(%rax)
  35. xorq %rax,%rax
  36. ret
  37. .p2align
  38. .globl __put_user_2
  39. __put_user_2:
  40. GET_CURRENT(%rbx) 
  41. addq $1,%rax
  42. jc bad_put_user
  43. cmpq tsk_addr_limit(%rbx),%rax
  44. jae  bad_put_user
  45. 2: movw %dx,-1(%rax)
  46. xorq %rax,%rax
  47. ret
  48. .p2align
  49. .globl __put_user_4
  50. __put_user_4:
  51. GET_CURRENT(%rbx) 
  52. addq $3,%rax
  53. jc bad_put_user
  54. cmpq tsk_addr_limit(%rbx),%rax
  55. jae  bad_put_user
  56. 3: movl %edx,-3(%rax)
  57. xorq %rax,%rax
  58. ret
  59. .p2align
  60. .globl __put_user_8
  61. __put_user_8:
  62. GET_CURRENT(%rbx) 
  63. addq $7,%rax
  64. jc bad_put_user
  65. cmpq tsk_addr_limit(%rbx),%rax
  66. jae  bad_put_user
  67. 4: movq %rdx,-7(%rax)
  68. xorq %rax,%rax
  69. ret
  70. ENTRY(bad_put_user)
  71. bad_put_user:
  72. movq $(-EFAULT),%rax
  73. ret
  74. .section __ex_table,"a"
  75. .quad 1b,bad_put_user
  76. .quad 2b,bad_put_user
  77. .quad 3b,bad_put_user
  78. .quad 4b,bad_put_user
  79. .previous