copy_page_64.S 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* Written 2003 by Andi Kleen, based on a kernel by Evandro Menezes */
  2. #include <linux/linkage.h>
  3. #include <asm/cpufeatures.h>
  4. #include <asm/alternative-asm.h>
  5. /*
  6. * Some CPUs run faster using the string copy instructions (sane microcode).
  7. * It is also a lot simpler. Use this when possible. But, don't use streaming
  8. * copy unless the CPU indicates X86_FEATURE_REP_GOOD. Could vary the
  9. * prefetch distance based on SMP/UP.
  10. */
  11. ALIGN
  12. ENTRY(copy_page)
  13. ALTERNATIVE "jmp copy_page_regs", "", X86_FEATURE_REP_GOOD
  14. movl $4096/8, %ecx
  15. rep movsq
  16. ret
  17. ENDPROC(copy_page)
  18. ENTRY(copy_page_regs)
  19. subq $2*8, %rsp
  20. movq %rbx, (%rsp)
  21. movq %r12, 1*8(%rsp)
  22. movl $(4096/64)-5, %ecx
  23. .p2align 4
  24. .Loop64:
  25. dec %rcx
  26. movq 0x8*0(%rsi), %rax
  27. movq 0x8*1(%rsi), %rbx
  28. movq 0x8*2(%rsi), %rdx
  29. movq 0x8*3(%rsi), %r8
  30. movq 0x8*4(%rsi), %r9
  31. movq 0x8*5(%rsi), %r10
  32. movq 0x8*6(%rsi), %r11
  33. movq 0x8*7(%rsi), %r12
  34. prefetcht0 5*64(%rsi)
  35. movq %rax, 0x8*0(%rdi)
  36. movq %rbx, 0x8*1(%rdi)
  37. movq %rdx, 0x8*2(%rdi)
  38. movq %r8, 0x8*3(%rdi)
  39. movq %r9, 0x8*4(%rdi)
  40. movq %r10, 0x8*5(%rdi)
  41. movq %r11, 0x8*6(%rdi)
  42. movq %r12, 0x8*7(%rdi)
  43. leaq 64 (%rsi), %rsi
  44. leaq 64 (%rdi), %rdi
  45. jnz .Loop64
  46. movl $5, %ecx
  47. .p2align 4
  48. .Loop2:
  49. decl %ecx
  50. movq 0x8*0(%rsi), %rax
  51. movq 0x8*1(%rsi), %rbx
  52. movq 0x8*2(%rsi), %rdx
  53. movq 0x8*3(%rsi), %r8
  54. movq 0x8*4(%rsi), %r9
  55. movq 0x8*5(%rsi), %r10
  56. movq 0x8*6(%rsi), %r11
  57. movq 0x8*7(%rsi), %r12
  58. movq %rax, 0x8*0(%rdi)
  59. movq %rbx, 0x8*1(%rdi)
  60. movq %rdx, 0x8*2(%rdi)
  61. movq %r8, 0x8*3(%rdi)
  62. movq %r9, 0x8*4(%rdi)
  63. movq %r10, 0x8*5(%rdi)
  64. movq %r11, 0x8*6(%rdi)
  65. movq %r12, 0x8*7(%rdi)
  66. leaq 64(%rdi), %rdi
  67. leaq 64(%rsi), %rsi
  68. jnz .Loop2
  69. movq (%rsp), %rbx
  70. movq 1*8(%rsp), %r12
  71. addq $2*8, %rsp
  72. ret
  73. ENDPROC(copy_page_regs)