Linux Audio

Check our new training course

Loading...
v4.10.11
 1#include <linux/linkage.h>
 2#include <asm/cpufeatures.h>
 3#include <asm/alternative-asm.h>
 4#include <asm/export.h>
 5
 6/*
 7 * Most CPUs support enhanced REP MOVSB/STOSB instructions. It is
 8 * recommended to use this when possible and we do use them by default.
 9 * If enhanced REP MOVSB/STOSB is not available, try to use fast string.
10 * Otherwise, use original.
11 */
12
13/*
14 * Zero a page.
15 * %rdi	- page
16 */
17ENTRY(clear_page)
18
19	ALTERNATIVE_2 "jmp clear_page_orig", "", X86_FEATURE_REP_GOOD, \
20		      "jmp clear_page_c_e", X86_FEATURE_ERMS
21
22	movl $4096/8,%ecx
23	xorl %eax,%eax
24	rep stosq
25	ret
26ENDPROC(clear_page)
27EXPORT_SYMBOL(clear_page)
28
29ENTRY(clear_page_orig)
 
 
 
 
 
 
 
30
 
 
31	xorl   %eax,%eax
32	movl   $4096/64,%ecx
33	.p2align 4
34.Lloop:
35	decl	%ecx
36#define PUT(x) movq %rax,x*8(%rdi)
37	movq %rax,(%rdi)
38	PUT(1)
39	PUT(2)
40	PUT(3)
41	PUT(4)
42	PUT(5)
43	PUT(6)
44	PUT(7)
45	leaq	64(%rdi),%rdi
46	jnz	.Lloop
47	nop
48	ret
49ENDPROC(clear_page_orig)
 
 
50
51ENTRY(clear_page_c_e)
52	movl $4096,%ecx
53	xorl %eax,%eax
54	rep stosb
55	ret
56ENDPROC(clear_page_c_e)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
v3.5.6
 1#include <linux/linkage.h>
 2#include <asm/dwarf2.h>
 3#include <asm/alternative-asm.h>
 
 4
 5/*
 6 * Zero a page. 	
 7 * rdi	page
 8 */			
 9ENTRY(clear_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_c)
17
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
27ENTRY(clear_page)
28	CFI_STARTPROC
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
47	CFI_ENDPROC
48.Lclear_page_end:
49ENDPROC(clear_page)
50
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	 */
58
59#include <asm/cpufeature.h>
60
61	.section .altinstr_replacement,"ax"
621:	.byte 0xeb					/* jmp <disp8> */
63	.byte (clear_page_c - clear_page) - (2f - 1b)	/* offset */
642:	.byte 0xeb					/* jmp <disp8> */
65	.byte (clear_page_c_e - clear_page) - (3f - 2b)	/* offset */
663:
67	.previous
68	.section .altinstructions,"a"
69	altinstruction_entry clear_page,1b,X86_FEATURE_REP_GOOD,\
70			     .Lclear_page_end-clear_page, 2b-1b
71	altinstruction_entry clear_page,2b,X86_FEATURE_ERMS,   \
72			     .Lclear_page_end-clear_page,3b-2b
73	.previous