Merge branch 'akpm'
[linux-2.6/next.git] / arch / x86 / lib / clear_page_64.S
blobf2145cfa12a66830e834718340c4cc88e64a731a
1 #include <linux/linkage.h>
2 #include <asm/dwarf2.h>
3 #include <asm/alternative-asm.h>
5 /*
6  * Zero a page.         
7  * rdi  page
8  */                     
9 ENTRY(clear_page_c)
10         CFI_STARTPROC
11         movl $4096/8,%ecx
12         xorl %eax,%eax
13         rep stosq
14         ret
15         CFI_ENDPROC
16 ENDPROC(clear_page_c)
18 ENTRY(clear_page_c_e)
19         CFI_STARTPROC
20         movl $4096,%ecx
21         xorl %eax,%eax
22         rep stosb
23         ret
24         CFI_ENDPROC
25 ENDPROC(clear_page_c_e)
27 ENTRY(clear_page)
28         CFI_STARTPROC
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         CFI_ENDPROC
48 .Lclear_page_end:
49 ENDPROC(clear_page)
51         /*
52          * Some CPUs support enhanced REP MOVSB/STOSB instructions.
53          * It is recommended to use this when possible.
54          * If enhanced REP MOVSB/STOSB is not available, try to use fast string.
55          * Otherwise, use original function.
56          *
57          */
59 #include <asm/cpufeature.h>
61         .section .altinstr_replacement,"ax"
62 1:      .byte 0xeb                                      /* jmp <disp8> */
63         .byte (clear_page_c - clear_page) - (2f - 1b)   /* offset */
64 2:      .byte 0xeb                                      /* jmp <disp8> */
65         .byte (clear_page_c_e - clear_page) - (3f - 2b) /* offset */
67         .previous
68         .section .altinstructions,"a"
69         altinstruction_entry clear_page,1b,X86_FEATURE_REP_GOOD,\
70                              .Lclear_page_end-clear_page, 2b-1b
71         altinstruction_entry clear_page,2b,X86_FEATURE_ERMS,   \
72                              .Lclear_page_end-clear_page,3b-2b
73         .previous