blob: 9a10a78bb4a414867fa68099996c6cfb66f26d2e [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 */
Jan Beulich8d379da2006-09-26 10:52:32 +02008 ALIGN
9clear_page_c:
10 CFI_STARTPROC
11 movl $4096/8,%ecx
12 xorl %eax,%eax
13 rep stosq
14 ret
15 CFI_ENDPROC
16ENDPROC(clear_page)
17
18ENTRY(clear_page)
19 CFI_STARTPROC
Andi Kleen7bcd3f32006-02-03 21:51:02 +010020 xorl %eax,%eax
21 movl $4096/64,%ecx
22 .p2align 4
23.Lloop:
24 decl %ecx
25#define PUT(x) movq %rax,x*8(%rdi)
26 movq %rax,(%rdi)
27 PUT(1)
28 PUT(2)
29 PUT(3)
30 PUT(4)
31 PUT(5)
32 PUT(6)
33 PUT(7)
34 leaq 64(%rdi),%rdi
35 jnz .Lloop
36 nop
37 ret
Jan Beulich8d379da2006-09-26 10:52:32 +020038 CFI_ENDPROC
39.Lclear_page_end:
40ENDPROC(clear_page)
Andi Kleen7bcd3f32006-02-03 21:51:02 +010041
42 /* Some CPUs run faster using the string instructions.
43 It is also a lot simpler. Use this when possible */
44
45#include <asm/cpufeature.h>
46
Jan Beulich8d379da2006-09-26 10:52:32 +020047 .section .altinstr_replacement,"ax"
481: .byte 0xeb /* jmp <disp8> */
49 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
502:
51 .previous
Andi Kleen7bcd3f32006-02-03 21:51:02 +010052 .section .altinstructions,"a"
53 .align 8
Jan Beulich8d379da2006-09-26 10:52:32 +020054 .quad clear_page
55 .quad 1b
56 .byte X86_FEATURE_REP_GOOD
57 .byte .Lclear_page_end - clear_page
58 .byte 2b - 1b
Andi Kleen7bcd3f32006-02-03 21:51:02 +010059 .previous