clear_page_64.S 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include <linux/linkage.h>
  2. #include <asm/dwarf2.h>
  3. #include <asm/cpufeature.h>
  4. #include <asm/alternative-asm.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)
  16. CFI_STARTPROC
  17. ALTERNATIVE_2 "jmp clear_page_orig", "", X86_FEATURE_REP_GOOD, \
  18. "jmp clear_page_c_e", X86_FEATURE_ERMS
  19. movl $4096/8,%ecx
  20. xorl %eax,%eax
  21. rep stosq
  22. ret
  23. CFI_ENDPROC
  24. ENDPROC(clear_page)
  25. ENTRY(clear_page_orig)
  26. CFI_STARTPROC
  27. xorl %eax,%eax
  28. movl $4096/64,%ecx
  29. .p2align 4
  30. .Lloop:
  31. decl %ecx
  32. #define PUT(x) movq %rax,x*8(%rdi)
  33. movq %rax,(%rdi)
  34. PUT(1)
  35. PUT(2)
  36. PUT(3)
  37. PUT(4)
  38. PUT(5)
  39. PUT(6)
  40. PUT(7)
  41. leaq 64(%rdi),%rdi
  42. jnz .Lloop
  43. nop
  44. ret
  45. CFI_ENDPROC
  46. ENDPROC(clear_page_orig)
  47. ENTRY(clear_page_c_e)
  48. CFI_STARTPROC
  49. movl $4096,%ecx
  50. xorl %eax,%eax
  51. rep stosb
  52. ret
  53. CFI_ENDPROC
  54. ENDPROC(clear_page_c_e)