Commit | Line | Data |
---|---|---|
8d379dad | 1 | #include <linux/linkage.h> |
cd4d09ec | 2 | #include <asm/cpufeatures.h> |
e365c9df | 3 | #include <asm/alternative-asm.h> |
784d5699 | 4 | #include <asm/export.h> |
8d379dad | 5 | |
1da177e4 | 6 | /* |
6620ef28 BP |
7 | * Most CPUs support enhanced REP MOVSB/STOSB instructions. It is |
8 | * recommended to use this when possible and we do use them by default. | |
9 | * If enhanced REP MOVSB/STOSB is not available, try to use fast string. | |
10 | * Otherwise, use original. | |
11 | */ | |
12 | ||
13 | /* | |
14 | * Zero a page. | |
15 | * %rdi - page | |
16 | */ | |
17 | ENTRY(clear_page) | |
6620ef28 BP |
18 | |
19 | ALTERNATIVE_2 "jmp clear_page_orig", "", X86_FEATURE_REP_GOOD, \ | |
20 | "jmp clear_page_c_e", X86_FEATURE_ERMS | |
21 | ||
8d379dad JB |
22 | movl $4096/8,%ecx |
23 | xorl %eax,%eax | |
24 | rep stosq | |
25 | ret | |
6620ef28 | 26 | ENDPROC(clear_page) |
784d5699 | 27 | EXPORT_SYMBOL(clear_page) |
8d379dad | 28 | |
6620ef28 | 29 | ENTRY(clear_page_orig) |
e365c9df | 30 | |
7bcd3f34 AK |
31 | xorl %eax,%eax |
32 | movl $4096/64,%ecx | |
33 | .p2align 4 | |
34 | .Lloop: | |
35 | decl %ecx | |
36 | #define PUT(x) movq %rax,x*8(%rdi) | |
37 | movq %rax,(%rdi) | |
38 | PUT(1) | |
39 | PUT(2) | |
40 | PUT(3) | |
41 | PUT(4) | |
42 | PUT(5) | |
43 | PUT(6) | |
44 | PUT(7) | |
45 | leaq 64(%rdi),%rdi | |
46 | jnz .Lloop | |
47 | nop | |
48 | ret | |
6620ef28 | 49 | ENDPROC(clear_page_orig) |
7bcd3f34 | 50 | |
6620ef28 | 51 | ENTRY(clear_page_c_e) |
6620ef28 BP |
52 | movl $4096,%ecx |
53 | xorl %eax,%eax | |
54 | rep stosb | |
55 | ret | |
6620ef28 | 56 | ENDPROC(clear_page_c_e) |