clear_page_64.S 969 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. #include <linux/linkage.h>
  2. #include <asm/cpufeatures.h>
  3. #include <asm/alternative-asm.h>
  4. #include <asm/export.h>
  5. /*
  6. * Most CPUs support enhanced REP MOVSB/STOSB instructions. It is
  7. * recommended to use this when possible and we do use them by default.
  8. * If enhanced REP MOVSB/STOSB is not available, try to use fast string.
  9. * Otherwise, use original.
  10. */
  11. /*
  12. * Zero a page.
  13. * %rdi - page
  14. */
  15. ENTRY(clear_page_rep)
  16. movl $4096/8,%ecx
  17. xorl %eax,%eax
  18. rep stosq
  19. ret
  20. ENDPROC(clear_page_rep)
  21. EXPORT_SYMBOL_GPL(clear_page_rep)
  22. ENTRY(clear_page_orig)
  23. xorl %eax,%eax
  24. movl $4096/64,%ecx
  25. .p2align 4
  26. .Lloop:
  27. decl %ecx
  28. #define PUT(x) movq %rax,x*8(%rdi)
  29. movq %rax,(%rdi)
  30. PUT(1)
  31. PUT(2)
  32. PUT(3)
  33. PUT(4)
  34. PUT(5)
  35. PUT(6)
  36. PUT(7)
  37. leaq 64(%rdi),%rdi
  38. jnz .Lloop
  39. nop
  40. ret
  41. ENDPROC(clear_page_orig)
  42. EXPORT_SYMBOL_GPL(clear_page_orig)
  43. ENTRY(clear_page_erms)
  44. movl $4096,%ecx
  45. xorl %eax,%eax
  46. rep stosb
  47. ret
  48. ENDPROC(clear_page_erms)
  49. EXPORT_SYMBOL_GPL(clear_page_erms)