copy_page.S 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. * Copyright (C) 2012 ARM Ltd.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include <linux/linkage.h>
  17. #include <linux/const.h>
  18. #include <asm/assembler.h>
  19. #include <asm/page.h>
  20. #include <asm/cpufeature.h>
  21. #include <asm/alternative.h>
  22. /*
  23. * Copy a page from src to dest (both are page aligned)
  24. *
  25. * Parameters:
  26. * x0 - dest
  27. * x1 - src
  28. */
  29. ENTRY(copy_page)
  30. alternative_if ARM64_HAS_NO_HW_PREFETCH
  31. # Prefetch two cache lines ahead.
  32. prfm pldl1strm, [x1, #128]
  33. prfm pldl1strm, [x1, #256]
  34. alternative_else_nop_endif
  35. ldp x2, x3, [x1]
  36. ldp x4, x5, [x1, #16]
  37. ldp x6, x7, [x1, #32]
  38. ldp x8, x9, [x1, #48]
  39. ldp x10, x11, [x1, #64]
  40. ldp x12, x13, [x1, #80]
  41. ldp x14, x15, [x1, #96]
  42. ldp x16, x17, [x1, #112]
  43. mov x18, #(PAGE_SIZE - 128)
  44. add x1, x1, #128
  45. 1:
  46. subs x18, x18, #128
  47. alternative_if ARM64_HAS_NO_HW_PREFETCH
  48. prfm pldl1strm, [x1, #384]
  49. alternative_else_nop_endif
  50. stnp x2, x3, [x0]
  51. ldp x2, x3, [x1]
  52. stnp x4, x5, [x0, #16]
  53. ldp x4, x5, [x1, #16]
  54. stnp x6, x7, [x0, #32]
  55. ldp x6, x7, [x1, #32]
  56. stnp x8, x9, [x0, #48]
  57. ldp x8, x9, [x1, #48]
  58. stnp x10, x11, [x0, #64]
  59. ldp x10, x11, [x1, #64]
  60. stnp x12, x13, [x0, #80]
  61. ldp x12, x13, [x1, #80]
  62. stnp x14, x15, [x0, #96]
  63. ldp x14, x15, [x1, #96]
  64. stnp x16, x17, [x0, #112]
  65. ldp x16, x17, [x1, #112]
  66. add x0, x0, #128
  67. add x1, x1, #128
  68. b.gt 1b
  69. stnp x2, x3, [x0]
  70. stnp x4, x5, [x0, #16]
  71. stnp x6, x7, [x0, #32]
  72. stnp x8, x9, [x0, #48]
  73. stnp x10, x11, [x0, #64]
  74. stnp x12, x13, [x0, #80]
  75. stnp x14, x15, [x0, #96]
  76. stnp x16, x17, [x0, #112]
  77. ret
  78. ENDPROC(copy_page)