summaryrefslogtreecommitdiff
path: root/meta/packages/qemu/qemu-0.9.1+svn/qemu-0.9.0-nptl.patch
diff options
context:
space:
mode:
authorRichard Purdie <richard@openedhand.com>2008-04-24 22:10:12 +0000
committerRichard Purdie <richard@openedhand.com>2008-04-24 22:10:12 +0000
commit927ad4986670f4938049c97e1bbabd5714e410e7 (patch)
tree0ab419dc6e50129f342b6291e66719b8a25cf57e /meta/packages/qemu/qemu-0.9.1+svn/qemu-0.9.0-nptl.patch
parent0e1fe2007df82725e6ce46d4f92d8bf4434ee887 (diff)
downloadopenembedded-core-927ad4986670f4938049c97e1bbabd5714e410e7.tar.gz
openembedded-core-927ad4986670f4938049c97e1bbabd5714e410e7.tar.bz2
openembedded-core-927ad4986670f4938049c97e1bbabd5714e410e7.tar.xz
openembedded-core-927ad4986670f4938049c97e1bbabd5714e410e7.zip
qemu-svn: Upgrade from r4027 -> 4242. Removes the need for gcc 3.x, adds USB networking for the n800
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@4332 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'meta/packages/qemu/qemu-0.9.1+svn/qemu-0.9.0-nptl.patch')
-rw-r--r--meta/packages/qemu/qemu-0.9.1+svn/qemu-0.9.0-nptl.patch450
1 files changed, 348 insertions, 102 deletions
diff --git a/meta/packages/qemu/qemu-0.9.1+svn/qemu-0.9.0-nptl.patch b/meta/packages/qemu/qemu-0.9.1+svn/qemu-0.9.0-nptl.patch
index 4a87d8d63..ac68ebf46 100644
--- a/meta/packages/qemu/qemu-0.9.1+svn/qemu-0.9.0-nptl.patch
+++ b/meta/packages/qemu/qemu-0.9.1+svn/qemu-0.9.0-nptl.patch
@@ -1,19 +1,3 @@
-These are Paul Brook's patches to QEMU-0.8.2 to enable the running of single
-ARM binaries under QEMU's user-emulation mode. Without them, QEMU-0.8.1
-immediately dies saying:
- Error: f0005
- qemu: uncaught target signal 6 (Aborted) - exiting
-while qemu-0.8.2 dies saying:
- qemu: Unsupported syscall: 983045
- cannot set up thread-local storage: unknown error
-
-This file is a rediffing of the patches visible at
-https://nowt.dyndns.org/patch.qemu_nptl on 27 Sept 2006
-which "patch" fails to apply automatically.
-See also http://lists.gnu.org/archive/html/qemu-devel/2006-09/msg00194.html
-
- Martin Guy, 27 Sept 2006
-
---
configure | 25 ++++++
exec-all.h | 165 ------------------------------------------
@@ -27,11 +11,11 @@ See also http://lists.gnu.org/archive/html/qemu-devel/2006-09/msg00194.html
target-arm/translate.c | 9 ++
10 files changed, 405 insertions(+), 183 deletions(-)
-Index: qemu/configure
+Index: trunk/configure
===================================================================
---- qemu.orig/configure 2008-04-09 23:02:37.000000000 +0100
-+++ qemu/configure 2008-04-09 23:06:36.000000000 +0100
-@@ -109,6 +109,7 @@
+--- trunk.orig/configure 2008-04-24 20:16:52.000000000 +0100
++++ trunk/configure 2008-04-24 20:16:53.000000000 +0100
+@@ -112,6 +112,7 @@
build_docs="no"
uname_release=""
curses="yes"
@@ -39,7 +23,7 @@ Index: qemu/configure
# OS specific
targetos=`uname -s`
-@@ -334,6 +335,8 @@
+@@ -339,6 +340,8 @@
;;
*) echo "ERROR: unknown option $opt"; show_help="yes"
;;
@@ -48,7 +32,7 @@ Index: qemu/configure
esac
done
-@@ -429,6 +432,7 @@
+@@ -436,6 +439,7 @@
echo " --disable-linux-user disable all linux usermode emulation targets"
echo " --enable-darwin-user enable all darwin usermode emulation targets"
echo " --disable-darwin-user disable all darwin usermode emulation targets"
@@ -56,7 +40,7 @@ Index: qemu/configure
echo " --fmod-lib path to FMOD library"
echo " --fmod-inc path to FMOD includes"
echo " --enable-uname-release=R Return R for uname -r in usermode emulation"
-@@ -595,6 +599,23 @@
+@@ -647,6 +651,23 @@
}
EOF
@@ -80,7 +64,7 @@ Index: qemu/configure
##########################################
# SDL probe
-@@ -778,6 +799,7 @@
+@@ -845,6 +866,7 @@
echo "Documentation $build_docs"
[ ! -z "$uname_release" ] && \
echo "uname -r $uname_release"
@@ -88,24 +72,48 @@ Index: qemu/configure
if test $sdl_too_old = "yes"; then
echo "-> Your SDL version is too old - please upgrade to have SDL support"
-@@ -1115,6 +1137,9 @@
- echo "TARGET_ARCH=arm" >> $config_mak
- echo "#define TARGET_ARCH \"arm\"" >> $config_h
- echo "#define TARGET_ARM 1" >> $config_h
-+ if test "$nptl" = "yes" ; then
-+ echo "#define USE_NPTL 1" >> $config_h
-+ fi
- bflt="yes"
- elif test "$target_cpu" = "sparc" ; then
- echo "TARGET_ARCH=sparc" >> $config_mak
-Index: qemu/exec-all.h
+@@ -1228,6 +1250,9 @@
+ echo "#define TARGET_ARM 1" >> $config_h
+ echo "#define CONFIG_NO_DYNGEN_OP 1" >> $config_h
+ bflt="yes"
++ if test "$nptl" = "yes" ; then
++ echo "#define USE_NPTL 1" >> $config_h
++ fi
+ ;;
+ cris)
+ echo "TARGET_ARCH=cris" >> $config_mak
+Index: trunk/exec-all.h
===================================================================
---- qemu.orig/exec-all.h 2008-04-09 22:39:38.000000000 +0100
-+++ qemu/exec-all.h 2008-04-09 23:05:55.000000000 +0100
-@@ -297,170 +297,7 @@
+--- trunk.orig/exec-all.h 2008-04-24 20:16:41.000000000 +0100
++++ trunk/exec-all.h 2008-04-24 20:16:53.000000000 +0100
+@@ -303,217 +303,7 @@
extern CPUReadMemoryFunc *io_mem_read[IO_MEM_NB_ENTRIES][4];
extern void *io_mem_opaque[IO_MEM_NB_ENTRIES];
+-#if defined(__hppa__)
+-
+-typedef int spinlock_t[4];
+-
+-#define SPIN_LOCK_UNLOCKED { 1, 1, 1, 1 }
+-
+-static inline void resetlock (spinlock_t *p)
+-{
+- (*p)[0] = (*p)[1] = (*p)[2] = (*p)[3] = 1;
+-}
+-
+-#else
+-
+-typedef int spinlock_t;
+-
+-#define SPIN_LOCK_UNLOCKED 0
+-
+-static inline void resetlock (spinlock_t *p)
+-{
+- *p = SPIN_LOCK_UNLOCKED;
+-}
+-
+-#endif
+-
-#if defined(__powerpc__)
-static inline int testandset (int *p)
-{
@@ -205,6 +213,33 @@ Index: qemu/exec-all.h
- : "cc","memory");
- return ret;
-}
+-#elif defined(__hppa__)
+-
+-/* Because malloc only guarantees 8-byte alignment for malloc'd data,
+- and GCC only guarantees 8-byte alignment for stack locals, we can't
+- be assured of 16-byte alignment for atomic lock data even if we
+- specify "__attribute ((aligned(16)))" in the type declaration. So,
+- we use a struct containing an array of four ints for the atomic lock
+- type and dynamically select the 16-byte aligned int from the array
+- for the semaphore. */
+-#define __PA_LDCW_ALIGNMENT 16
+-static inline void *ldcw_align (void *p) {
+- unsigned long a = (unsigned long)p;
+- a = (a + __PA_LDCW_ALIGNMENT - 1) & ~(__PA_LDCW_ALIGNMENT - 1);
+- return (void *)a;
+-}
+-
+-static inline int testandset (spinlock_t *p)
+-{
+- unsigned int ret;
+- p = ldcw_align(p);
+- __asm__ __volatile__("ldcw 0(%1),%0"
+- : "=r" (ret)
+- : "r" (p)
+- : "memory" );
+- return !ret;
+-}
+-
-#elif defined(__ia64)
-
-#include <ia64intrin.h>
@@ -237,10 +272,6 @@ Index: qemu/exec-all.h
-#error unimplemented CPU support
-#endif
-
--typedef int spinlock_t;
--
--#define SPIN_LOCK_UNLOCKED 0
--
-#if defined(CONFIG_USER_ONLY)
-static inline void spin_lock(spinlock_t *lock)
-{
@@ -249,7 +280,7 @@ Index: qemu/exec-all.h
-
-static inline void spin_unlock(spinlock_t *lock)
-{
-- *lock = 0;
+- resetlock(lock);
-}
-
-static inline int spin_trylock(spinlock_t *lock)
@@ -274,10 +305,10 @@ Index: qemu/exec-all.h
extern spinlock_t tb_lock;
-Index: qemu/linux-user/arm/syscall.h
+Index: trunk/linux-user/arm/syscall.h
===================================================================
---- qemu.orig/linux-user/arm/syscall.h 2007-11-27 12:09:33.000000000 +0000
-+++ qemu/linux-user/arm/syscall.h 2008-04-09 23:05:55.000000000 +0100
+--- trunk.orig/linux-user/arm/syscall.h 2008-04-24 20:16:41.000000000 +0100
++++ trunk/linux-user/arm/syscall.h 2008-04-24 20:16:53.000000000 +0100
@@ -28,7 +28,9 @@
#define ARM_SYSCALL_BASE 0x900000
#define ARM_THUMB_SYSCALL 0
@@ -289,11 +320,11 @@ Index: qemu/linux-user/arm/syscall.h
#define ARM_NR_semihosting 0x123456
#define ARM_NR_thumb_semihosting 0xAB
-Index: qemu/linux-user/main.c
+Index: trunk/linux-user/main.c
===================================================================
---- qemu.orig/linux-user/main.c 2008-04-09 23:02:37.000000000 +0100
-+++ qemu/linux-user/main.c 2008-04-09 23:05:55.000000000 +0100
-@@ -364,6 +364,50 @@
+--- trunk.orig/linux-user/main.c 2008-04-24 20:16:47.000000000 +0100
++++ trunk/linux-user/main.c 2008-04-24 20:17:38.000000000 +0100
+@@ -365,6 +365,50 @@
}
}
@@ -325,7 +356,7 @@ Index: qemu/linux-user/main.c
+ cpu_unlock();
+ break;
+ case 0xffff0fe0: /* __kernel_get_tls */
-+ env->regs[0] = env->cp15.c13_tls;
++ env->regs[0] = env->cp15.c13_tls2;
+ break;
+ default:
+ return 1;
@@ -344,7 +375,7 @@ Index: qemu/linux-user/main.c
void cpu_loop(CPUARMState *env)
{
int trapnr;
-@@ -474,10 +518,8 @@
+@@ -475,10 +519,8 @@
}
}
@@ -357,7 +388,7 @@ Index: qemu/linux-user/main.c
env->regs[0] = do_arm_semihosting (env);
} else if (n == 0 || n >= ARM_SYSCALL_BASE
|| (env->thumb && n == ARM_THUMB_SYSCALL)) {
-@@ -488,14 +530,34 @@
+@@ -489,14 +531,34 @@
n -= ARM_SYSCALL_BASE;
env->eabi = 0;
}
@@ -400,7 +431,7 @@ Index: qemu/linux-user/main.c
} else {
goto error;
}
-@@ -534,6 +596,10 @@
+@@ -535,6 +597,10 @@
}
}
break;
@@ -411,7 +442,19 @@ Index: qemu/linux-user/main.c
default:
error:
fprintf(stderr, "qemu: unhandled CPU exception 0x%x - aborting\n",
-@@ -2402,6 +2468,10 @@
+@@ -1994,6 +2060,11 @@
+ int drop_ld_preload = 0, environ_count = 0;
+ char **target_environ, **wrk, **dst;
+
++ char *assume_kernel = getenv("QEMU_ASSUME_KERNEL");
++
++ if (assume_kernel)
++ setenv("LD_ASSUME_KERNEL", assume_kernel, 1);
++
+ if (argc <= 1)
+ usage();
+
+@@ -2403,6 +2474,10 @@
ts->heap_base = info->brk;
/* This will be filled in on the first SYS_HEAPINFO call. */
ts->heap_limit = 0;
@@ -422,10 +465,10 @@ Index: qemu/linux-user/main.c
#endif
if (gdbstub_port) {
-Index: qemu/linux-user/qemu.h
+Index: trunk/linux-user/qemu.h
===================================================================
---- qemu.orig/linux-user/qemu.h 2008-01-02 15:48:21.000000000 +0000
-+++ qemu/linux-user/qemu.h 2008-04-09 23:05:55.000000000 +0100
+--- trunk.orig/linux-user/qemu.h 2008-04-24 20:16:41.000000000 +0100
++++ trunk/linux-user/qemu.h 2008-04-24 20:16:53.000000000 +0100
@@ -107,6 +107,9 @@
uint32_t heap_base;
uint32_t heap_limit;
@@ -436,11 +479,19 @@ Index: qemu/linux-user/qemu.h
int used; /* non zero if used */
struct image_info *info;
uint8_t stack[0];
-Index: qemu/linux-user/syscall.c
+Index: trunk/linux-user/syscall.c
===================================================================
---- qemu.orig/linux-user/syscall.c 2008-04-09 23:02:38.000000000 +0100
-+++ qemu/linux-user/syscall.c 2008-04-09 23:05:55.000000000 +0100
-@@ -71,9 +71,18 @@
+--- trunk.orig/linux-user/syscall.c 2008-04-24 20:16:50.000000000 +0100
++++ trunk/linux-user/syscall.c 2008-04-24 20:19:52.000000000 +0100
+@@ -61,6 +61,7 @@
+ #define tchars host_tchars /* same as target */
+ #define ltchars host_ltchars /* same as target */
+
++#include <linux/futex.h>
+ #include <linux/termios.h>
+ #include <linux/unistd.h>
+ #include <linux/utsname.h>
+@@ -71,9 +72,18 @@
#include <linux/kd.h>
#include "qemu.h"
@@ -459,7 +510,14 @@ Index: qemu/linux-user/syscall.c
#if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_SPARC) \
|| defined(TARGET_M68K) || defined(TARGET_SH4) || defined(TARGET_CRIS)
/* 16 bit uid wrappers emulation */
-@@ -2702,9 +2711,19 @@
+@@ -2695,16 +2705,25 @@
+ return 0;
+ }
+ #endif
+-
+ #endif /* defined(TARGET_I386) */
+
+ /* this stack is the equivalent of the kernel stack associated with a
thread/process */
#define NEW_STACK_SIZE 8192
@@ -479,7 +537,7 @@ Index: qemu/linux-user/syscall.c
cpu_loop(env);
/* never exits */
return 0;
-@@ -2712,13 +2731,22 @@
+@@ -2712,15 +2731,27 @@
/* do_fork() Must return host values and target errnos (unlike most
do_*() functions). */
@@ -492,18 +550,53 @@ Index: qemu/linux-user/syscall.c
TaskState *ts;
uint8_t *new_stack;
CPUState *new_env;
-
++#if defined(TARGET_I386)
++ uint64_t *new_gdt_table;
++#endif
+#ifdef USE_NPTL
+ unsigned int nptl_flags;
-+
+
+ if (flags & CLONE_PARENT_SETTID)
+ *parent_tidptr = gettid();
+#endif
-+
if (flags & CLONE_VM) {
ts = malloc(sizeof(TaskState) + NEW_STACK_SIZE);
++ if (!ts)
++ return -ENOMEM;
memset(ts, 0, sizeof(TaskState));
-@@ -2784,16 +2812,67 @@
+ new_stack = ts->stack;
+ ts->used = 1;
+@@ -2732,6 +2763,29 @@
+ #if defined(TARGET_I386)
+ if (!newsp)
+ newsp = env->regs[R_ESP];
++ new_gdt_table = malloc(9 * 8);
++ if (!new_gdt_table) {
++ free(new_env);
++ return -ENOMEM;
++ }
++ /* Copy main GDT table from parent, but clear TLS entries */
++ memcpy(new_gdt_table, g2h(env->gdt.base), 6 * 8);
++ memset(&new_gdt_table[6], 0, 3 * 8);
++ new_env->gdt.base = h2g(new_gdt_table);
++ if (flags & 0x00080000 /* CLONE_SETTLS */) {
++ ret = do_set_thread_area(new_env, new_env->regs[R_ESI]);
++ if (ret) {
++ free(new_gdt_table);
++ free(new_env);
++ return ret;
++ }
++ }
++ cpu_x86_load_seg(env, R_CS, new_env->regs[R_CS]);
++ cpu_x86_load_seg(env, R_DS, new_env->regs[R_DS]);
++ cpu_x86_load_seg(env, R_ES, new_env->regs[R_ES]);
++ cpu_x86_load_seg(env, R_SS, new_env->regs[R_SS]);
++ cpu_x86_load_seg(env, R_FS, new_env->regs[R_FS]);
++ cpu_x86_load_seg(env, R_GS, new_env->regs[R_GS]);
+ new_env->regs[R_ESP] = newsp;
+ new_env->regs[R_EAX] = 0;
+ #elif defined(TARGET_ARM)
+@@ -2784,16 +2838,67 @@
#error unsupported target CPU
#endif
new_env->opaque = ts;
@@ -572,7 +665,85 @@ Index: qemu/linux-user/syscall.c
}
return ret;
}
-@@ -3118,7 +3197,7 @@
+@@ -3052,6 +3157,68 @@
+ unlock_user_struct(target_ts, target_addr, 1);
+ }
+
++static long do_futex(target_ulong uaddr, int op, uint32_t val,
++ target_ulong utime, target_ulong uaddr2,
++ uint32_t val3)
++{
++ struct timespec host_utime;
++ unsigned long val2 = utime;
++
++ if (utime && (op == FUTEX_WAIT || op == FUTEX_LOCK_PI)) {
++ target_to_host_timespec(&host_utime, utime);
++ val2 = (unsigned long)&host_utime;
++ }
++
++#ifdef BSWAP_NEEDED
++ switch(op) {
++ case FUTEX_CMP_REQUEUE:
++ val3 = tswap32(val3);
++ case FUTEX_REQUEUE:
++ val2 = tswap32(val2);
++ case FUTEX_WAIT:
++ case FUTEX_WAKE:
++ val = tswap32(val);
++ case FUTEX_LOCK_PI: /* This one's icky, but comes out OK */
++ case FUTEX_UNLOCK_PI:
++ break;
++ default:
++ gemu_log("qemu: Unsupported futex op %d\n", op);
++ return -ENOSYS;
++ }
++#if 0 /* No, it's worse than this */
++ if (op == FUTEX_WAKE_OP) {
++ /* Need to munge the secondary operation (val3) */
++ val3 = tswap32(val3);
++ int op2 = (val3 >> 28) & 7;
++ int cmp = (val3 >> 24) & 15;
++ int oparg = (val3 << 8) >> 20;
++ int cmparg = (val3 << 20) >> 20;
++ int shift = val3 & (FUTEX_OP_OPARG_SHIFT << 28);
++
++ if (shift)
++ oparg = (oparg & 7) + 24 - (oparg & 24);
++ else oparg =
++ if (op2 == FUTEX_OP_ADD) {
++ gemu_log("qemu: Unsupported wrong-endian FUTEX_OP_ADD\n");
++ return -ENOSYS;
++ }
++ if (cmparg == FUTEX_OP_CMP_LT || cmparg == FUTEX_OP_CMP_GE ||
++ cmparg == FUTEX_OP_CMP_LE || cmparg == FUTEX_OP_CMP_GT) {
++ gemu_log("qemu: Unsupported wrong-endian futex cmparg %d\n", cmparg);
++ return -ENOSYS;
++ }
++ val3 = shift | (op2<<28) | (cmp<<24) | (oparg<<12) | cmparg;
++ }
++#endif
++#endif
++ return syscall(__NR_futex, g2h(uaddr), op, val, val2, g2h(uaddr2), val3);
++}
++
++int do_set_tid_address(target_ulong tidptr)
++{
++ return syscall(__NR_set_tid_address, g2h(tidptr));
++}
++
+ /* do_syscall() should always have a single exit point at the end so
+ that actions, such as logging of syscall results, can be performed.
+ All errnos that do_syscall() returns must be -TARGET_<errcode>. */
+@@ -3076,7 +3243,7 @@
+ _mcleanup();
+ #endif
+ gdb_exit(cpu_env, arg1);
+- /* XXX: should free thread stack and CPU env */
++ /* XXX: should free thread stack, GDT and CPU env */
+ _exit(arg1);
+ ret = 0; /* avoid warning */
+ break;
+@@ -3118,7 +3285,7 @@
ret = do_brk(arg1);
break;
case TARGET_NR_fork:
@@ -581,7 +752,7 @@ Index: qemu/linux-user/syscall.c
break;
#ifdef TARGET_NR_waitpid
case TARGET_NR_waitpid:
-@@ -4481,7 +4560,8 @@
+@@ -4482,7 +4649,8 @@
ret = get_errno(fsync(arg1));
break;
case TARGET_NR_clone:
@@ -591,7 +762,7 @@ Index: qemu/linux-user/syscall.c
break;
#ifdef __NR_exit_group
/* new thread calls */
-@@ -4928,7 +5008,8 @@
+@@ -4943,7 +5111,8 @@
#endif
#ifdef TARGET_NR_vfork
case TARGET_NR_vfork:
@@ -601,11 +772,34 @@ Index: qemu/linux-user/syscall.c
break;
#endif
#ifdef TARGET_NR_ugetrlimit
-Index: qemu/qemu_spinlock.h
+@@ -5521,6 +5690,9 @@
+ #elif defined(TARGET_I386) && defined(TARGET_ABI32)
+ ret = do_set_thread_area(cpu_env, arg1);
+ break;
++#elif TARGET_i386
++ ret = get_errno(do_set_thread_area(cpu_env, arg1));
++ break;
+ #else
+ goto unimplemented_nowarn;
+ #endif
+@@ -5538,6 +5710,12 @@
+ goto unimplemented_nowarn;
+ #endif
+
++#ifdef TARGET_NR_futex
++ case TARGET_NR_futex:
++ ret = get_errno(do_futex(arg1, arg2, arg3, arg4, arg5, arg6));
++ break;
++#endif
++
+ #ifdef TARGET_NR_clock_gettime
+ case TARGET_NR_clock_gettime:
+ {
+Index: trunk/qemu_spinlock.h
===================================================================
--- /dev/null 1970-01-01 00:00:00.000000000 +0000
-+++ qemu/qemu_spinlock.h 2008-04-09 23:05:55.000000000 +0100
-@@ -0,0 +1,181 @@
++++ trunk/qemu_spinlock.h 2008-04-24 20:16:53.000000000 +0100
+@@ -0,0 +1,250 @@
+/*
+ * Atomic operation helper include
+ *
@@ -743,6 +937,33 @@ Index: qemu/qemu_spinlock.h
+}
+#endif
+
++#ifdef __hppa__
++/* Because malloc only guarantees 8-byte alignment for malloc'd data,
++ and GCC only guarantees 8-byte alignment for stack locals, we can't
++ be assured of 16-byte alignment for atomic lock data even if we
++ specify "__attribute ((aligned(16)))" in the type declaration. So,
++ we use a struct containing an array of four ints for the atomic lock
++ type and dynamically select the 16-byte aligned int from the array
++ for the semaphore. */
++#define __PA_LDCW_ALIGNMENT 16
++static inline void *ldcw_align (void *p) {
++ unsigned long a = (unsigned long)p;
++ a = (a + __PA_LDCW_ALIGNMENT - 1) & ~(__PA_LDCW_ALIGNMENT - 1);
++ return (void *)a;
++}
++
++static inline int testandset (spinlock_t *p)
++{
++ unsigned int ret;
++ p = ldcw_align(p);
++ __asm__ __volatile__("ldcw 0(%1),%0"
++ : "=r" (ret)
++ : "r" (p)
++ : "memory" );
++ return !ret;
++}
++#endif
++
+#ifdef __ia64
+#include <ia64intrin.h>
+
@@ -752,10 +973,52 @@ Index: qemu/qemu_spinlock.h
+}
+#endif
+
++#ifdef __mips__
++static inline int testandset (int *p)
++{
++ int ret;
++
++ __asm__ __volatile__ (
++ " .set push \n"
++ " .set noat \n"
++ " .set mips2 \n"
++ "1: li $1, 1 \n"
++ " ll %0, %1 \n"
++ " sc $1, %1 \n"
++ " beqz $1, 1b \n"
++ " .set pop "
++ : "=r" (ret), "+R" (*p)
++ :
++ : "memory");
++
++ return ret;
++}
++#endif
++
++#if defined(__hppa__)
++
++typedef int spinlock_t[4];
++
++#define SPIN_LOCK_UNLOCKED { 1, 1, 1, 1 }
++
++static inline void resetlock (spinlock_t *p)
++{
++ (*p)[0] = (*p)[1] = (*p)[2] = (*p)[3] = 1;
++}
++
++#else
++
+typedef int spinlock_t;
+
+#define SPIN_LOCK_UNLOCKED 0
+
++static inline void resetlock (spinlock_t *p)
++{
++ *p = SPIN_LOCK_UNLOCKED;
++}
++
++#endif
++
+#if defined(CONFIG_USER_ONLY)
+static inline void spin_lock(spinlock_t *lock)
+{
@@ -764,7 +1027,7 @@ Index: qemu/qemu_spinlock.h
+
+static inline void spin_unlock(spinlock_t *lock)
+{
-+ *lock = 0;
++ resetlock(lock);
+}
+
+static inline int spin_trylock(spinlock_t *lock)
@@ -787,10 +1050,10 @@ Index: qemu/qemu_spinlock.h
+#endif
+
+#endif
-Index: qemu/target-arm/cpu.h
+Index: trunk/target-arm/cpu.h
===================================================================
---- qemu.orig/target-arm/cpu.h 2007-11-27 12:09:57.000000000 +0000
-+++ qemu/target-arm/cpu.h 2008-04-09 23:05:55.000000000 +0100
+--- trunk.orig/target-arm/cpu.h 2008-04-24 20:16:41.000000000 +0100
++++ trunk/target-arm/cpu.h 2008-04-24 20:16:53.000000000 +0100
@@ -38,6 +38,7 @@
#define EXCP_FIQ 6
#define EXCP_BKPT 7
@@ -799,7 +1062,7 @@ Index: qemu/target-arm/cpu.h
#define ARMV7M_EXCP_RESET 1
#define ARMV7M_EXCP_NMI 2
-@@ -222,6 +223,15 @@
+@@ -218,6 +219,15 @@
void cpu_lock(void);
void cpu_unlock(void);
@@ -815,36 +1078,19 @@ Index: qemu/target-arm/cpu.h
#define CPSR_M (0x1f)
#define CPSR_T (1 << 5)
#define CPSR_F (1 << 6)
-Index: qemu/target-arm/op.c
-===================================================================
---- qemu.orig/target-arm/op.c 2008-04-09 22:40:01.000000000 +0100
-+++ qemu/target-arm/op.c 2008-04-09 23:05:55.000000000 +0100
-@@ -994,6 +994,12 @@
- cpu_loop_exit();
- }
-
-+void OPPROTO op_kernel_trap(void)
-+{
-+ env->exception_index = EXCP_KERNEL_TRAP;
-+ cpu_loop_exit();
-+}
-+
- /* VFP support. We follow the convention used for VFP instrunctions:
- Single precition routines have a "s" suffix, double precision a
- "d" suffix. */
-Index: qemu/target-arm/translate.c
+Index: trunk/target-arm/translate.c
===================================================================
---- qemu.orig/target-arm/translate.c 2008-04-09 22:40:01.000000000 +0100
-+++ qemu/target-arm/translate.c 2008-04-09 23:05:55.000000000 +0100
-@@ -7496,7 +7496,14 @@
- gen_op_exception_exit();
+--- trunk.orig/target-arm/translate.c 2008-04-24 20:16:41.000000000 +0100
++++ trunk/target-arm/translate.c 2008-04-24 20:16:53.000000000 +0100
+@@ -8606,7 +8606,14 @@
+ gen_exception(EXCP_EXCEPTION_EXIT);
}
#endif
-
+#ifdef CONFIG_USER_ONLY
+ /* Intercept jump to the magic kernel page. */
+ if (dc->pc > 0xffff0000) {
-+ gen_op_kernel_trap();
++ gen_exception(EXCP_KERNEL_TRAP);
+ dc->is_jmp = DISAS_UPDATE;
+ break;
+ }