Date: Tue, 8 Apr 2003 01:52:47 -0700 (PDT) From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 28504 for review Message-ID: <200304080852.h388qkxA011910@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=28504 Change 28504 by peter@peter_daintree on 2003/04/08 01:52:25 actually use hammer-style calling conventions rather than i386 style stack based conventions. This is both a blessing and a curse. Affected files ... .. //depot/projects/hammer/sys/x86_64/x86_64/support.s#16 edit Differences ... ==== //depot/projects/hammer/sys/x86_64/x86_64/support.s#16 (text+ko) ==== @@ -63,17 +63,12 @@ /* * copyout(from_kernel, to_user, len) - MP SAFE + * %rdi, %rsi, %rdx */ ENTRY(copyout) movq PCPU(CURPCB),%rax movq $copyout_fault,PCB_ONFAULT(%rax) - pushq %rsi - pushq %rdi - pushq %rbx - movq 32(%rsp),%rsi - movq 40(%rsp),%rdi - movq 48(%rsp),%rbx - testl %ebx,%ebx /* anything to do? */ + testq %rdx,%rdx /* anything to do? */ jz done_copyout /* @@ -86,8 +81,8 @@ /* * First, prevent address wrapping. */ - movq %rdi,%rax - addq %rbx,%rax + movq %rsi,%rax + addq %rdx,%rax jc copyout_fault /* * XXX STOP USING VM_MAXUSER_ADDRESS. @@ -99,8 +94,9 @@ cmpq %rcx,%rax ja copyout_fault - /* bcopy(%rsi, %rdi, %rbx) */ - movq %rbx,%rcx + xchgq %rdi, %rsi + /* bcopy(%rsi, %rdi, %rdx) */ + movq %rdx,%rcx shrq $3,%rcx cld @@ -112,9 +108,6 @@ movsb done_copyout: - popq %rbx - popq %rdi - popq %rsi xorq %rax,%rax movq PCPU(CURPCB),%rdx movq %rax,PCB_ONFAULT(%rdx) @@ -122,9 +115,6 @@ ALIGN_TEXT copyout_fault: - popq %rbx - popq %rdi - popq %rsi movq PCPU(CURPCB),%rdx movq $0,PCB_ONFAULT(%rdx) movq $EFAULT,%rax @@ -132,26 +122,26 @@ /* * copyin(from_user, to_kernel, len) - MP SAFE + * %rdi, %rsi, %rdx */ ENTRY(copyin) movq PCPU(CURPCB),%rax movq $copyin_fault,PCB_ONFAULT(%rax) - pushq %rsi - pushq %rdi - movq 24(%rsp),%rsi /* caddr_t from */ - movq 32(%rsp),%rdi /* caddr_t to */ - movq 40(%rsp),%rcx /* size_t len */ + testq %rdx,%rdx /* anything to do? */ + jz done_copyin /* * make sure address is valid */ - movq %rsi,%rdx - addq %rcx,%rdx + movq %rdi,%rax + addq %rdx,%rax jc copyin_fault - movq $VM_MAXUSER_ADDRESS,%rax - cmpq %rax,%rdx + movq $VM_MAXUSER_ADDRESS,%rcx + cmpq %rcx,%rax ja copyin_fault + xchgq %rdi, %rsi + movq %rdx, %rcx movb %cl,%al shrq $3,%rcx /* copy longword-wise */ cld @@ -162,8 +152,7 @@ rep movsb - popq %rdi - popq %rsi +done_copyin: xorq %rax,%rax movq PCPU(CURPCB),%rdx movq %rax,PCB_ONFAULT(%rdx) @@ -171,8 +160,6 @@ ALIGN_TEXT copyin_fault: - popq %rdi - popq %rsi movq PCPU(CURPCB),%rdx movq $0,PCB_ONFAULT(%rdx) movq $EFAULT,%rax @@ -180,19 +167,18 @@ /* * casuptr. Compare and set user pointer. Returns -1 or the current value. + * dst = %rdi, old = %rsi, new = %rdx */ ENTRY(casuptr) movq PCPU(CURPCB),%rcx movq $fusufault,PCB_ONFAULT(%rcx) - movq 8(%rsp),%rdx /* dst */ movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rdx /* verify address is valid */ + cmpq %rax,%rdi /* verify address is valid */ ja fusufault - movq 16(%rsp),%rax /* old */ - movq 24(%rsp),%rcx /* new */ - cmpxchgq %rcx, (%rdx) + movq %rsi, %rax /* old */ + cmpxchgq %rdx, (%rdi) /* new = %rdx */ /* * The old value is in %eax. If the store succeeded it will be the @@ -209,32 +195,31 @@ * fu{byte,sword,word} - MP SAFE * * Fetch a byte (sword, word) from user memory + * %rdi */ ENTRY(fuword64) movq PCPU(CURPCB),%rcx movq $fusufault,PCB_ONFAULT(%rcx) - movq 8(%rsp),%rdx /* from */ movq $VM_MAXUSER_ADDRESS-8,%rax - cmpq %rax,%rdx /* verify address is valid */ + cmpq %rax,%rdi /* verify address is valid */ ja fusufault - movq (%rdx),%rax + movq (%rdi),%rax movq $0,PCB_ONFAULT(%rcx) ret ENTRY(fuword32) movq PCPU(CURPCB),%rcx movq $fusufault,PCB_ONFAULT(%rcx) - movq 8(%rsp),%rdx /* from */ movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rdx /* verify address is valid */ + cmpq %rax,%rdi /* verify address is valid */ ja fusufault # XXX use the 64 extend xorq %rax, %rax - movl (%rdx),%eax + movl (%rdi),%eax movq $0,PCB_ONFAULT(%rcx) ret @@ -258,15 +243,14 @@ ENTRY(fuword16) movq PCPU(CURPCB),%rcx movq $fusufault,PCB_ONFAULT(%rcx) - movq 8(%rsp),%rdx movq $VM_MAXUSER_ADDRESS-2,%rax - cmpq %rax,%rdx + cmpq %rax,%rdi ja fusufault # XXX use the 64 extend xorq %rax, %rax - movzwl (%rdx),%eax + movzwl (%rdi),%eax movq $0,PCB_ONFAULT(%rcx) ret @@ -276,15 +260,14 @@ ENTRY(fubyte) movq PCPU(CURPCB),%rcx movq $fusufault,PCB_ONFAULT(%rcx) - movq 8(%rsp),%rdx movq $VM_MAXUSER_ADDRESS-1,%rax - cmpq %rax,%rdx + cmpq %rax,%rdi ja fusufault # XXX use the 64 extend xorq %rax, %rax - movzbl (%rdx),%eax + movzbl (%rdi),%eax movq $0,PCB_ONFAULT(%rcx) ret @@ -300,18 +283,17 @@ * su{byte,sword,word} - MP SAFE * * Write a byte (word, longword) to user memory + * addr = %rdi, value = %rsi */ ENTRY(suword64) movq PCPU(CURPCB),%rcx movq $fusufault,PCB_ONFAULT(%rcx) - movq 8(%rsp),%rdx movq $VM_MAXUSER_ADDRESS-8,%rax - cmpq %rax,%rdx /* verify address validity */ + cmpq %rax,%rdi /* verify address validity */ ja fusufault - movq 16(%rsp),%rax - movq %rax,(%rdx) + movq %rsi,(%rdi) xorq %rax,%rax movq PCPU(CURPCB),%rcx movq %rax,PCB_ONFAULT(%rcx) @@ -320,14 +302,12 @@ ENTRY(suword32) movq PCPU(CURPCB),%rcx movq $fusufault,PCB_ONFAULT(%rcx) - movq 8(%rsp),%rdx movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rdx /* verify address validity */ + cmpq %rax,%rdi /* verify address validity */ ja fusufault - movl 16(%rsp),%eax - movl %eax,(%rdx) + movl %esi,(%rdi) xorq %rax,%rax movq PCPU(CURPCB),%rcx movq %rax,PCB_ONFAULT(%rcx) @@ -342,14 +322,12 @@ ENTRY(suword16) movq PCPU(CURPCB),%rcx movq $fusufault,PCB_ONFAULT(%rcx) - movq 8(%rsp),%rdx movq $VM_MAXUSER_ADDRESS-2,%rax - cmpq %rax,%rdx /* verify address validity */ + cmpq %rax,%rdi /* verify address validity */ ja fusufault - movw 16(%rsp),%ax - movw %ax,(%rdx) + movw %si,(%rdi) xorq %rax,%rax movq PCPU(CURPCB),%rcx /* restore trashed register */ movq %rax,PCB_ONFAULT(%rcx) @@ -361,14 +339,13 @@ ENTRY(subyte) movq PCPU(CURPCB),%rcx movq $fusufault,PCB_ONFAULT(%rcx) - movq 8(%rsp),%rdx movq $VM_MAXUSER_ADDRESS-1,%rax - cmpq %rax,%rdx /* verify address validity */ + cmpq %rax,%rdi /* verify address validity */ ja fusufault - movb 16(%rsp),%al - movb %al,(%rdx) + movl %esi, %eax + movb %al,(%rdi) xorq %rax,%rax movq PCPU(CURPCB),%rcx /* restore trashed register */ movq %rax,PCB_ONFAULT(%rcx) @@ -376,6 +353,7 @@ /* * copyinstr(from, to, maxlen, int *lencopied) - MP SAFE + * %rdi, %rsi, %rdx, %rcx * * copy a string from from to to, stop when a 0 character is reached. * return ENAMETOOLONG if string is longer than maxlen, and @@ -383,15 +361,12 @@ * return the actual length in *lencopied. */ ENTRY(copyinstr) - pushq %rsi - pushq %rdi movq PCPU(CURPCB),%rcx movq $cpystrflt,PCB_ONFAULT(%rcx) + movq %rdx, %r8 /* %r8 = maxlen */ + movq %rcx, %r9 /* %r9 = *len */ + xchgq %rdi, %rsi /* %rdi = from, %rsi = to */ - movq 24(%rsp),%rsi /* %esi = from */ - movq 32(%rsp),%rdi /* %edi = to */ - movq 40(%rsp),%rdx /* %edx = maxlen */ - movq $VM_MAXUSER_ADDRESS,%rax /* make sure 'from' is within bounds */ @@ -402,7 +377,7 @@ cmpq %rdx,%rax jae 1f movq %rax,%rdx - movq %rax,40(%rsp) + movq %rax,%r8 1: incq %rdx cld @@ -436,28 +411,23 @@ /* set *lencopied and return %eax */ movq PCPU(CURPCB),%rcx movq $0,PCB_ONFAULT(%rcx) - movq 40(%rsp),%rcx - subq %rdx,%rcx - movq 48(%rsp),%rdx - testq %rdx,%rdx + + testq %r9,%r9 jz 1f - movq %rcx,(%rdx) + subq %rdx,%r8 + movq %r8,(%r9) 1: - popq %rdi - popq %rsi ret /* * copystr(from, to, maxlen, int *lencopied) - MP SAFE + * %rdi, %rsi, %rdx, %rcx */ ENTRY(copystr) - pushq %rsi - pushq %rdi + movq %rdx, %r8 /* %r8 = maxlen */ - movq 24(%rsp),%rsi /* %esi = from */ - movq 32(%rsp),%rdi /* %edi = to */ - movq 40(%rsp),%rdx /* %edx = maxlen */ + xchgq %rdi, %rsi incq %rdx cld 1: @@ -477,20 +447,18 @@ movq $ENAMETOOLONG,%rax 6: + + testq %rcx, %rcx + jz 7f /* set *lencopied and return %rax */ - movq 40(%rsp),%rcx - subq %rdx,%rcx - movq 48(%rsp),%rdx - testq %rdx,%rdx - jz 7f - movq %rcx,(%rdx) + subq %rdx, %r8 + movq %r8, (%rcx) 7: - popq %rdi - popq %rsi ret /* * Handling of special 386 registers and descriptor tables etc + * %rdi */ /* void lgdt(struct region_descriptor *rdp); */ ENTRY(lgdt) @@ -501,12 +469,6 @@ jmp 1f nop 1: - /* reload "stale" selectors */ - movl $KDSEL,%eax - mov %ax,%ds - mov %ax,%es - mov %ax,%ss - /* reload code selector by turning return into intersegmental return */ popq %rax pushq $KCSEL
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200304080852.h388qkxA011910>