blob: aa4326bfb24a1dc6dbe2b131dd7c7c19bb58d58d [file] [log] [blame]
Jan Beulich8d379da2006-09-26 10:52:32 +02001#include <linux/linkage.h>
2#include <asm/dwarf2.h>
3
Linus Torvalds1da177e2005-04-16 15:20:36 -07004/*
5 * Zero a page.
6 * rdi page
7 */
Mike Galbraith9e314992009-06-30 15:00:20 +02008ENTRY(clear_page_c)
Jan Beulich8d379da2006-09-26 10:52:32 +02009 CFI_STARTPROC
10 movl $4096/8,%ecx
11 xorl %eax,%eax
12 rep stosq
13 ret
14 CFI_ENDPROC
Mike Galbraith9e314992009-06-30 15:00:20 +020015ENDPROC(clear_page_c)
Jan Beulich8d379da2006-09-26 10:52:32 +020016
17ENTRY(clear_page)
18 CFI_STARTPROC
Andi Kleen7bcd3f32006-02-03 21:51:02 +010019 xorl %eax,%eax
20 movl $4096/64,%ecx
21 .p2align 4
22.Lloop:
23 decl %ecx
24#define PUT(x) movq %rax,x*8(%rdi)
25 movq %rax,(%rdi)
26 PUT(1)
27 PUT(2)
28 PUT(3)
29 PUT(4)
30 PUT(5)
31 PUT(6)
32 PUT(7)
33 leaq 64(%rdi),%rdi
34 jnz .Lloop
35 nop
36 ret
Jan Beulich8d379da2006-09-26 10:52:32 +020037 CFI_ENDPROC
38.Lclear_page_end:
39ENDPROC(clear_page)
Andi Kleen7bcd3f32006-02-03 21:51:02 +010040
41 /* Some CPUs run faster using the string instructions.
42 It is also a lot simpler. Use this when possible */
43
44#include <asm/cpufeature.h>
45
Jan Beulich8d379da2006-09-26 10:52:32 +020046 .section .altinstr_replacement,"ax"
471: .byte 0xeb /* jmp <disp8> */
48 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
492:
50 .previous
Andi Kleen7bcd3f32006-02-03 21:51:02 +010051 .section .altinstructions,"a"
52 .align 8
Jan Beulich8d379da2006-09-26 10:52:32 +020053 .quad clear_page
54 .quad 1b
H. Peter Anvin83a7a2a2010-06-10 00:10:43 +000055 .word X86_FEATURE_REP_GOOD
Jan Beulich8d379da2006-09-26 10:52:32 +020056 .byte .Lclear_page_end - clear_page
57 .byte 2b - 1b
Andi Kleen7bcd3f32006-02-03 21:51:02 +010058 .previous