copy_user.S 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * arch/alpha/lib/copy_user.S
  4. *
  5. * Copy to/from user space, handling exceptions as we go.. This
  6. * isn't exactly pretty.
  7. *
  8. * This is essentially the same as "memcpy()", but with a few twists.
  9. * Notably, we have to make sure that $0 is always up-to-date and
  10. * contains the right "bytes left to copy" value (and that it is updated
  11. * only _after_ a successful copy). There is also some rather minor
  12. * exception setup stuff..
  13. */
  14. #include <asm/export.h>
  15. /* Allow an exception for an insn; exit if we get one. */
  16. #define EXI(x,y...) \
  17. 99: x,##y; \
  18. .section __ex_table,"a"; \
  19. .long 99b - .; \
  20. lda $31, $exitin-99b($31); \
  21. .previous
  22. #define EXO(x,y...) \
  23. 99: x,##y; \
  24. .section __ex_table,"a"; \
  25. .long 99b - .; \
  26. lda $31, $exitout-99b($31); \
  27. .previous
  28. .set noat
  29. .align 4
  30. .globl __copy_user
  31. .ent __copy_user
  32. __copy_user:
  33. .prologue 0
  34. mov $18,$0
  35. and $16,7,$3
  36. beq $0,$35
  37. beq $3,$36
  38. subq $3,8,$3
  39. .align 4
  40. $37:
  41. EXI( ldq_u $1,0($17) )
  42. EXO( ldq_u $2,0($16) )
  43. extbl $1,$17,$1
  44. mskbl $2,$16,$2
  45. insbl $1,$16,$1
  46. addq $3,1,$3
  47. bis $1,$2,$1
  48. EXO( stq_u $1,0($16) )
  49. subq $0,1,$0
  50. addq $16,1,$16
  51. addq $17,1,$17
  52. beq $0,$41
  53. bne $3,$37
  54. $36:
  55. and $17,7,$1
  56. bic $0,7,$4
  57. beq $1,$43
  58. beq $4,$48
  59. EXI( ldq_u $3,0($17) )
  60. .align 4
  61. $50:
  62. EXI( ldq_u $2,8($17) )
  63. subq $4,8,$4
  64. extql $3,$17,$3
  65. extqh $2,$17,$1
  66. bis $3,$1,$1
  67. EXO( stq $1,0($16) )
  68. addq $17,8,$17
  69. subq $0,8,$0
  70. addq $16,8,$16
  71. bis $2,$2,$3
  72. bne $4,$50
  73. $48:
  74. beq $0,$41
  75. .align 4
  76. $57:
  77. EXI( ldq_u $1,0($17) )
  78. EXO( ldq_u $2,0($16) )
  79. extbl $1,$17,$1
  80. mskbl $2,$16,$2
  81. insbl $1,$16,$1
  82. bis $1,$2,$1
  83. EXO( stq_u $1,0($16) )
  84. subq $0,1,$0
  85. addq $16,1,$16
  86. addq $17,1,$17
  87. bne $0,$57
  88. br $31,$41
  89. .align 4
  90. $43:
  91. beq $4,$65
  92. .align 4
  93. $66:
  94. EXI( ldq $1,0($17) )
  95. subq $4,8,$4
  96. EXO( stq $1,0($16) )
  97. addq $17,8,$17
  98. subq $0,8,$0
  99. addq $16,8,$16
  100. bne $4,$66
  101. $65:
  102. beq $0,$41
  103. EXI( ldq $2,0($17) )
  104. EXO( ldq $1,0($16) )
  105. mskql $2,$0,$2
  106. mskqh $1,$0,$1
  107. bis $2,$1,$2
  108. EXO( stq $2,0($16) )
  109. bis $31,$31,$0
  110. $41:
  111. $35:
  112. $exitin:
  113. $exitout:
  114. ret $31,($26),1
  115. .end __copy_user
  116. EXPORT_SYMBOL(__copy_user)