M7patch.S 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * M7patch.S: Patch generic routines with M7 variant.
  3. *
  4. * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
  5. */
  6. #include <linux/linkage.h>
  7. #define BRANCH_ALWAYS 0x10680000
  8. #define NOP 0x01000000
  9. #define NG_DO_PATCH(OLD, NEW) \
  10. sethi %hi(NEW), %g1; \
  11. or %g1, %lo(NEW), %g1; \
  12. sethi %hi(OLD), %g2; \
  13. or %g2, %lo(OLD), %g2; \
  14. sub %g1, %g2, %g1; \
  15. sethi %hi(BRANCH_ALWAYS), %g3; \
  16. sll %g1, 11, %g1; \
  17. srl %g1, 11 + 2, %g1; \
  18. or %g3, %lo(BRANCH_ALWAYS), %g3; \
  19. or %g3, %g1, %g3; \
  20. stw %g3, [%g2]; \
  21. sethi %hi(NOP), %g3; \
  22. or %g3, %lo(NOP), %g3; \
  23. stw %g3, [%g2 + 0x4]; \
  24. flush %g2;
  25. ENTRY(m7_patch_copyops)
  26. NG_DO_PATCH(memcpy, M7memcpy)
  27. NG_DO_PATCH(raw_copy_from_user, M7copy_from_user)
  28. NG_DO_PATCH(raw_copy_to_user, M7copy_to_user)
  29. retl
  30. nop
  31. ENDPROC(m7_patch_copyops)
  32. ENTRY(m7_patch_bzero)
  33. NG_DO_PATCH(memset, M7memset)
  34. NG_DO_PATCH(__bzero, M7bzero)
  35. NG_DO_PATCH(__clear_user, NGclear_user)
  36. NG_DO_PATCH(tsb_init, NGtsb_init)
  37. retl
  38. nop
  39. ENDPROC(m7_patch_bzero)
  40. ENTRY(m7_patch_pageops)
  41. NG_DO_PATCH(copy_user_page, NG4copy_user_page)
  42. NG_DO_PATCH(_clear_page, M7clear_page)
  43. NG_DO_PATCH(clear_user_page, M7clear_user_page)
  44. retl
  45. nop
  46. ENDPROC(m7_patch_pageops)