]> git.ipfire.org Git - thirdparty/kernel/stable.git/blame - arch/x86/lib/clear_page_64.S
x86/cpufeature: Carve out X86_FEATURE_*
[thirdparty/kernel/stable.git] / arch / x86 / lib / clear_page_64.S
CommitLineData
8d379dad
JB
1#include <linux/linkage.h>
2#include <asm/dwarf2.h>
e365c9df 3#include <asm/alternative-asm.h>
8d379dad 4
1da177e4
LT
5/*
6 * Zero a page.
7 * rdi page
8 */
9e314996 9ENTRY(clear_page_c)
8d379dad
JB
10 CFI_STARTPROC
11 movl $4096/8,%ecx
12 xorl %eax,%eax
13 rep stosq
14 ret
15 CFI_ENDPROC
9e314996 16ENDPROC(clear_page_c)
8d379dad 17
e365c9df
FY
18ENTRY(clear_page_c_e)
19 CFI_STARTPROC
20 movl $4096,%ecx
21 xorl %eax,%eax
22 rep stosb
23 ret
24 CFI_ENDPROC
25ENDPROC(clear_page_c_e)
26
8d379dad
JB
27ENTRY(clear_page)
28 CFI_STARTPROC
7bcd3f34
AK
29 xorl %eax,%eax
30 movl $4096/64,%ecx
31 .p2align 4
32.Lloop:
33 decl %ecx
34#define PUT(x) movq %rax,x*8(%rdi)
35 movq %rax,(%rdi)
36 PUT(1)
37 PUT(2)
38 PUT(3)
39 PUT(4)
40 PUT(5)
41 PUT(6)
42 PUT(7)
43 leaq 64(%rdi),%rdi
44 jnz .Lloop
45 nop
46 ret
8d379dad
JB
47 CFI_ENDPROC
48.Lclear_page_end:
49ENDPROC(clear_page)
7bcd3f34 50
e365c9df
FY
51 /*
52 * Some CPUs support enhanced REP MOVSB/STOSB instructions.
53 * It is recommended to use this when possible.
54 * If enhanced REP MOVSB/STOSB is not available, try to use fast string.
55 * Otherwise, use original function.
56 *
57 */
7bcd3f34 58
e12edd02 59#include <asm/cpufeatures.h>
7bcd3f34 60
8d379dad
JB
61 .section .altinstr_replacement,"ax"
621: .byte 0xeb /* jmp <disp8> */
63 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
e365c9df
FY
642: .byte 0xeb /* jmp <disp8> */
65 .byte (clear_page_c_e - clear_page) - (3f - 2b) /* offset */
663:
8d379dad 67 .previous
7bcd3f34 68 .section .altinstructions,"a"
e365c9df 69 altinstruction_entry clear_page,1b,X86_FEATURE_REP_GOOD,\
005db1f8 70 .Lclear_page_end-clear_page, 2b-1b, 0
e365c9df 71 altinstruction_entry clear_page,2b,X86_FEATURE_ERMS, \
005db1f8 72 .Lclear_page_end-clear_page,3b-2b, 0
7bcd3f34 73 .previous