Jan Beulich | 8d379da | 2006-09-26 10:52:32 +0200 | [diff] [blame] | 1 | #include <linux/linkage.h> |
| 2 | #include <asm/dwarf2.h> |
| 3 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | /* |
| 5 | * Zero a page. |
| 6 | * rdi page |
| 7 | */ |
Jan Beulich | 8d379da | 2006-09-26 10:52:32 +0200 | [diff] [blame] | 8 | ALIGN |
| 9 | 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) |
| 17 | |
| 18 | ENTRY(clear_page) |
| 19 | CFI_STARTPROC |
Andi Kleen | 7bcd3f3 | 2006-02-03 21:51:02 +0100 | [diff] [blame] | 20 | 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 Beulich | 8d379da | 2006-09-26 10:52:32 +0200 | [diff] [blame] | 38 | CFI_ENDPROC |
| 39 | .Lclear_page_end: |
| 40 | ENDPROC(clear_page) |
Andi Kleen | 7bcd3f3 | 2006-02-03 21:51:02 +0100 | [diff] [blame] | 41 | |
| 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 Beulich | 8d379da | 2006-09-26 10:52:32 +0200 | [diff] [blame] | 47 | .section .altinstr_replacement,"ax" |
| 48 | 1: .byte 0xeb /* jmp <disp8> */ |
| 49 | .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */ |
| 50 | 2: |
| 51 | .previous |
Andi Kleen | 7bcd3f3 | 2006-02-03 21:51:02 +0100 | [diff] [blame] | 52 | .section .altinstructions,"a" |
| 53 | .align 8 |
Jan Beulich | 8d379da | 2006-09-26 10:52:32 +0200 | [diff] [blame] | 54 | .quad clear_page |
| 55 | .quad 1b |
| 56 | .byte X86_FEATURE_REP_GOOD |
| 57 | .byte .Lclear_page_end - clear_page |
| 58 | .byte 2b - 1b |
Andi Kleen | 7bcd3f3 | 2006-02-03 21:51:02 +0100 | [diff] [blame] | 59 | .previous |