am 9306d2a2: am bc86e156: am 22323f91: Merge "Fix aarch64 futex assembly routines."

* commit '9306d2a21f281b505582cd8710546decc92bf497':
  Fix aarch64 futex assembly routines.
This commit is contained in:
Elliott Hughes 2013-12-21 01:37:04 +00:00 committed by Android Git Automerger
commit 6ae8ab2896
8 changed files with 59 additions and 117 deletions

View File

@ -31,97 +31,56 @@
#define FUTEX_WAIT 0 #define FUTEX_WAIT 0
#define FUTEX_WAKE 1 #define FUTEX_WAKE 1
/* // int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
* Syscall interface for fast userspace locks
*
* int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout);
* int __futex_wake(volatile void *ftx, int count);
* int __futex_syscall3(volatile void *ftx, int op, int val);
* int __futex_syscall4(volatile void *ftx, int op, int val, const struct timespec *timeout);
*/
ENTRY(__futex_syscall4) ENTRY(__futex_syscall4)
/* create AArch64 PCS frame pointer */ stp x29, x30, [sp, #-16]!
stp x29, x30, [sp, #-16]! mov x29, sp
mov x29, sp
/* store x8 */ str x8, [sp, #-16]!
str x8, [sp, #-16]! mov x8, __NR_futex
svc #0
ldr x8, [sp], #16
/* syscall No. in x8 */ ldp x29, x30, [sp], #16
mov x8, __NR_futex ret
svc #0
/* restore x8 */
ldr x8, [sp], #16
ldp x29, x30, [sp], #16
/* check if syscall returned successfully */
cmn x0, #(MAX_ERRNO + 1)
cneg x0, x0, hi
b.hi __set_errno
ret
END(__futex_syscall4) END(__futex_syscall4)
// int __futex_syscall3(volatile void* ftx, int op, int count)
ENTRY(__futex_syscall3) ENTRY(__futex_syscall3)
/* __futex_syscall4 but with fewer arguments */ b __futex_syscall4
b __futex_syscall4
END(__futex_syscall3) END(__futex_syscall3)
// int __futex_wait(volatile void* ftx, int val, const struct timespec* timeout)
ENTRY(__futex_wait) ENTRY(__futex_wait)
/* create AArch64 PCS frame pointer */ stp x29, x30, [sp, #-16]!
stp x29, x30, [sp, #-16]! mov x29, sp
mov x29, sp
/* store x8 */ mov x3, x2
str x8, [sp, #-16]! mov x2, x1
mov x1, #FUTEX_WAIT
/* arange arguments as expected in the kernel side */ str x8, [sp, #-16]!
mov x3, x2 mov x8, __NR_futex
mov w2, w1 svc #0
mov w1, #FUTEX_WAIT ldr x8, [sp], #16
/* syscall No. in X8 */ ldp x29, x30, [sp], #16
mov x8, __NR_futex ret
svc #0
/* restore x8 */
ldr x8, [sp], #16
ldp x29, x30, [sp], #16
/* check if syscall returned successfully */
cmn x0, #(MAX_ERRNO + 1)
cneg x0, x0, hi
b.hi __set_errno
ret
END(__futex_wait) END(__futex_wait)
// int __futex_wake(volatile void* ftx, int count)
ENTRY(__futex_wake) ENTRY(__futex_wake)
/* create AArch64 PCS frame pointer */ stp x29, x30, [sp, #-16]!
stp x29, x30, [sp, #-16]! mov x29, sp
mov x29, sp
/* store x8 */ mov x2, x1
str x8, [sp, #-16]! mov x1, #FUTEX_WAKE
/* arange arguments as expected in the kernel side */ str x8, [sp, #-16]!
mov w2, w1 mov x8, __NR_futex
mov w1, #FUTEX_WAIT svc #0
ldr x8, [sp], #16
/* syscall No. in X8 */ ldp x29, x30, [sp], #16
mov x8, __NR_futex ret
svc #0
/* restore x8 */
ldr x8, [sp], #16
ldp x29, x30, [sp], #16
/* check if syscall returned successfully */
cmn x0, #(MAX_ERRNO + 1)
cneg x0, x0, hi
b.hi __set_errno
ret
END(__futex_wake) END(__futex_wake)

View File

@ -26,13 +26,12 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <asm/unistd.h> #include <private/bionic_asm.h>
#include <machine/asm.h>
#define FUTEX_WAIT 0 #define FUTEX_WAIT 0
#define FUTEX_WAKE 1 #define FUTEX_WAKE 1
// __futex_syscall3(*ftx, op, val) // int __futex_syscall3(volatile void* ftx, int op, int count)
ENTRY(__futex_syscall3) ENTRY(__futex_syscall3)
mov ip, r7 mov ip, r7
ldr r7, =__NR_futex ldr r7, =__NR_futex
@ -41,12 +40,12 @@ ENTRY(__futex_syscall3)
bx lr bx lr
END(__futex_syscall3) END(__futex_syscall3)
// __futex_syscall4(*ftx, op, val, *timespec) // int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
ENTRY(__futex_syscall4) ENTRY(__futex_syscall4)
b __futex_syscall3 b __futex_syscall3
END(__futex_syscall4) END(__futex_syscall4)
// __futex_wait(*ftx, val, *timespec) // int __futex_wait(volatile void* ftx, int val, const struct timespec* timeout)
ENTRY(__futex_wait) ENTRY(__futex_wait)
mov ip, r7 mov ip, r7
mov r3, r2 mov r3, r2
@ -58,7 +57,7 @@ ENTRY(__futex_wait)
bx lr bx lr
END(__futex_wait) END(__futex_wait)
// __futex_wake(*ftx, counter) // int __futex_wake(volatile void* ftx, int count)
ENTRY(__futex_wake) ENTRY(__futex_wake)
mov ip, r7 mov ip, r7
mov r2, r1 mov r2, r1

View File

@ -26,15 +26,12 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <asm/unistd.h> #include <private/bionic_asm.h>
#define FUTEX_WAIT 0 #define FUTEX_WAIT 0
#define FUTEX_WAKE 1 #define FUTEX_WAKE 1
/* // int __futex_wait(volatile void* ftx, int val, const struct timespec* timeout)
* __futex_wait(*ftx, val, *timespec)
* futex_syscall(*ftx, op, val, *timespec, *addr2, val3)
*/
.type __futex_wait, @function .type __futex_wait, @function
.global __futex_wait .global __futex_wait
.align 4 .align 4
@ -59,10 +56,7 @@ __futex_wait:
j $ra j $ra
.end __futex_wait .end __futex_wait
/* // int __futex_wake(volatile void* ftx, int count)
* int __futex_wake(volatile void *ftx, int count)
* int futex_syscall(*ftx, op, val, *timespec, *addr2, val3)
*/
.type __futex_wake, @function .type __futex_wake, @function
.globl __futex_wake .globl __futex_wake
.align 4 .align 4
@ -87,9 +81,7 @@ __futex_wake:
j $ra j $ra
.end __futex_wake .end __futex_wake
/* __futex_syscall3(*ftx, op, val) // int __futex_syscall3(volatile void* ftx, int op, int count)
* futex_syscall(*ftx, op, val, *timespec, *addr2, val3)
*/
.type __futex_syscall3, @function .type __futex_syscall3, @function
.global __futex_syscall3 .global __futex_syscall3
.align 4 .align 4
@ -114,9 +106,7 @@ __futex_syscall3:
j $ra j $ra
.end __futex_syscall3 .end __futex_syscall3
/* __futex_syscall4(*ftx, op, val) // int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
* futex_syscall(*ftx, op, val, *timespec, *addr2, val3)
*/
.type __futex_syscall4, @function .type __futex_syscall4, @function
.global __futex_syscall4 .global __futex_syscall4
.align 4 .align 4

View File

@ -1,10 +1,9 @@
#include <asm/unistd.h> #include <private/bionic_asm.h>
#include <machine/asm.h>
#define FUTEX_WAIT 0 #define FUTEX_WAIT 0
#define FUTEX_WAKE 1 #define FUTEX_WAKE 1
// int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout) // int __futex_wait(volatile void* ftx, int val, const struct timespec* timeout)
ENTRY(__futex_wait) ENTRY(__futex_wait)
pushl %ebx pushl %ebx
pushl %esi pushl %esi
@ -19,7 +18,7 @@ ENTRY(__futex_wait)
ret ret
END(__futex_wait) END(__futex_wait)
// int __futex_wake(volatile void *ftx, int count) // int __futex_wake(volatile void* ftx, int count)
ENTRY(__futex_wake) ENTRY(__futex_wake)
pushl %ebx pushl %ebx
mov 8(%esp), %ebx /* ftx */ mov 8(%esp), %ebx /* ftx */
@ -31,7 +30,7 @@ ENTRY(__futex_wake)
ret ret
END(__futex_wake) END(__futex_wake)
// int __futex_syscall3(volatile void *ftx, int op, int count) // int __futex_syscall3(volatile void* ftx, int op, int count)
ENTRY(__futex_syscall3) ENTRY(__futex_syscall3)
pushl %ebx pushl %ebx
movl 8(%esp), %ebx /* ftx */ movl 8(%esp), %ebx /* ftx */
@ -43,7 +42,7 @@ ENTRY(__futex_syscall3)
ret ret
END(__futex_syscall3) END(__futex_syscall3)
// int __futex_syscall4(volatile void *ftx, int op, int val, const struct timespec *timeout) // int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
ENTRY(__futex_syscall4) ENTRY(__futex_syscall4)
pushl %ebx pushl %ebx
pushl %esi pushl %esi

View File

@ -26,15 +26,12 @@
* SUCH DAMAGE. * SUCH DAMAGE.
*/ */
#include <asm/unistd.h> #include <private/bionic_asm.h>
#include <machine/asm.h>
#define FUTEX_WAIT 0 #define FUTEX_WAIT 0
#define FUTEX_WAKE 1 #define FUTEX_WAKE 1
/* // int __futex_wait(volatile void* ftx, int val, const struct timespec* timeout)
* int __futex_wait(volatile void *ftx, int val, const struct timespec *timeout)
*/
ENTRY(__futex_wait) ENTRY(__futex_wait)
mov %rdx, %r10 /* timeout */ mov %rdx, %r10 /* timeout */
mov %esi, %edx /* val */ mov %esi, %edx /* val */
@ -44,8 +41,7 @@ ENTRY(__futex_wait)
ret ret
END(__futex_wait) END(__futex_wait)
/* int __futex_wake(volatile void *ftx, int count) */ // int __futex_wake(volatile void* ftx, int count)
ENTRY(__futex_wake) ENTRY(__futex_wake)
mov %esi, %edx mov %esi, %edx
mov $FUTEX_WAKE, %esi mov $FUTEX_WAKE, %esi
@ -54,14 +50,14 @@ ENTRY(__futex_wake)
ret ret
END(__futex_wake) END(__futex_wake)
/* int __futex_syscall3(volatile void *ftx, int op, int count) */ // int __futex_syscall3(volatile void* ftx, int op, int count)
ENTRY(__futex_syscall3) ENTRY(__futex_syscall3)
mov $__NR_futex, %eax mov $__NR_futex, %eax
syscall syscall
ret ret
END(__futex_syscall3) END(__futex_syscall3)
/* int __futex_syscall4(volatile void *ftx, int op, int val, const struct timespec *timeout) */ // int __futex_syscall4(volatile void* ftx, int op, int val, const struct timespec* timeout)
ENTRY(__futex_syscall4) ENTRY(__futex_syscall4)
mov %rcx, %r10 /* timeout */ mov %rcx, %r10 /* timeout */
mov $__NR_futex, %eax mov $__NR_futex, %eax

View File

@ -454,7 +454,7 @@ int __system_property_read(const prop_info *pi, char *name, char *value)
for(;;) { for(;;) {
serial = pi->serial; serial = pi->serial;
while(SERIAL_DIRTY(serial)) { while(SERIAL_DIRTY(serial)) {
__futex_wait((volatile void *)&pi->serial, serial, 0); __futex_wait((volatile void *)&pi->serial, serial, NULL);
serial = pi->serial; serial = pi->serial;
} }
len = SERIAL_VALUE_LEN(serial); len = SERIAL_VALUE_LEN(serial);
@ -572,12 +572,12 @@ int __system_property_wait(const prop_info *pi)
prop_area *pa = __system_property_area__; prop_area *pa = __system_property_area__;
n = pa->serial; n = pa->serial;
do { do {
__futex_wait(&pa->serial, n, 0); __futex_wait(&pa->serial, n, NULL);
} while(n == pa->serial); } while(n == pa->serial);
} else { } else {
n = pi->serial; n = pi->serial;
do { do {
__futex_wait((volatile void *)&pi->serial, n, 0); __futex_wait((volatile void *)&pi->serial, n, NULL);
} while(n == pi->serial); } while(n == pi->serial);
} }
return 0; return 0;
@ -635,7 +635,7 @@ unsigned int __system_property_wait_any(unsigned int serial)
prop_area *pa = __system_property_area__; prop_area *pa = __system_property_area__;
do { do {
__futex_wait(&pa->serial, serial, 0); __futex_wait(&pa->serial, serial, NULL);
} while(pa->serial == serial); } while(pa->serial == serial);
return pa->serial; return pa->serial;

View File

@ -101,7 +101,7 @@ int __system_property_read_compat(const prop_info *_pi, char *name, char *value)
for(;;) { for(;;) {
serial = pi->serial; serial = pi->serial;
while(SERIAL_DIRTY(serial)) { while(SERIAL_DIRTY(serial)) {
__futex_wait((volatile void *)&pi->serial, serial, 0); __futex_wait((volatile void *)&pi->serial, serial, NULL);
serial = pi->serial; serial = pi->serial;
} }
len = SERIAL_VALUE_LEN(serial); len = SERIAL_VALUE_LEN(serial);

View File

@ -28,7 +28,6 @@
#ifndef _BIONIC_FUTEX_H #ifndef _BIONIC_FUTEX_H
#define _BIONIC_FUTEX_H #define _BIONIC_FUTEX_H
#include <linux/compiler.h> /* needed for __user in non-uapi futex.h */
#include <linux/futex.h> #include <linux/futex.h>
#include <sys/cdefs.h> #include <sys/cdefs.h>