diff --git a/sys/i386/i386/support.s b/sys/i386/i386/support.s index 1e970da67ca7..c3ac17314019 100644 --- a/sys/i386/i386/support.s +++ b/sys/i386/i386/support.s @@ -1522,6 +1522,12 @@ ENTRY(longjmp) bbhead: .long 0 +#if defined(SMP) || !defined(_KERNEL) +#define MPLOCKED lock ; +#else +#define MPLOCKED +#endif + .text NON_GPROF_ENTRY(__bb_init_func) movl 4(%esp),%eax @@ -1530,3 +1536,108 @@ 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 PCPU(CURPCB), %edx + movl $0, PCB_ONFAULT(%edx) + movl $-EFAULT, %eax + ret + +/* int futex_xchgl(int oparg, caddr_t uaddr, int *oldval); */ + .globl futex_xchgl +futex_xchgl: + movl PCPU(CURPCB), %eax + movl $futex_fault, PCB_ONFAULT(%eax) + movl 4(%esp), %eax + movl 8(%esp), %edx + cmpl $VM_MAXUSER_ADDRESS,%edx + ja futex_fault + + MPLOCKED xchgl %eax, (%edx) + movl 0xc(%esp), %edx + movl %eax, (%edx) + xorl %eax, %eax + + movl PCPU(CURPCB), %edx + movl $0, PCB_ONFAULT(%edx) + ret + +/* int futex_addl(int oparg, caddr_t uaddr, int *oldval); */ + .globl futex_addl +futex_addl: + movl PCPU(CURPCB), %eax + movl $futex_fault, PCB_ONFAULT(%eax) + movl 4(%esp), %eax + movl 8(%esp), %edx + cmpl $VM_MAXUSER_ADDRESS,%edx + ja futex_fault + + MPLOCKED xaddl %eax, (%edx) + movl 0xc(%esp), %edx + movl %eax, (%edx) + xorl %eax, %eax + + movl PCPU(CURPCB), %edx + movl $0, PCB_ONFAULT(%edx) + ret + +/* int futex_orl(int oparg, caddr_t uaddr, int *oldval); */ + .globl futex_orl +futex_orl: + movl PCPU(CURPCB), %eax + movl $futex_fault, PCB_ONFAULT(%eax) + movl 4(%esp), %eax + movl 8(%esp), %edx + cmpl $VM_MAXUSER_ADDRESS,%edx + ja futex_fault + + MPLOCKED orl %eax, (%edx) + movl 0xc(%esp), %edx + movl %eax, (%edx) + xorl %eax, %eax + + movl PCPU(CURPCB), %edx + movl $0, PCB_ONFAULT(%edx) + ret + +/* int futex_andnl(int oparg, caddr_t uaddr, int *oldval); */ + .globl futex_andnl +futex_andnl: + movl PCPU(CURPCB), %eax + movl $futex_fault, PCB_ONFAULT(%eax) + movl 4(%esp), %eax + movl 8(%esp), %edx + cmpl $VM_MAXUSER_ADDRESS,%edx + ja futex_fault + + notl (%edx) + MPLOCKED andl %eax, (%edx) + movl 0xc(%esp), %edx + movl %eax, (%edx) + xorl %eax, %eax + + movl PCPU(CURPCB), %edx + movl $0, PCB_ONFAULT(%edx) + ret + +/* int futex_xorl(int oparg, caddr_t uaddr, int *oldval); */ + .globl futex_xorl +futex_xorl: + movl PCPU(CURPCB), %eax + movl $futex_fault, PCB_ONFAULT(%eax) + movl 4(%esp), %eax + movl 8(%esp), %edx + cmpl $VM_MAXUSER_ADDRESS,%edx + ja futex_fault + + MPLOCKED xorl %eax, (%edx) + movl 0xc(%esp), %edx + movl %eax, (%edx) + xorl %eax, %eax + + movl PCPU(CURPCB), %edx + movl $0, PCB_ONFAULT(%edx) + ret