copy_page_64.S 1.8 KB

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