From b8d43285a4db12156c40ba6fdbd8002c383fcbca Mon Sep 17 00:00:00 2001 From: Mikhail Ilyin Date: Mon, 16 Mar 2015 12:30:47 +0000 Subject: linux-user: Access correct register for get/set_tls syscalls on ARM TZ CPUs When support was added for TrustZone to ARM CPU emulation, we failed to correctly update the support for the linux-user implementation of the get/set_tls syscalls. This meant that accesses to the TPIDRURO register via the syscalls were always using the non-secure copy of the register even if native MRC/MCR accesses were using the secure register. This inconsistency caused most binaries to segfault on startup if the CPU type was explicitly set to one of the TZ-enabled ones like cortex-a15. (The default "any" CPU doesn't have TZ enabled and so is not affected.) Use access_secure_reg() to determine whether we should be using the secure or the nonsecure copy of TPIDRURO when emulating these syscalls. Signed-off-by: Mikhail Ilyin Message-id: 1426505198-2411-1-git-send-email-m.ilin@samsung.com [PMM: rewrote commit message to more clearly explain the issue and its consequences.] Signed-off-by: Peter Maydell --- linux-user/arm/target_cpu.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'linux-user/arm/target_cpu.h') diff --git a/linux-user/arm/target_cpu.h b/linux-user/arm/target_cpu.h index d8a534d7b1..6832262e39 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 -- cgit v1.2.3-55-g7522