From 46bd727a1efacf2cee6e6e8a51dc3f720c819a0f Mon Sep 17 00:00:00 2001 From: Jung-uk Kim Date: Sat, 31 Mar 2007 01:47:37 +0000 Subject: [PATCH] Correct BB-profiling and adjust comments. Pointed out by: bde Reviewed by: bde --- sys/amd64/amd64/support.S | 86 ++++++++++++++++++------------------ sys/i386/i386/support.s | 91 +++++++++++++++++++-------------------- 2 files changed, 88 insertions(+), 89 deletions(-) diff --git a/sys/amd64/amd64/support.S b/sys/amd64/amd64/support.S index eede26af3e80..c828877a2fbc 100644 --- a/sys/amd64/amd64/support.S +++ b/sys/amd64/amd64/support.S @@ -671,6 +671,49 @@ ENTRY(longjmp) incl %eax ret +/*****************************************************************************/ +/* linux_futex support */ +/*****************************************************************************/ + +futex_fault: + movq $0,PCB_ONFAULT(%rcx) + movq $-EFAULT,%rax + ret + +ENTRY(futex_xchgl) + movq PCPU(CURPCB),%rcx + movq $futex_fault,PCB_ONFAULT(%rcx) + + movq $VM_MAXUSER_ADDRESS-4,%rax + cmpq %rax,%rsi + ja futex_fault + +#ifdef SMP + lock +#endif + xchgl %edi,(%rsi) + movl %edi,(%rdx) + xorl %eax,%eax + movq %rax,PCB_ONFAULT(%rcx) + ret + +ENTRY(futex_addl) + movq PCPU(CURPCB),%rcx + movq $futex_fault,PCB_ONFAULT(%rcx) + + movq $VM_MAXUSER_ADDRESS-4,%rax + cmpq %rax,%rsi + ja futex_fault + +#ifdef SMP + lock +#endif + xaddl %edi,(%rsi) + movl %edi,(%rdx) + xorl %eax,%eax + movq %rax,PCB_ONFAULT(%rcx) + ret + /* * Support for BB-profiling (gcc -a). The kernbb program will extract * the data from the kernel. @@ -689,46 +732,3 @@ NON_GPROF_ENTRY(__bb_init_func) movq %rax,32(%rdi) movq %rdi,bbhead NON_GPROF_RET - - .text - -futex_fault: - movq $0,PCB_ONFAULT(%rcx) - movq $-EFAULT,%rax - ret - -/* int futex_xchgl(int oparg, caddr_t uaddr, int *oldval); */ -ENTRY(futex_xchgl) - movq PCPU(CURPCB),%rcx - movq $futex_fault,PCB_ONFAULT(%rcx) - - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - -#ifdef SMP - lock -#endif - xchgl %edi,(%rsi) - movl %edi,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%rcx) - ret - -/* int futex_addl(int oparg, caddr_t uaddr, int *oldval); */ -ENTRY(futex_addl) - movq PCPU(CURPCB),%rcx - movq $futex_fault,PCB_ONFAULT(%rcx) - - movq $VM_MAXUSER_ADDRESS-4,%rax - cmpq %rax,%rsi - ja futex_fault - -#ifdef SMP - lock -#endif - xaddl %edi,(%rsi) - movl %edi,(%rdx) - xorl %eax,%eax - movq %rax,PCB_ONFAULT(%rcx) - ret diff --git a/sys/i386/i386/support.s b/sys/i386/i386/support.s index 546698ee2197..7d49f01ead47 100644 --- a/sys/i386/i386/support.s +++ b/sys/i386/i386/support.s @@ -1513,6 +1513,51 @@ ENTRY(longjmp) incl %eax ret +/*****************************************************************************/ +/* linux_futex support */ +/*****************************************************************************/ + +futex_fault: + movl $0,PCB_ONFAULT(%ecx) + movl $-EFAULT,%eax + ret + +ENTRY(futex_xchgl) + movl PCPU(CURPCB),%ecx + movl $futex_fault,PCB_ONFAULT(%ecx) + movl 4(%esp),%eax + movl 8(%esp),%edx + cmpl $VM_MAXUSER_ADDRESS-4,%edx + ja futex_fault + +#ifdef SMP + lock +#endif + xchgl %eax,(%edx) + movl 12(%esp),%edx + movl %eax,(%edx) + xorl %eax,%eax + movl $0,PCB_ONFAULT(%ecx) + ret + +ENTRY(futex_addl) + movl PCPU(CURPCB),%ecx + movl $futex_fault,PCB_ONFAULT(%ecx) + movl 4(%esp),%eax + movl 8(%esp),%edx + cmpl $VM_MAXUSER_ADDRESS-4,%edx + ja futex_fault + +#ifdef SMP + lock +#endif + xaddl %eax,(%edx) + movl 12(%esp),%edx + movl %eax,(%edx) + xorl %eax,%eax + movl $0,PCB_ONFAULT(%ecx) + ret + /* * Support for BB-profiling (gcc -a). The kernbb program will extract * the data from the kernel. @@ -1532,49 +1577,3 @@ NON_GPROF_ENTRY(__bb_init_func) movl %edx,16(%eax) movl %eax,bbhead NON_GPROF_RET - -/* necessary for linux_futex support */ - .text - -futex_fault: - movl $0,PCB_ONFAULT(%ecx) - movl $-EFAULT,%eax - ret - -/* int futex_xchgl(int oparg, caddr_t uaddr, int *oldval); */ -ENTRY(futex_xchgl) - movl PCPU(CURPCB),%ecx - movl $futex_fault,PCB_ONFAULT(%ecx) - movl 4(%esp),%eax - movl 8(%esp),%edx - cmpl $VM_MAXUSER_ADDRESS-4,%edx - ja futex_fault - -#ifdef SMP - lock -#endif - xchgl %eax,(%edx) - movl 12(%esp),%edx - movl %eax,(%edx) - xorl %eax,%eax - movl $0,PCB_ONFAULT(%ecx) - ret - -/* int futex_addl(int oparg, caddr_t uaddr, int *oldval); */ -ENTRY(futex_addl) - movl PCPU(CURPCB),%ecx - movl $futex_fault,PCB_ONFAULT(%ecx) - movl 4(%esp),%eax - movl 8(%esp),%edx - cmpl $VM_MAXUSER_ADDRESS-4,%edx - ja futex_fault - -#ifdef SMP - lock -#endif - xaddl %eax,(%edx) - movl 12(%esp),%edx - movl %eax,(%edx) - xorl %eax,%eax - movl $0,PCB_ONFAULT(%ecx) - ret