blob: fe59b8ac4fccd401789d23146ce3a261951acc52 [file] [log] [blame]
Thomas Gleixner457c8992019-05-19 13:08:55 +01001/* SPDX-License-Identifier: GPL-2.0-only */
Jan Beulich8d379da2006-09-26 10:52:32 +02002#include <linux/linkage.h>
Al Viro784d5692016-01-11 11:04:34 -05003#include <asm/export.h>
Jan Beulich8d379da2006-09-26 10:52:32 +02004
Linus Torvalds1da177e2005-04-16 15:20:36 -07005/*
Borislav Petkov6620ef22015-01-18 12:57:41 +01006 * Most CPUs support enhanced REP MOVSB/STOSB instructions. It is
7 * recommended to use this when possible and we do use them by default.
8 * If enhanced REP MOVSB/STOSB is not available, try to use fast string.
9 * Otherwise, use original.
10 */
11
12/*
13 * Zero a page.
14 * %rdi - page
15 */
Jiri Slaby6dcc5622019-10-11 13:51:04 +020016SYM_FUNC_START(clear_page_rep)
Jan Beulich8d379da2006-09-26 10:52:32 +020017 movl $4096/8,%ecx
18 xorl %eax,%eax
19 rep stosq
Peter Zijlstraf94909c2021-12-04 14:43:40 +010020 RET
Jiri Slaby6dcc5622019-10-11 13:51:04 +020021SYM_FUNC_END(clear_page_rep)
Borislav Petkovf25d3842017-02-09 01:34:49 +010022EXPORT_SYMBOL_GPL(clear_page_rep)
Jan Beulich8d379da2006-09-26 10:52:32 +020023
Jiri Slaby6dcc5622019-10-11 13:51:04 +020024SYM_FUNC_START(clear_page_orig)
Andi Kleen7bcd3f32006-02-03 21:51:02 +010025 xorl %eax,%eax
26 movl $4096/64,%ecx
27 .p2align 4
28.Lloop:
29 decl %ecx
30#define PUT(x) movq %rax,x*8(%rdi)
31 movq %rax,(%rdi)
32 PUT(1)
33 PUT(2)
34 PUT(3)
35 PUT(4)
36 PUT(5)
37 PUT(6)
38 PUT(7)
39 leaq 64(%rdi),%rdi
40 jnz .Lloop
41 nop
Peter Zijlstraf94909c2021-12-04 14:43:40 +010042 RET
Jiri Slaby6dcc5622019-10-11 13:51:04 +020043SYM_FUNC_END(clear_page_orig)
Borislav Petkovf25d3842017-02-09 01:34:49 +010044EXPORT_SYMBOL_GPL(clear_page_orig)
Andi Kleen7bcd3f32006-02-03 21:51:02 +010045
Jiri Slaby6dcc5622019-10-11 13:51:04 +020046SYM_FUNC_START(clear_page_erms)
Borislav Petkov6620ef22015-01-18 12:57:41 +010047 movl $4096,%ecx
48 xorl %eax,%eax
49 rep stosb
Peter Zijlstraf94909c2021-12-04 14:43:40 +010050 RET
Jiri Slaby6dcc5622019-10-11 13:51:04 +020051SYM_FUNC_END(clear_page_erms)
Borislav Petkovf25d3842017-02-09 01:34:49 +010052EXPORT_SYMBOL_GPL(clear_page_erms)