Index: sys/amd64/amd64/support.S =================================================================== --- sys/amd64/amd64/support.S +++ sys/amd64/amd64/support.S @@ -915,27 +915,22 @@ .macro COPYINSTR smap PUSH_FRAME_POINTER movq %rdx,%r8 /* %r8 = maxlen */ - movq %rcx,%r9 /* %r9 = *len */ - xchgq %rdi,%rsi /* %rdi = from, %rsi = to */ - movq PCPU(CURPCB),%rcx - movq $cpystrflt,PCB_ONFAULT(%rcx) + movq PCPU(CURPCB),%r9 + movq $cpystrflt,PCB_ONFAULT(%r9) movq $VM_MAXUSER_ADDRESS,%rax /* make sure 'from' is within bounds */ - subq %rsi,%rax + subq %rdi,%rax jbe cpystrflt SMAP_DISABLE \smap /* restrict maxlen to <= VM_MAXUSER_ADDRESS-from */ cmpq %rdx,%rax - jae 1f - movq %rax,%rdx - movq %rax,%r8 + jb 8f 1: incq %rdx - 2: decq %rdx .if \smap == 0 @@ -944,9 +939,11 @@ jz copyinstr_toolong_smap .endif - lodsb - stosb - orb %al,%al + mov (%rdi),%al + mov %al,(%rsi) + incq %rsi + incq %rdi + test %al,%al jnz 2b SMAP_ENABLE \smap @@ -956,30 +953,42 @@ xorl %eax,%eax /* set *lencopied and return %eax */ - movq PCPU(CURPCB),%rcx - movq $0,PCB_ONFAULT(%rcx) + movq %rax,PCB_ONFAULT(%r9) - testq %r9,%r9 + testq %rcx,%rcx jz 3f subq %rdx,%r8 - movq %r8,(%r9) + movq %r8,(%rcx) 3: POP_FRAME_POINTER ret + ALIGN_TEXT +8: + movq %rax,%rdx + movq %rax,%r8 + jmp 1b + .endm +ENTRY(copyinstr_nosmap) + COPYINSTR smap=0 +END(copyinstr_nosmap) + +ENTRY(copyinstr_smap) + COPYINSTR smap=1 +END(copyinstr_smap) + cpystrflt: /* Fault entry clears PSL.AC */ movl $EFAULT,%eax cpystrflt_x: /* set *lencopied and return %eax */ - movq PCPU(CURPCB),%rcx - movq $0,PCB_ONFAULT(%rcx) + movq $0,PCB_ONFAULT(%r9) - testq %r9,%r9 + testq %rcx,%rcx jz 1f subq %rdx,%r8 - movq %r8,(%r9) + movq %r8,(%rcx) 1: POP_FRAME_POINTER ret @@ -994,14 +1003,6 @@ movl $ENAMETOOLONG,%eax jmp cpystrflt_x -ENTRY(copyinstr_nosmap) - COPYINSTR smap=0 -END(copyinstr_nosmap) - -ENTRY(copyinstr_smap) - COPYINSTR smap=1 -END(copyinstr_smap) - /* * copystr(from, to, maxlen, int *lencopied) * %rdi, %rsi, %rdx, %rcx