clear_page_64.S 969 B

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