copy_page.S 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2012 ARM Ltd.
  4. */
  5. #include <linux/linkage.h>
  6. #include <linux/const.h>
  7. #include <asm/assembler.h>
  8. #include <asm/page.h>
  9. #include <asm/cpufeature.h>
  10. #include <asm/alternative.h>
  11. /*
  12. * Copy a page from src to dest (both are page aligned)
  13. *
  14. * Parameters:
  15. * x0 - dest
  16. * x1 - src
  17. */
  18. SYM_FUNC_START(__pi_copy_page)
  19. #ifdef CONFIG_AS_HAS_MOPS
  20. .arch_extension mops
  21. alternative_if_not ARM64_HAS_MOPS
  22. b .Lno_mops
  23. alternative_else_nop_endif
  24. mov x2, #PAGE_SIZE
  25. cpypwn [x0]!, [x1]!, x2!
  26. cpymwn [x0]!, [x1]!, x2!
  27. cpyewn [x0]!, [x1]!, x2!
  28. ret
  29. .Lno_mops:
  30. #endif
  31. ldp x2, x3, [x1]
  32. ldp x4, x5, [x1, #16]
  33. ldp x6, x7, [x1, #32]
  34. ldp x8, x9, [x1, #48]
  35. ldp x10, x11, [x1, #64]
  36. ldp x12, x13, [x1, #80]
  37. ldp x14, x15, [x1, #96]
  38. ldp x16, x17, [x1, #112]
  39. add x0, x0, #256
  40. add x1, x1, #128
  41. 1:
  42. tst x0, #(PAGE_SIZE - 1)
  43. stnp x2, x3, [x0, #-256]
  44. ldp x2, x3, [x1]
  45. stnp x4, x5, [x0, #16 - 256]
  46. ldp x4, x5, [x1, #16]
  47. stnp x6, x7, [x0, #32 - 256]
  48. ldp x6, x7, [x1, #32]
  49. stnp x8, x9, [x0, #48 - 256]
  50. ldp x8, x9, [x1, #48]
  51. stnp x10, x11, [x0, #64 - 256]
  52. ldp x10, x11, [x1, #64]
  53. stnp x12, x13, [x0, #80 - 256]
  54. ldp x12, x13, [x1, #80]
  55. stnp x14, x15, [x0, #96 - 256]
  56. ldp x14, x15, [x1, #96]
  57. stnp x16, x17, [x0, #112 - 256]
  58. ldp x16, x17, [x1, #112]
  59. add x0, x0, #128
  60. add x1, x1, #128
  61. b.ne 1b
  62. stnp x2, x3, [x0, #-256]
  63. stnp x4, x5, [x0, #16 - 256]
  64. stnp x6, x7, [x0, #32 - 256]
  65. stnp x8, x9, [x0, #48 - 256]
  66. stnp x10, x11, [x0, #64 - 256]
  67. stnp x12, x13, [x0, #80 - 256]
  68. stnp x14, x15, [x0, #96 - 256]
  69. stnp x16, x17, [x0, #112 - 256]
  70. ret
  71. SYM_FUNC_END(__pi_copy_page)
  72. SYM_FUNC_ALIAS(copy_page, __pi_copy_page)
  73. EXPORT_SYMBOL(copy_page)