[MIPS] Fix futex_atomic_op_inuser.
I found that NPTL's pthread_cond_signal() does not work properly on kernels compiled by gcc 4.1.x. I suppose inline asm for __futex_atomic_op() was wrong. I suppose: 1. "=&r" constraint should be used for oldval. 2. Instead of "r" (uaddr), "=R" (*uaddr) for output and "R" (*uaddr) for input should be used. 3. "memory" should be added to the clobber list. Signed-off-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
This commit is contained in:
parent
e1701fb2e2
commit
0307e8d024
1 changed files with 17 additions and 15 deletions
|
@ -22,51 +22,53 @@
|
||||||
" .set push \n" \
|
" .set push \n" \
|
||||||
" .set noat \n" \
|
" .set noat \n" \
|
||||||
" .set mips3 \n" \
|
" .set mips3 \n" \
|
||||||
"1: ll %1, (%3) # __futex_atomic_op \n" \
|
"1: ll %1, %4 # __futex_atomic_op \n" \
|
||||||
" .set mips0 \n" \
|
" .set mips0 \n" \
|
||||||
" " insn " \n" \
|
" " insn " \n" \
|
||||||
" .set mips3 \n" \
|
" .set mips3 \n" \
|
||||||
"2: sc $1, (%3) \n" \
|
"2: sc $1, %2 \n" \
|
||||||
" beqzl $1, 1b \n" \
|
" beqzl $1, 1b \n" \
|
||||||
__FUTEX_SMP_SYNC \
|
__FUTEX_SMP_SYNC \
|
||||||
"3: \n" \
|
"3: \n" \
|
||||||
" .set pop \n" \
|
" .set pop \n" \
|
||||||
" .set mips0 \n" \
|
" .set mips0 \n" \
|
||||||
" .section .fixup,\"ax\" \n" \
|
" .section .fixup,\"ax\" \n" \
|
||||||
"4: li %0, %5 \n" \
|
"4: li %0, %6 \n" \
|
||||||
" j 2b \n" \
|
" j 2b \n" \
|
||||||
" .previous \n" \
|
" .previous \n" \
|
||||||
" .section __ex_table,\"a\" \n" \
|
" .section __ex_table,\"a\" \n" \
|
||||||
" "__UA_ADDR "\t1b, 4b \n" \
|
" "__UA_ADDR "\t1b, 4b \n" \
|
||||||
" "__UA_ADDR "\t2b, 4b \n" \
|
" "__UA_ADDR "\t2b, 4b \n" \
|
||||||
" .previous \n" \
|
" .previous \n" \
|
||||||
: "=r" (ret), "=r" (oldval) \
|
: "=r" (ret), "=&r" (oldval), "=R" (*uaddr) \
|
||||||
: "0" (0), "r" (uaddr), "Jr" (oparg), "i" (-EFAULT)); \
|
: "0" (0), "R" (*uaddr), "Jr" (oparg), "i" (-EFAULT) \
|
||||||
|
: "memory"); \
|
||||||
} else if (cpu_has_llsc) { \
|
} else if (cpu_has_llsc) { \
|
||||||
__asm__ __volatile__( \
|
__asm__ __volatile__( \
|
||||||
" .set push \n" \
|
" .set push \n" \
|
||||||
" .set noat \n" \
|
" .set noat \n" \
|
||||||
" .set mips3 \n" \
|
" .set mips3 \n" \
|
||||||
"1: ll %1, (%3) # __futex_atomic_op \n" \
|
"1: ll %1, %4 # __futex_atomic_op \n" \
|
||||||
" .set mips0 \n" \
|
" .set mips0 \n" \
|
||||||
" " insn " \n" \
|
" " insn " \n" \
|
||||||
" .set mips3 \n" \
|
" .set mips3 \n" \
|
||||||
"2: sc $1, (%3) \n" \
|
"2: sc $1, %2 \n" \
|
||||||
" beqz $1, 1b \n" \
|
" beqz $1, 1b \n" \
|
||||||
__FUTEX_SMP_SYNC \
|
__FUTEX_SMP_SYNC \
|
||||||
"3: \n" \
|
"3: \n" \
|
||||||
" .set pop \n" \
|
" .set pop \n" \
|
||||||
" .set mips0 \n" \
|
" .set mips0 \n" \
|
||||||
" .section .fixup,\"ax\" \n" \
|
" .section .fixup,\"ax\" \n" \
|
||||||
"4: li %0, %5 \n" \
|
"4: li %0, %6 \n" \
|
||||||
" j 2b \n" \
|
" j 2b \n" \
|
||||||
" .previous \n" \
|
" .previous \n" \
|
||||||
" .section __ex_table,\"a\" \n" \
|
" .section __ex_table,\"a\" \n" \
|
||||||
" "__UA_ADDR "\t1b, 4b \n" \
|
" "__UA_ADDR "\t1b, 4b \n" \
|
||||||
" "__UA_ADDR "\t2b, 4b \n" \
|
" "__UA_ADDR "\t2b, 4b \n" \
|
||||||
" .previous \n" \
|
" .previous \n" \
|
||||||
: "=r" (ret), "=r" (oldval) \
|
: "=r" (ret), "=&r" (oldval), "=R" (*uaddr) \
|
||||||
: "0" (0), "r" (uaddr), "Jr" (oparg), "i" (-EFAULT)); \
|
: "0" (0), "R" (*uaddr), "Jr" (oparg), "i" (-EFAULT) \
|
||||||
|
: "memory"); \
|
||||||
} else \
|
} else \
|
||||||
ret = -ENOSYS; \
|
ret = -ENOSYS; \
|
||||||
}
|
}
|
||||||
|
@ -89,23 +91,23 @@ futex_atomic_op_inuser (int encoded_op, int __user *uaddr)
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case FUTEX_OP_SET:
|
case FUTEX_OP_SET:
|
||||||
__futex_atomic_op("move $1, %z4", ret, oldval, uaddr, oparg);
|
__futex_atomic_op("move $1, %z5", ret, oldval, uaddr, oparg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FUTEX_OP_ADD:
|
case FUTEX_OP_ADD:
|
||||||
__futex_atomic_op("addu $1, %1, %z4",
|
__futex_atomic_op("addu $1, %1, %z5",
|
||||||
ret, oldval, uaddr, oparg);
|
ret, oldval, uaddr, oparg);
|
||||||
break;
|
break;
|
||||||
case FUTEX_OP_OR:
|
case FUTEX_OP_OR:
|
||||||
__futex_atomic_op("or $1, %1, %z4",
|
__futex_atomic_op("or $1, %1, %z5",
|
||||||
ret, oldval, uaddr, oparg);
|
ret, oldval, uaddr, oparg);
|
||||||
break;
|
break;
|
||||||
case FUTEX_OP_ANDN:
|
case FUTEX_OP_ANDN:
|
||||||
__futex_atomic_op("and $1, %1, %z4",
|
__futex_atomic_op("and $1, %1, %z5",
|
||||||
ret, oldval, uaddr, ~oparg);
|
ret, oldval, uaddr, ~oparg);
|
||||||
break;
|
break;
|
||||||
case FUTEX_OP_XOR:
|
case FUTEX_OP_XOR:
|
||||||
__futex_atomic_op("xor $1, %1, %z4",
|
__futex_atomic_op("xor $1, %1, %z5",
|
||||||
ret, oldval, uaddr, oparg);
|
ret, oldval, uaddr, oparg);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue