clear_page_64.S 946 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #include <linux/linkage.h>
  2. #include <asm/cpufeature.h>
  3. #include <asm/alternative-asm.h>
  4. /*
  5. * Most CPUs support enhanced REP MOVSB/STOSB instructions. It is
  6. * recommended to use this when possible and we do use them by default.
  7. * If enhanced REP MOVSB/STOSB is not available, try to use fast string.
  8. * Otherwise, use original.
  9. */
  10. /*
  11. * Zero a page.
  12. * %rdi - page
  13. */
  14. ENTRY(clear_page)
  15. ALTERNATIVE_2 "jmp clear_page_orig", "", X86_FEATURE_REP_GOOD, \
  16. "jmp clear_page_c_e", X86_FEATURE_ERMS
  17. movl $4096/8,%ecx
  18. xorl %eax,%eax
  19. rep stosq
  20. ret
  21. ENDPROC(clear_page)
  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. ENTRY(clear_page_c_e)
  43. movl $4096,%ecx
  44. xorl %eax,%eax
  45. rep stosb
  46. ret
  47. ENDPROC(clear_page_c_e)