| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | /* Written 2003 by Andi Kleen, based on a kernel by Evandro Menezes */ | 
					
						
							| 
									
										
										
										
											2006-10-04 03:38:54 -04:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-09-26 10:52:32 +02:00
										 |  |  | #include <linux/linkage.h> | 
					
						
							|  |  |  | #include <asm/dwarf2.h> | 
					
						
							| 
									
										
										
										
											2011-07-13 09:24:10 -04:00
										 |  |  | #include <asm/alternative-asm.h> | 
					
						
							| 
									
										
										
										
											2006-09-26 10:52:32 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	ALIGN | 
					
						
							| 
									
										
										
										
											2012-10-18 03:52:45 +08:00
										 |  |  | copy_page_rep: | 
					
						
							| 
									
										
										
										
											2006-09-26 10:52:32 +02:00
										 |  |  | 	CFI_STARTPROC | 
					
						
							| 
									
										
										
										
											2012-10-18 03:52:45 +08:00
										 |  |  | 	movl	$4096/8, %ecx | 
					
						
							|  |  |  | 	rep	movsq | 
					
						
							| 
									
										
										
										
											2006-09-26 10:52:32 +02:00
										 |  |  | 	ret | 
					
						
							|  |  |  | 	CFI_ENDPROC | 
					
						
							| 
									
										
										
										
											2012-10-18 03:52:45 +08:00
										 |  |  | ENDPROC(copy_page_rep) | 
					
						
							| 
									
										
										
										
											2006-09-26 10:52:32 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-18 03:52:45 +08:00
										 |  |  | /* | 
					
						
							|  |  |  |  *  Don't use streaming copy unless the CPU indicates X86_FEATURE_REP_GOOD. | 
					
						
							|  |  |  |  *  Could vary the prefetch distance based on SMP/UP. | 
					
						
							|  |  |  | */ | 
					
						
							| 
									
										
										
										
											2005-04-16 15:20:36 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-09-26 10:52:32 +02:00
										 |  |  | ENTRY(copy_page) | 
					
						
							|  |  |  | 	CFI_STARTPROC | 
					
						
							| 
									
										
										
										
											2012-10-18 03:52:45 +08:00
										 |  |  | 	subq	$2*8,	%rsp | 
					
						
							| 
									
										
										
										
											2012-01-05 16:12:25 +00:00
										 |  |  | 	CFI_ADJUST_CFA_OFFSET 2*8 | 
					
						
							| 
									
										
										
										
											2012-10-18 03:52:45 +08:00
										 |  |  | 	movq	%rbx,	(%rsp) | 
					
						
							| 
									
										
										
										
											2006-09-26 10:52:32 +02:00
										 |  |  | 	CFI_REL_OFFSET rbx, 0 | 
					
						
							| 
									
										
										
										
											2012-10-18 03:52:45 +08:00
										 |  |  | 	movq	%r12,	1*8(%rsp) | 
					
						
							| 
									
										
										
										
											2006-09-26 10:52:32 +02:00
										 |  |  | 	CFI_REL_OFFSET r12, 1*8 | 
					
						
							| 
									
										
										
										
											2006-02-03 21:51:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-18 03:52:45 +08:00
										 |  |  | 	movl	$(4096/64)-5,	%ecx | 
					
						
							| 
									
										
										
										
											2006-02-03 21:51:02 +01:00
										 |  |  | 	.p2align 4
 | 
					
						
							|  |  |  | .Loop64: | 
					
						
							| 
									
										
										
										
											2012-10-18 03:52:45 +08:00
										 |  |  | 	dec	%rcx | 
					
						
							|  |  |  | 	movq	0x8*0(%rsi), %rax | 
					
						
							|  |  |  | 	movq	0x8*1(%rsi), %rbx | 
					
						
							|  |  |  | 	movq	0x8*2(%rsi), %rdx | 
					
						
							|  |  |  | 	movq	0x8*3(%rsi), %r8 | 
					
						
							|  |  |  | 	movq	0x8*4(%rsi), %r9 | 
					
						
							|  |  |  | 	movq	0x8*5(%rsi), %r10 | 
					
						
							|  |  |  | 	movq	0x8*6(%rsi), %r11 | 
					
						
							|  |  |  | 	movq	0x8*7(%rsi), %r12 | 
					
						
							| 
									
										
										
										
											2006-02-03 21:51:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	prefetcht0 5*64(%rsi) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-18 03:52:45 +08:00
										 |  |  | 	movq	%rax, 0x8*0(%rdi) | 
					
						
							|  |  |  | 	movq	%rbx, 0x8*1(%rdi) | 
					
						
							|  |  |  | 	movq	%rdx, 0x8*2(%rdi) | 
					
						
							|  |  |  | 	movq	%r8,  0x8*3(%rdi) | 
					
						
							|  |  |  | 	movq	%r9,  0x8*4(%rdi) | 
					
						
							|  |  |  | 	movq	%r10, 0x8*5(%rdi) | 
					
						
							|  |  |  | 	movq	%r11, 0x8*6(%rdi) | 
					
						
							|  |  |  | 	movq	%r12, 0x8*7(%rdi) | 
					
						
							| 
									
										
										
										
											2006-02-03 21:51:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-18 03:52:45 +08:00
										 |  |  | 	leaq	64 (%rsi), %rsi | 
					
						
							|  |  |  | 	leaq	64 (%rdi), %rdi | 
					
						
							| 
									
										
										
										
											2006-02-03 21:51:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-18 03:52:45 +08:00
										 |  |  | 	jnz	.Loop64 | 
					
						
							| 
									
										
										
										
											2006-02-03 21:51:02 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-18 03:52:45 +08:00
										 |  |  | 	movl	$5, %ecx | 
					
						
							| 
									
										
										
										
											2006-02-03 21:51:02 +01:00
										 |  |  | 	.p2align 4
 | 
					
						
							|  |  |  | .Loop2: | 
					
						
							| 
									
										
										
										
											2012-10-18 03:52:45 +08:00
										 |  |  | 	decl	%ecx | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	movq	0x8*0(%rsi), %rax | 
					
						
							|  |  |  | 	movq	0x8*1(%rsi), %rbx | 
					
						
							|  |  |  | 	movq	0x8*2(%rsi), %rdx | 
					
						
							|  |  |  | 	movq	0x8*3(%rsi), %r8 | 
					
						
							|  |  |  | 	movq	0x8*4(%rsi), %r9 | 
					
						
							|  |  |  | 	movq	0x8*5(%rsi), %r10 | 
					
						
							|  |  |  | 	movq	0x8*6(%rsi), %r11 | 
					
						
							|  |  |  | 	movq	0x8*7(%rsi), %r12 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	movq	%rax, 0x8*0(%rdi) | 
					
						
							|  |  |  | 	movq	%rbx, 0x8*1(%rdi) | 
					
						
							|  |  |  | 	movq	%rdx, 0x8*2(%rdi) | 
					
						
							|  |  |  | 	movq	%r8,  0x8*3(%rdi) | 
					
						
							|  |  |  | 	movq	%r9,  0x8*4(%rdi) | 
					
						
							|  |  |  | 	movq	%r10, 0x8*5(%rdi) | 
					
						
							|  |  |  | 	movq	%r11, 0x8*6(%rdi) | 
					
						
							|  |  |  | 	movq	%r12, 0x8*7(%rdi) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 	leaq	64(%rdi), %rdi | 
					
						
							|  |  |  | 	leaq	64(%rsi), %rsi | 
					
						
							| 
									
										
										
										
											2006-02-03 21:51:02 +01:00
										 |  |  | 	jnz	.Loop2 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2012-10-18 03:52:45 +08:00
										 |  |  | 	movq	(%rsp), %rbx | 
					
						
							| 
									
										
										
										
											2006-09-26 10:52:32 +02:00
										 |  |  | 	CFI_RESTORE rbx | 
					
						
							| 
									
										
										
										
											2012-10-18 03:52:45 +08:00
										 |  |  | 	movq	1*8(%rsp), %r12 | 
					
						
							| 
									
										
										
										
											2006-09-26 10:52:32 +02:00
										 |  |  | 	CFI_RESTORE r12 | 
					
						
							| 
									
										
										
										
											2012-10-18 03:52:45 +08:00
										 |  |  | 	addq	$2*8, %rsp | 
					
						
							| 
									
										
										
										
											2012-01-05 16:12:25 +00:00
										 |  |  | 	CFI_ADJUST_CFA_OFFSET -2*8 | 
					
						
							| 
									
										
										
										
											2006-02-03 21:51:02 +01:00
										 |  |  | 	ret | 
					
						
							| 
									
										
										
										
											2006-09-26 10:52:32 +02:00
										 |  |  | .Lcopy_page_end: | 
					
						
							|  |  |  | 	CFI_ENDPROC | 
					
						
							|  |  |  | ENDPROC(copy_page) | 
					
						
							| 
									
										
										
										
											2006-02-03 21:51:02 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 	/* Some CPUs run faster using the string copy instructions. | 
					
						
							|  |  |  | 	   It is also a lot simpler. Use this when possible */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | #include <asm/cpufeature.h> | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2006-09-26 10:52:32 +02:00
										 |  |  | 	.section .altinstr_replacement,"ax" | 
					
						
							|  |  |  | 1:	.byte 0xeb					/* jmp <disp8> */ | 
					
						
							| 
									
										
										
										
											2012-10-18 03:52:45 +08:00
										 |  |  | 	.byte (copy_page_rep - copy_page) - (2f - 1b)	/* offset */ | 
					
						
							| 
									
										
										
										
											2006-09-26 10:52:32 +02:00
										 |  |  | 2: | 
					
						
							|  |  |  | 	.previous | 
					
						
							| 
									
										
										
										
											2006-02-03 21:51:02 +01:00
										 |  |  | 	.section .altinstructions,"a" | 
					
						
							| 
									
										
										
										
											2011-07-13 09:24:10 -04:00
										 |  |  | 	altinstruction_entry copy_page, 1b, X86_FEATURE_REP_GOOD,	\ | 
					
						
							|  |  |  | 		.Lcopy_page_end-copy_page, 2b-1b | 
					
						
							| 
									
										
										
										
											2006-02-03 21:51:02 +01:00
										 |  |  | 	.previous |