xref: /openbmc/linux/arch/x86/lib/clear_page_64.S (revision b6dcefde)
1#include <linux/linkage.h>
2#include <asm/dwarf2.h>
3
4/*
5 * Zero a page.
6 * rdi	page
7 */
8ENTRY(clear_page_c)
9	CFI_STARTPROC
10	movl $4096/8,%ecx
11	xorl %eax,%eax
12	rep stosq
13	ret
14	CFI_ENDPROC
15ENDPROC(clear_page_c)
16
17ENTRY(clear_page)
18	CFI_STARTPROC
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
37	CFI_ENDPROC
38.Lclear_page_end:
39ENDPROC(clear_page)
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
46	.section .altinstr_replacement,"ax"
471:	.byte 0xeb					/* jmp <disp8> */
48	.byte (clear_page_c - clear_page) - (2f - 1b)	/* offset */
492:
50	.previous
51	.section .altinstructions,"a"
52	.align 8
53	.quad clear_page
54	.quad 1b
55	.byte X86_FEATURE_REP_GOOD
56	.byte .Lclear_page_end - clear_page
57	.byte 2b - 1b
58	.previous
59