1#include <linux/linkage.h>
2#include <asm/dwarf2.h>
3
4/*
5 * Zero a page.
6 * rdi	page
7 */
8	ALIGN
9clear_page_c:
10	CFI_STARTPROC
11	movl $4096/8,%ecx
12	xorl %eax,%eax
13	rep stosq
14	ret
15	CFI_ENDPROC
16ENDPROC(clear_page)
17
18ENTRY(clear_page)
19	CFI_STARTPROC
20	xorl   %eax,%eax
21	movl   $4096/64,%ecx
22	.p2align 4
23.Lloop:
24	decl	%ecx
25#define PUT(x) movq %rax,x*8(%rdi)
26	movq %rax,(%rdi)
27	PUT(1)
28	PUT(2)
29	PUT(3)
30	PUT(4)
31	PUT(5)
32	PUT(6)
33	PUT(7)
34	leaq	64(%rdi),%rdi
35	jnz	.Lloop
36	nop
37	ret
38	CFI_ENDPROC
39.Lclear_page_end:
40ENDPROC(clear_page)
41
42	/* Some CPUs run faster using the string instructions.
43	   It is also a lot simpler. Use this when possible */
44
45#include <asm/cpufeature.h>
46
47	.section .altinstr_replacement,"ax"
481:	.byte 0xeb					/* jmp <disp8> */
49	.byte (clear_page_c - clear_page) - (2f - 1b)	/* offset */
502:
51	.previous
52	.section .altinstructions,"a"
53	.align 8
54	.quad clear_page
55	.quad 1b
56	.byte X86_FEATURE_REP_GOOD
57	.byte .Lclear_page_end - clear_page
58	.byte 2b - 1b
59	.previous
60