From 1ecad9a95c1343e0a3f2f43c3bcbe7d7a5894447 Mon Sep 17 00:00:00 2001 From: Chih-Wei Huang Date: Fri, 8 May 2009 10:44:30 +0800 Subject: [PATCH 1/2] Fix uninitialized variable loop The following command will usually just fail # /system/bin/mount -t proc proc /proc ioctl LOOP_SET_FD failed: Bad file number The simple patch fixes the issue. --- toolbox/mount.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/toolbox/mount.c b/toolbox/mount.c index 395c9433a..472c952e7 100644 --- a/toolbox/mount.c +++ b/toolbox/mount.c @@ -226,7 +226,7 @@ int mount_main(int argc, char *argv[]) { char *type = NULL; int c; - int loop; + int loop = 0; progname = argv[0]; rwflag = MS_VERBOSE; From 02608475edd7c42303c9c515aae270fb8b32032a Mon Sep 17 00:00:00 2001 From: Vinay HARUGOP Date: Thu, 10 Sep 2009 00:31:12 +0530 Subject: [PATCH 2/2] ARM architecture reference manuals for ARMv6 & ARMv7 state that the use of 'swp' instruction is deprecated ARMv6 onwards. These architectures provide the load-linked, store-conditional pair of ldrex/strex whose use is recommended in place of 'swp'. Also, the description of the 'swp' instruction in the ARMv6 reference manual states that the swap operation does not include any memory barrier guarantees.This fix attempts to address these issues by providing an atomic swap implementation using ldrex/strex under _ARM_HAVE_LDREX_STREX macro. _ARM_HAVE_LDREX_STREX macro is defined in cpu-features.h file and patch is submitted under change ID 11088. This Fix is verified on ST Ericsson's U8500 platform and Submitted on behalf of a third-party: Surinder-pal SINGH from STMicroelectronics. --- libcutils/atomic-android-arm.S | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libcutils/atomic-android-arm.S b/libcutils/atomic-android-arm.S index c56ec5d0e..9a24976c3 100644 --- a/libcutils/atomic-android-arm.S +++ b/libcutils/atomic-android-arm.S @@ -17,8 +17,7 @@ #include /* - * NOTE: these atomic operations are SMP safe on all architectures, - * except swap(), see below. + * NOTE: these atomic operations are SMP safe on all architectures. */ .text @@ -228,11 +227,18 @@ android_atomic_or: * output: r0 = old value */ -/* FIXME: this is not safe on SMP systems - * a general way to do it is to use kernel_cmpxchg */ - +/* replaced swp instruction with ldrex/strex for ARMv6 & ARMv7 */ android_atomic_swap: +#if defined (_ARM_HAVE_LDREX_STREX) +1: ldrex r2, [r1] + strex r3, r0, [r1] + teq r3, #0 + bne 1b + mov r0, r2 + mcr p15, 0, r0, c7, c10, 5 /* or, use dmb */ +#else swp r0, r0, [r1] +#endif bx lr /*