GNU Linux-libre 4.14.290-gnu1
[releases.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_rep)
18         movl $4096/8,%ecx
19         xorl %eax,%eax
20         rep stosq
21         ret
22 ENDPROC(clear_page_rep)
23 EXPORT_SYMBOL_GPL(clear_page_rep)
24
25 ENTRY(clear_page_orig)
26         xorl   %eax,%eax
27         movl   $4096/64,%ecx
28         .p2align 4
29 .Lloop:
30         decl    %ecx
31 #define PUT(x) movq %rax,x*8(%rdi)
32         movq %rax,(%rdi)
33         PUT(1)
34         PUT(2)
35         PUT(3)
36         PUT(4)
37         PUT(5)
38         PUT(6)
39         PUT(7)
40         leaq    64(%rdi),%rdi
41         jnz     .Lloop
42         nop
43         ret
44 ENDPROC(clear_page_orig)
45 EXPORT_SYMBOL_GPL(clear_page_orig)
46
47 ENTRY(clear_page_erms)
48         movl $4096,%ecx
49         xorl %eax,%eax
50         rep stosb
51         ret
52 ENDPROC(clear_page_erms)
53 EXPORT_SYMBOL_GPL(clear_page_erms)