lightnvm: NVM should depend on HAS_DMA
[deliverable/linux.git] / arch / x86 / lib / clear_page_64.S
1 #include <linux/linkage.h>
2 #include <asm/cpufeatures.h>
3 #include <asm/alternative-asm.h>
4
5 /*
6 * Most CPUs support enhanced REP MOVSB/STOSB instructions. It is
7 * recommended to use this when possible and we do use them by default.
8 * If enhanced REP MOVSB/STOSB is not available, try to use fast string.
9 * Otherwise, use original.
10 */
11
12 /*
13 * Zero a page.
14 * %rdi - page
15 */
16 ENTRY(clear_page)
17
18 ALTERNATIVE_2 "jmp clear_page_orig", "", X86_FEATURE_REP_GOOD, \
19 "jmp clear_page_c_e", X86_FEATURE_ERMS
20
21 movl $4096/8,%ecx
22 xorl %eax,%eax
23 rep stosq
24 ret
25 ENDPROC(clear_page)
26
27 ENTRY(clear_page_orig)
28
29 xorl %eax,%eax
30 movl $4096/64,%ecx
31 .p2align 4
32 .Lloop:
33 decl %ecx
34 #define PUT(x) movq %rax,x*8(%rdi)
35 movq %rax,(%rdi)
36 PUT(1)
37 PUT(2)
38 PUT(3)
39 PUT(4)
40 PUT(5)
41 PUT(6)
42 PUT(7)
43 leaq 64(%rdi),%rdi
44 jnz .Lloop
45 nop
46 ret
47 ENDPROC(clear_page_orig)
48
49 ENTRY(clear_page_c_e)
50 movl $4096,%ecx
51 xorl %eax,%eax
52 rep stosb
53 ret
54 ENDPROC(clear_page_c_e)
This page took 0.032859 seconds and 5 git commands to generate.