1#include <linux/linkage.h> 2#include <asm/cpufeature.h> 3#include <asm/alternative-asm.h> 4 5/* 6 * Most CPUs support enhanced REP MOVSB/STOSB instructions. It is 7 * recommended to use this when possible and we do use them by default. 8 * If enhanced REP MOVSB/STOSB is not available, try to use fast string. 9 * Otherwise, use original. 10 */ 11 12/* 13 * Zero a page. 14 * %rdi - page 15 */ 16ENTRY(clear_page) 17 18 ALTERNATIVE_2 "jmp clear_page_orig", "", X86_FEATURE_REP_GOOD, \ 19 "jmp clear_page_c_e", X86_FEATURE_ERMS 20 21 movl $4096/8,%ecx 22 xorl %eax,%eax 23 rep stosq 24 ret 25ENDPROC(clear_page) 26 27ENTRY(clear_page_orig) 28 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 47ENDPROC(clear_page_orig) 48 49ENTRY(clear_page_c_e) 50 movl $4096,%ecx 51 xorl %eax,%eax 52 rep stosb 53 ret 54ENDPROC(clear_page_c_e) 55