GENpage.S 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* GENpage.S: Generic clear and copy page.
  3. *
  4. * Copyright (C) 2007 (davem@davemloft.net)
  5. */
  6. #include <asm/page.h>
  7. .text
  8. .align 32
  9. GENcopy_user_page:
  10. set PAGE_SIZE, %g7
  11. 1: ldx [%o1 + 0x00], %o2
  12. ldx [%o1 + 0x08], %o3
  13. ldx [%o1 + 0x10], %o4
  14. ldx [%o1 + 0x18], %o5
  15. stx %o2, [%o0 + 0x00]
  16. stx %o3, [%o0 + 0x08]
  17. stx %o4, [%o0 + 0x10]
  18. stx %o5, [%o0 + 0x18]
  19. ldx [%o1 + 0x20], %o2
  20. ldx [%o1 + 0x28], %o3
  21. ldx [%o1 + 0x30], %o4
  22. ldx [%o1 + 0x38], %o5
  23. stx %o2, [%o0 + 0x20]
  24. stx %o3, [%o0 + 0x28]
  25. stx %o4, [%o0 + 0x30]
  26. stx %o5, [%o0 + 0x38]
  27. subcc %g7, 64, %g7
  28. add %o1, 64, %o1
  29. bne,pt %xcc, 1b
  30. add %o0, 64, %o0
  31. retl
  32. nop
  33. GENclear_page:
  34. GENclear_user_page:
  35. set PAGE_SIZE, %g7
  36. 1: stx %g0, [%o0 + 0x00]
  37. stx %g0, [%o0 + 0x08]
  38. stx %g0, [%o0 + 0x10]
  39. stx %g0, [%o0 + 0x18]
  40. stx %g0, [%o0 + 0x20]
  41. stx %g0, [%o0 + 0x28]
  42. stx %g0, [%o0 + 0x30]
  43. stx %g0, [%o0 + 0x38]
  44. subcc %g7, 64, %g7
  45. bne,pt %xcc, 1b
  46. add %o0, 64, %o0
  47. #define BRANCH_ALWAYS 0x10680000
  48. #define NOP 0x01000000
  49. #define GEN_DO_PATCH(OLD, NEW) \
  50. sethi %hi(NEW), %g1; \
  51. or %g1, %lo(NEW), %g1; \
  52. sethi %hi(OLD), %g2; \
  53. or %g2, %lo(OLD), %g2; \
  54. sub %g1, %g2, %g1; \
  55. sethi %hi(BRANCH_ALWAYS), %g3; \
  56. sll %g1, 11, %g1; \
  57. srl %g1, 11 + 2, %g1; \
  58. or %g3, %lo(BRANCH_ALWAYS), %g3; \
  59. or %g3, %g1, %g3; \
  60. stw %g3, [%g2]; \
  61. sethi %hi(NOP), %g3; \
  62. or %g3, %lo(NOP), %g3; \
  63. stw %g3, [%g2 + 0x4]; \
  64. flush %g2;
  65. .globl generic_patch_pageops
  66. .type generic_patch_pageops,#function
  67. generic_patch_pageops:
  68. GEN_DO_PATCH(copy_user_page, GENcopy_user_page)
  69. GEN_DO_PATCH(_clear_page, GENclear_page)
  70. GEN_DO_PATCH(clear_user_page, GENclear_user_page)
  71. retl
  72. nop
  73. .size generic_patch_pageops,.-generic_patch_pageops