From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from pentafluge.infradead.org (pentafluge.infradead.org [213.146.154.40]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTP id DAEE367BB3 for ; Tue, 5 Sep 2006 14:53:24 +1000 (EST) Subject: Re: [PATCH] Unwire set/get_robust_list From: David Woodhouse To: Paul Mackerras In-Reply-To: <17660.48525.873588.173047@cargo.ozlabs.ibm.com> References: <1157409148.2473.209.camel@shinybook.infradead.org> <17660.48525.873588.173047@cargo.ozlabs.ibm.com> Content-Type: text/plain Date: Mon, 04 Sep 2006 21:53:14 -0700 Message-Id: <1157431994.2413.6.camel@shinybook.infradead.org> Mime-Version: 1.0 Cc: linuxppc-dev@ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , On Tue, 2006-09-05 at 09:58 +1000, Paul Mackerras wrote: > Don't we need an access_ok() test in there? Otherwise, looks fine to > me. Oops, good point. Like this then... Do we actually need the memory clobber, btw? We're not using this for locking in kernel space. [PATCH] Implement PowerPC futex_atomic_cmpxchg_inatomic(). The sys_[gs]et_robust_list() syscalls were wired up on PowerPC but didn't work correctly because futex_atomic_cmpxchg_inatomic() wasn't implemented. Implement it, based on __cmpxchg_u32() Signed-off-by: David Woodhouse diff --git a/include/asm-powerpc/futex.h b/include/asm-powerpc/futex.h index f1b3c00..936422e 100644 --- a/include/asm-powerpc/futex.h +++ b/include/asm-powerpc/futex.h @@ -84,7 +84,33 @@ static inline int futex_atomic_op_inuser static inline int futex_atomic_cmpxchg_inatomic(int __user *uaddr, int oldval, int newval) { - return -ENOSYS; + int prev; + + if (!access_ok(VERIFY_WRITE, uaddr, sizeof(int))) + return -EFAULT; + + __asm__ __volatile__ ( + LWSYNC_ON_SMP +"1: lwarx %0,0,%2 # futex_atomic_cmpxchg_inatomic\n\ + cmpw 0,%0,%3\n\ + bne- 3f\n" + PPC405_ERR77(0,%2) +"2: stwcx. %4,0,%2\n\ + bne- 1b\n" + ISYNC_ON_SMP +"3: .section .fixup,\"ax\"\n\ +4: li %0,%5\n\ + b 3b\n\ + .previous\n\ + .section __ex_table,\"a\"\n\ + .align 3\n\ + " PPC_LONG "1b,4b,2b,4b\n\ + .previous" \ + : "=&r" (prev), "+m" (*uaddr) + : "r" (uaddr), "r" (oldval), "r" (newval), "i" (-EFAULT) + : "cc", "memory"); + + return prev; } #endif /* __KERNEL__ */ -- dwmw2