clear_user.S 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * arch/alpha/lib/clear_user.S
  4. * Contributed by Richard Henderson <[email protected]>
  5. *
  6. * Zero user space, handling exceptions as we go.
  7. *
  8. * We have to make sure that $0 is always up-to-date and contains the
  9. * right "bytes left to zero" value (and that it is updated only _after_
  10. * a successful copy). There is also some rather minor exception setup
  11. * stuff.
  12. */
  13. #include <asm/export.h>
  14. /* Allow an exception for an insn; exit if we get one. */
  15. #define EX(x,y...) \
  16. 99: x,##y; \
  17. .section __ex_table,"a"; \
  18. .long 99b - .; \
  19. lda $31, $exception-99b($31); \
  20. .previous
  21. .set noat
  22. .set noreorder
  23. .align 4
  24. .globl __clear_user
  25. .ent __clear_user
  26. .frame $30, 0, $26
  27. .prologue 0
  28. $loop:
  29. and $1, 3, $4 # e0 :
  30. beq $4, 1f # .. e1 :
  31. 0: EX( stq_u $31, 0($16) ) # e0 : zero one word
  32. subq $0, 8, $0 # .. e1 :
  33. subq $4, 1, $4 # e0 :
  34. addq $16, 8, $16 # .. e1 :
  35. bne $4, 0b # e1 :
  36. unop # :
  37. 1: bic $1, 3, $1 # e0 :
  38. beq $1, $tail # .. e1 :
  39. 2: EX( stq_u $31, 0($16) ) # e0 : zero four words
  40. subq $0, 8, $0 # .. e1 :
  41. EX( stq_u $31, 8($16) ) # e0 :
  42. subq $0, 8, $0 # .. e1 :
  43. EX( stq_u $31, 16($16) ) # e0 :
  44. subq $0, 8, $0 # .. e1 :
  45. EX( stq_u $31, 24($16) ) # e0 :
  46. subq $0, 8, $0 # .. e1 :
  47. subq $1, 4, $1 # e0 :
  48. addq $16, 32, $16 # .. e1 :
  49. bne $1, 2b # e1 :
  50. $tail:
  51. bne $2, 1f # e1 : is there a tail to do?
  52. ret $31, ($26), 1 # .. e1 :
  53. 1: EX( ldq_u $5, 0($16) ) # e0 :
  54. clr $0 # .. e1 :
  55. nop # e1 :
  56. mskqh $5, $0, $5 # e0 :
  57. EX( stq_u $5, 0($16) ) # e0 :
  58. ret $31, ($26), 1 # .. e1 :
  59. __clear_user:
  60. and $17, $17, $0
  61. and $16, 7, $4 # e0 : find dest misalignment
  62. beq $0, $zerolength # .. e1 :
  63. addq $0, $4, $1 # e0 : bias counter
  64. and $1, 7, $2 # e1 : number of bytes in tail
  65. srl $1, 3, $1 # e0 :
  66. beq $4, $loop # .. e1 :
  67. EX( ldq_u $5, 0($16) ) # e0 : load dst word to mask back in
  68. beq $1, $oneword # .. e1 : sub-word store?
  69. mskql $5, $16, $5 # e0 : take care of misaligned head
  70. addq $16, 8, $16 # .. e1 :
  71. EX( stq_u $5, -8($16) ) # e0 :
  72. addq $0, $4, $0 # .. e1 : bytes left -= 8 - misalignment
  73. subq $1, 1, $1 # e0 :
  74. subq $0, 8, $0 # .. e1 :
  75. br $loop # e1 :
  76. unop # :
  77. $oneword:
  78. mskql $5, $16, $4 # e0 :
  79. mskqh $5, $2, $5 # e0 :
  80. or $5, $4, $5 # e1 :
  81. EX( stq_u $5, 0($16) ) # e0 :
  82. clr $0 # .. e1 :
  83. $zerolength:
  84. $exception:
  85. ret $31, ($26), 1 # .. e1 :
  86. .end __clear_user
  87. EXPORT_SYMBOL(__clear_user)