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 | */ |
Mike Galbraith | 9e31499 | 2009-06-30 15:00:20 +0200 | [diff] [blame] | 8 | ENTRY(clear_page_c) |
Jan Beulich | 8d379da | 2006-09-26 10:52:32 +0200 | [diff] [blame] | 9 | CFI_STARTPROC |
| 10 | movl $4096/8,%ecx |
| 11 | xorl %eax,%eax |
| 12 | rep stosq |
| 13 | ret |
| 14 | CFI_ENDPROC |
Mike Galbraith | 9e31499 | 2009-06-30 15:00:20 +0200 | [diff] [blame] | 15 | ENDPROC(clear_page_c) |
Jan Beulich | 8d379da | 2006-09-26 10:52:32 +0200 | [diff] [blame] | 16 | |
| 17 | ENTRY(clear_page) |
| 18 | CFI_STARTPROC |
Andi Kleen | 7bcd3f3 | 2006-02-03 21:51:02 +0100 | [diff] [blame] | 19 | 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 Beulich | 8d379da | 2006-09-26 10:52:32 +0200 | [diff] [blame] | 37 | CFI_ENDPROC |
| 38 | .Lclear_page_end: |
| 39 | ENDPROC(clear_page) |
Andi Kleen | 7bcd3f3 | 2006-02-03 21:51:02 +0100 | [diff] [blame] | 40 | |
| 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 Beulich | 8d379da | 2006-09-26 10:52:32 +0200 | [diff] [blame] | 46 | .section .altinstr_replacement,"ax" |
| 47 | 1: .byte 0xeb /* jmp <disp8> */ |
| 48 | .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */ |
| 49 | 2: |
| 50 | .previous |
Andi Kleen | 7bcd3f3 | 2006-02-03 21:51:02 +0100 | [diff] [blame] | 51 | .section .altinstructions,"a" |
| 52 | .align 8 |
Jan Beulich | 8d379da | 2006-09-26 10:52:32 +0200 | [diff] [blame] | 53 | .quad clear_page |
| 54 | .quad 1b |
| 55 | .byte X86_FEATURE_REP_GOOD |
| 56 | .byte .Lclear_page_end - clear_page |
| 57 | .byte 2b - 1b |
Andi Kleen | 7bcd3f3 | 2006-02-03 21:51:02 +0100 | [diff] [blame] | 58 | .previous |