GENpage.S 1.6 KB

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