clear_page_64.S 970 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #include <linux/linkage.h>
  2. #include <asm/dwarf2.h>
  3. /*
  4. * Zero a page.
  5. * rdi page
  6. */
  7. ENTRY(clear_page_c)
  8. CFI_STARTPROC
  9. movl $4096/8,%ecx
  10. xorl %eax,%eax
  11. rep stosq
  12. ret
  13. CFI_ENDPROC
  14. ENDPROC(clear_page_c)
  15. ENTRY(clear_page)
  16. CFI_STARTPROC
  17. xorl %eax,%eax
  18. movl $4096/64,%ecx
  19. .p2align 4
  20. .Lloop:
  21. decl %ecx
  22. #define PUT(x) movq %rax,x*8(%rdi)
  23. movq %rax,(%rdi)
  24. PUT(1)
  25. PUT(2)
  26. PUT(3)
  27. PUT(4)
  28. PUT(5)
  29. PUT(6)
  30. PUT(7)
  31. leaq 64(%rdi),%rdi
  32. jnz .Lloop
  33. nop
  34. ret
  35. CFI_ENDPROC
  36. .Lclear_page_end:
  37. ENDPROC(clear_page)
  38. /* Some CPUs run faster using the string instructions.
  39. It is also a lot simpler. Use this when possible */
  40. #include <asm/cpufeature.h>
  41. .section .altinstr_replacement,"ax"
  42. 1: .byte 0xeb /* jmp <disp8> */
  43. .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
  44. 2:
  45. .previous
  46. .section .altinstructions,"a"
  47. .align 8
  48. .quad clear_page
  49. .quad 1b
  50. .byte X86_FEATURE_REP_GOOD
  51. .byte .Lclear_page_end - clear_page
  52. .byte 2b - 1b
  53. .previous