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