blob: 81b1635d67dee9624de37e1f4577a36e9b7065cb [file] [log] [blame]
Jan Beulich8d379da2006-09-26 10:52:32 +02001#include <linux/linkage.h>
Borislav Petkovcd4d09e2016-01-26 22:12:04 +01002#include <asm/cpufeatures.h>
Fenghua Yue365c9d2011-05-17 15:29:14 -07003#include <asm/alternative-asm.h>
Al Viro784d5692016-01-11 11:04:34 -05004#include <asm/export.h>
Jan Beulich8d379da2006-09-26 10:52:32 +02005
Linus Torvalds1da177e2005-04-16 15:20:36 -07006/*
Borislav Petkov6620ef22015-01-18 12:57:41 +01007 * 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 */
Borislav Petkovf25d3842017-02-09 01:34:49 +010017ENTRY(clear_page_rep)
Jan Beulich8d379da2006-09-26 10:52:32 +020018 movl $4096/8,%ecx
19 xorl %eax,%eax
20 rep stosq
21 ret
Borislav Petkovf25d3842017-02-09 01:34:49 +010022ENDPROC(clear_page_rep)
23EXPORT_SYMBOL_GPL(clear_page_rep)
Jan Beulich8d379da2006-09-26 10:52:32 +020024
Borislav Petkov6620ef22015-01-18 12:57:41 +010025ENTRY(clear_page_orig)
Andi Kleen7bcd3f32006-02-03 21:51:02 +010026 xorl %eax,%eax
27 movl $4096/64,%ecx
28 .p2align 4
29.Lloop:
30 decl %ecx
31#define PUT(x) movq %rax,x*8(%rdi)
32 movq %rax,(%rdi)
33 PUT(1)
34 PUT(2)
35 PUT(3)
36 PUT(4)
37 PUT(5)
38 PUT(6)
39 PUT(7)
40 leaq 64(%rdi),%rdi
41 jnz .Lloop
42 nop
43 ret
Borislav Petkov6620ef22015-01-18 12:57:41 +010044ENDPROC(clear_page_orig)
Borislav Petkovf25d3842017-02-09 01:34:49 +010045EXPORT_SYMBOL_GPL(clear_page_orig)
Andi Kleen7bcd3f32006-02-03 21:51:02 +010046
Borislav Petkovf25d3842017-02-09 01:34:49 +010047ENTRY(clear_page_erms)
Borislav Petkov6620ef22015-01-18 12:57:41 +010048 movl $4096,%ecx
49 xorl %eax,%eax
50 rep stosb
51 ret
Borislav Petkovf25d3842017-02-09 01:34:49 +010052ENDPROC(clear_page_erms)
53EXPORT_SYMBOL_GPL(clear_page_erms)