xref: /openbmc/linux/arch/x86/lib/clear_page_64.S (revision 94d964e5)
1/* SPDX-License-Identifier: GPL-2.0-only */
2#include <linux/linkage.h>
3#include <asm/export.h>
4
5/*
6 * 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 */
16SYM_FUNC_START(clear_page_rep)
17	movl $4096/8,%ecx
18	xorl %eax,%eax
19	rep stosq
20	RET
21SYM_FUNC_END(clear_page_rep)
22EXPORT_SYMBOL_GPL(clear_page_rep)
23
24SYM_FUNC_START(clear_page_orig)
25	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
42	RET
43SYM_FUNC_END(clear_page_orig)
44EXPORT_SYMBOL_GPL(clear_page_orig)
45
46SYM_FUNC_START(clear_page_erms)
47	movl $4096,%ecx
48	xorl %eax,%eax
49	rep stosb
50	RET
51SYM_FUNC_END(clear_page_erms)
52EXPORT_SYMBOL_GPL(clear_page_erms)
53