Received: from eggs.gnu.org ([2001:4830:134:3::10]:54351) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXT9j-0008FN-A4 for qemu-devel@nongnu.org; Mon, 16 Mar 2015 07:26:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YXT9g-0004Wa-JN for qemu-devel@nongnu.org; Mon, 16 Mar 2015 07:25:59 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:10413) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YXT9g-0004WN-Cz for qemu-devel@nongnu.org; Mon, 16 Mar 2015 07:25:56 -0400 Received: from eucpsbgm1.samsung.com (unknown [203.254.199.244]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7u4-24.01(7.0.4.24.0) 64bit (built Nov 17 2011)) with ESMTP id <0NLA00BT6YLXKK50@mailout1.w1.samsung.com> for qemu-devel@nongnu.org; Mon, 16 Mar 2015 11:29:57 +0000 (GMT) From: Mikhail Ilyin Date: Mon, 16 Mar 2015 14:26:38 +0300 Message-id: <1426505198-2411-1-git-send-email-m.ilin@samsung.com> Subject: [Qemu-devel] [PATCH] linux-user: qemu treats TLS pointer in the wrong way when spicifying cpu cotrex-a15. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: m.ilin@samsung.com, riku.voipio@iki.fi, y.gribov@samsung.com From: Mikhail Ilyin At present there are two copies of TPIDRURO register for secure and unsecure access. TLS is set via a system call __ARM_NR_set_tls and its handler (cpu_set_tls) always assigns a provided value to unsecure register tpidrro_el[0]/tpidruro_ns. But during execution for cortex-a15 mrc instruction returns TLS from secure rigester tpidruro_s which is 0 and causes SIGSEGV. Signed-off-by: Mikhail Ilyin --- linux-user/arm/target_cpu.h | 15 ++++++++++++++- linux-user/main.c | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/linux-user/arm/target_cpu.h b/linux-user/arm/target_cpu.h index d8a534d..6832262 100644 --- a/linux-user/arm/target_cpu.h +++ b/linux-user/arm/target_cpu.h @@ -29,7 +29,20 @@ static inline void cpu_clone_regs(CPUARMState *env, target_ulong newsp) static inline void cpu_set_tls(CPUARMState *env, target_ulong newtls) { - env->cp15.tpidrro_el[0] = newtls; + if (access_secure_reg(env)) { + env->cp15.tpidruro_s = newtls; + } else { + env->cp15.tpidrro_el[0] = newtls; + } +} + +static inline target_ulong cpu_get_tls(CPUARMState *env) +{ + if (access_secure_reg(env)) { + return env->cp15.tpidruro_s; + } else { + return env->cp15.tpidrro_el[0]; + } } #endif diff --git a/linux-user/main.c b/linux-user/main.c index 6bd23af..6e446de 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -566,7 +566,7 @@ do_kernel_trap(CPUARMState *env) end_exclusive(); break; case 0xffff0fe0: /* __kernel_get_tls */ - env->regs[0] = env->cp15.tpidrro_el[0]; + env->regs[0] = cpu_get_tls(env); break; case 0xffff0f60: /* __kernel_cmpxchg64 */ arm_kernel_cmpxchg64_helper(env); -- 1.9.1