copy_from_user.S 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * User memory copy functions for kernel
  3. *
  4. * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License version 2 and
  8. * only version 2 as published by the Free Software Foundation.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  18. * 02110-1301, USA.
  19. */
  20. /*
  21. * The right way to do this involves valignb
  22. * The easy way to do this is only speed up src/dest similar alignment.
  23. */
  24. /*
  25. * Copy to/from user are the same, except that for packets with a load and
  26. * a store, I don't know how to tell which kind of exception we got.
  27. * Therefore, we duplicate the function, and handle faulting addresses
  28. * differently for each function
  29. */
  30. /*
  31. * copy from user: loads can fault
  32. */
  33. #define src_sav r13
  34. #define dst_sav r12
  35. #define src_dst_sav r13:12
  36. #define d_dbuf r15:14
  37. #define w_dbuf r15
  38. #define dst r0
  39. #define src r1
  40. #define bytes r2
  41. #define loopcount r5
  42. #define FUNCNAME __copy_from_user_hexagon
  43. #include "copy_user_template.S"
  44. /* LOAD FAULTS from COPY_FROM_USER */
  45. /* Alignment loop. r2 has been updated. Return it. */
  46. .falign
  47. 1009:
  48. 2009:
  49. 4009:
  50. {
  51. r0 = r2
  52. jumpr r31
  53. }
  54. /* Normal copy loops. Do epilog. Use src-src_sav to compute distance */
  55. /* X - (A - B) == X + B - A */
  56. .falign
  57. 8089:
  58. {
  59. memd(dst) = d_dbuf
  60. r2 += sub(src_sav,src)
  61. }
  62. {
  63. r0 = r2
  64. jumpr r31
  65. }
  66. .falign
  67. 4089:
  68. {
  69. memw(dst) = w_dbuf
  70. r2 += sub(src_sav,src)
  71. }
  72. {
  73. r0 = r2
  74. jumpr r31
  75. }
  76. .falign
  77. 2089:
  78. {
  79. memh(dst) = w_dbuf
  80. r2 += sub(src_sav,src)
  81. }
  82. {
  83. r0 = r2
  84. jumpr r31
  85. }
  86. .falign
  87. 1089:
  88. {
  89. memb(dst) = w_dbuf
  90. r2 += sub(src_sav,src)
  91. }
  92. {
  93. r0 = r2
  94. jumpr r31
  95. }
  96. /* COPY FROM USER: only loads can fail */
  97. .section __ex_table,"a"
  98. .long 1000b,1009b
  99. .long 2000b,2009b
  100. .long 4000b,4009b
  101. .long 8080b,8089b
  102. .long 4080b,4089b
  103. .long 2080b,2089b
  104. .long 1080b,1089b
  105. .previous