clear_page.S 791 B

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