copy_to_user.S 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * User memory copying routines for the Hexagon Kernel
  4. *
  5. * Copyright (c) 2010-2011, The Linux Foundation. All rights reserved.
  6. */
  7. /* The right way to do this involves valignb
  8. * The easy way to do this is only speed up src/dest similar alignment.
  9. */
  10. /*
  11. * Copy to/from user are the same, except that for packets with a load and
  12. * a store, I don't know how to tell which kind of exception we got.
  13. * Therefore, we duplicate the function, and handle faulting addresses
  14. * differently for each function
  15. */
  16. /*
  17. * copy to user: stores can fault
  18. */
  19. #define src_sav r13
  20. #define dst_sav r12
  21. #define src_dst_sav r13:12
  22. #define d_dbuf r15:14
  23. #define w_dbuf r15
  24. #define dst r0
  25. #define src r1
  26. #define bytes r2
  27. #define loopcount r5
  28. #define FUNCNAME raw_copy_to_user
  29. #include "copy_user_template.S"
  30. /* STORE FAULTS from COPY_TO_USER */
  31. .falign
  32. 1109:
  33. 2109:
  34. 4109:
  35. /* Alignment loop. r2 has been updated. Return it. */
  36. {
  37. r0 = r2
  38. jumpr r31
  39. }
  40. /* Normal copy loops. Use dst-dst_sav to compute distance */
  41. /* dst holds best write, no need to unwind any loops */
  42. /* X - (A - B) == X + B - A */
  43. .falign
  44. 8189:
  45. 8199:
  46. 4189:
  47. 4199:
  48. 2189:
  49. 2199:
  50. 1189:
  51. 1199:
  52. {
  53. r2 += sub(dst_sav,dst)
  54. }
  55. {
  56. r0 = r2
  57. jumpr r31
  58. }
  59. /* COPY TO USER: only stores can fail */
  60. .section __ex_table,"a"
  61. .long 1100b,1109b
  62. .long 2100b,2109b
  63. .long 4100b,4109b
  64. .long 8180b,8189b
  65. .long 8190b,8199b
  66. .long 4180b,4189b
  67. .long 4190b,4199b
  68. .long 2180b,2189b
  69. .long 2190b,2199b
  70. .long 1180b,1189b
  71. .long 1190b,1199b
  72. .previous