From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NmBL3-0001aP-B2 for qemu-devel@nongnu.org; Mon, 01 Mar 2010 14:31:33 -0500 Received: from [199.232.76.173] (port=35483 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NmBL0-0001Xl-WF for qemu-devel@nongnu.org; Mon, 01 Mar 2010 14:31:31 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NmBKy-0005xc-T6 for qemu-devel@nongnu.org; Mon, 01 Mar 2010 14:31:30 -0500 Received: from mx20.gnu.org ([199.232.41.8]:19316) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1NmBKy-0005xO-HW for qemu-devel@nongnu.org; Mon, 01 Mar 2010 14:31:28 -0500 Received: from mail.codesourcery.com ([38.113.113.100]) by mx20.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NmBKx-00024p-9P for qemu-devel@nongnu.org; Mon, 01 Mar 2010 14:31:27 -0500 Message-ID: <4B8C160A.2000108@codesourcery.com> Date: Mon, 01 Mar 2010 22:31:22 +0300 From: Maxim Kuvyrkov MIME-Version: 1.0 References: <4B8C133D.2030900@codesourcery.com> In-Reply-To: <4B8C133D.2030900@codesourcery.com> Content-Type: multipart/mixed; boundary="------------030509010606080304050805" Subject: [Qemu-devel] [PATCH 1/4] Add NPTL support for ColdFire List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------030509010606080304050805 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit --------------030509010606080304050805 Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0"; name="0001-Add-NPTL-support-for-ColdFire.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-Add-NPTL-support-for-ColdFire.patch" >>From 1e505c8434d42f9b4fb1cc60934f856ffc06b476 Mon Sep 17 00:00:00 2001 From: Maxim Kuvyrkov Date: Mon, 1 Mar 2010 02:35:53 -0800 Subject: [PATCH 1/4] Add NPTL support for ColdFire Add emulation of new m68k syscalls that provide kernel support for NPTL. Signed-off-by: Maxim Kuvyrkov --- configure | 1 + linux-user/m68k/syscall_nr.h | 5 +++++ linux-user/main.c | 21 +++++++++++++++++++++ linux-user/strace.list | 6 ++++++ linux-user/syscall.c | 20 ++++++++++++++++++++ target-m68k/cpu.h | 21 ++++++++++++++++++++- 6 files changed, 73 insertions(+), 1 deletions(-) diff --git a/configure b/configure index 8eb5f5b..0c03640 100755 --- a/configure +++ b/configure @@ -2375,6 +2375,7 @@ case "$target_arch2" in ;; m68k) bflt="yes" + target_nptl="yes" gdb_xml_files="cf-core.xml cf-fp.xml" target_phys_bits=32 ;; diff --git a/linux-user/m68k/syscall_nr.h b/linux-user/m68k/syscall_nr.h index 1c0ba07..00d4966 100644 --- a/linux-user/m68k/syscall_nr.h +++ b/linux-user/m68k/syscall_nr.h @@ -328,3 +328,8 @@ #define TARGET_NR_dup3 326 #define TARGET_NR_pipe2 327 #define TARGET_NR_inotify_init1 328 + +#define TARGET_NR_get_thread_area 333 +#define TARGET_NR_set_thread_area 334 +#define TARGET_NR_atomic_cmpxchg_32 335 +#define TARGET_NR_atomic_barrier 336 diff --git a/linux-user/main.c b/linux-user/main.c index eeae22e..70e39fc 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -2256,6 +2256,27 @@ void cpu_loop (CPUState *env) #ifdef TARGET_M68K +uint32_t do_cmpxchg_32 (uint32_t addr, uint32_t oldval, uint32_t newval) +{ + uint32_t val; + + /* XXX: This only works between threads, not between processes. + It's probably possible to implement this with native host + operations. However things like ldrex/strex are much harder so + there's not much point trying. */ + start_exclusive(); + + /* FIXME: This should SEGV if the access fails. */ + get_user_u32(val, addr); + if (val == oldval) + /* FIXME: Check for segfaults. */ + put_user_u32(newval, addr); + + end_exclusive(); + + return val; +} + void cpu_loop(CPUM68KState *env) { int trapnr; diff --git a/linux-user/strace.list b/linux-user/strace.list index 97b7f76..c8c79cc 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -33,6 +33,12 @@ #ifdef TARGET_NR_arm_fadvise64_64 { TARGET_NR_arm_fadvise64_64, "arm_fadvise64_64" , NULL, NULL, NULL }, #endif +#ifdef TARGET_NR_atomic_barrier +{ TARGET_NR_atomic_barrier, "atomic_barrier" , NULL, NULL, NULL }, +#endif +#ifdef TARGET_NR_atomic_cmpxchg_32 +{ TARGET_NR_atomic_cmpxchg_32, "atomic_cmpxchg_32" , NULL, NULL, NULL }, +#endif #ifdef TARGET_NR_bdflush { TARGET_NR_bdflush, "bdflush" , NULL, NULL, NULL }, #endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 38eb35f..364f671 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5756,6 +5756,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg5, arg4)); #elif defined(TARGET_CRIS) ret = get_errno(do_fork(cpu_env, arg2, arg1, arg3, arg4, arg5)); +#elif defined(TARGET_M68K) + ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg5, arg4)); #else ret = get_errno(do_fork(cpu_env, arg1, arg2, arg3, arg4, arg5)); #endif @@ -6943,6 +6945,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, #elif defined(TARGET_I386) && defined(TARGET_ABI32) ret = do_set_thread_area(cpu_env, arg1); break; +#elif defined(TARGET_M68K) + cpu_set_tls (cpu_env, arg1); + ret = 0; + break; #else goto unimplemented_nowarn; #endif @@ -6951,6 +6957,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, case TARGET_NR_get_thread_area: #if defined(TARGET_I386) && defined(TARGET_ABI32) ret = do_get_thread_area(cpu_env, arg1); + break; +#elif defined(TARGET_M68K) + ret = cpu_get_tls (cpu_env); + break; #else goto unimplemented_nowarn; #endif @@ -7197,6 +7207,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret = get_errno(fallocate(arg1, arg2, arg3, arg4)); break; #endif +#ifdef TARGET_NR_atomic_cmpxchg_32 + case TARGET_NR_atomic_cmpxchg_32: + ret = do_cmpxchg_32 (arg6, arg2, arg1); + break; +#endif +#ifdef TARGET_NR_atomic_barrier + case TARGET_NR_atomic_barrier: + ret = 0; + break; +#endif default: unimplemented: gemu_log("qemu: Unsupported syscall: %d\n", num); diff --git a/target-m68k/cpu.h b/target-m68k/cpu.h index 68a7e41..6bafc40 100644 --- a/target-m68k/cpu.h +++ b/target-m68k/cpu.h @@ -109,6 +109,9 @@ typedef struct CPUM68KState { uint32_t qregs[MAX_QREGS]; + /* For usermode emulation */ + target_ulong tls_value; + CPU_COMMON uint32_t features; @@ -126,6 +129,8 @@ int cpu_m68k_signal_handler(int host_signum, void *pinfo, void *puc); void cpu_m68k_flush_flags(CPUM68KState *, int); +uint32_t do_cmpxchg_32 (uint32_t, uint32_t, uint32_t); + enum { CC_OP_DYNAMIC, /* Use env->cc_op */ CC_OP_FLAGS, /* CC_DEST = CVZN, CC_SRC = unused */ @@ -236,7 +241,21 @@ static inline void cpu_clone_regs(CPUState *env, target_ulong newsp) env->aregs[7] = newsp; env->dregs[0] = 0; } -#endif + +static inline target_ulong cpu_get_tls(CPUState *env) +{ + return env->tls_value; +} + +static inline void cpu_set_tls(CPUState *env, target_ulong newtls) +{ + env->tls_value = newtls; +} + +static inline void cpu_clear_exclusive(void) +{ +} +#endif /* CONFIG_USER_ONLY */ #include "cpu-all.h" #include "exec-all.h" -- 1.6.2.4 --------------030509010606080304050805--