From patchwork Sat Dec 24 18:59:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 5962 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id B657323E0C for ; Sat, 24 Dec 2011 18:59:16 +0000 (UTC) Received: from mail-ey0-f180.google.com (mail-ey0-f180.google.com [209.85.215.180]) by fiordland.canonical.com (Postfix) with ESMTP id A8271A18079 for ; Sat, 24 Dec 2011 18:59:16 +0000 (UTC) Received: by mail-ey0-f180.google.com with SMTP id c11so7986279eaa.11 for ; Sat, 24 Dec 2011 10:59:16 -0800 (PST) Received: by 10.204.156.219 with SMTP id y27mr4449710bkw.71.1324753156483; Sat, 24 Dec 2011 10:59:16 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.205.82.144 with SMTP id ac16cs117161bkc; Sat, 24 Dec 2011 10:59:15 -0800 (PST) Received: by 10.68.74.233 with SMTP id x9mr14422088pbv.74.1324753152941; Sat, 24 Dec 2011 10:59:12 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id b10si17857401pbo.201.2011.12.24.10.59.11 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 24 Dec 2011 10:59:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1ReWoF-0001VA-Pw; Sat, 24 Dec 2011 18:59:07 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org Subject: [PATCH 1/2] target-arm: Don't use cpu_single_env in bank_number() Date: Sat, 24 Dec 2011 18:59:06 +0000 Message-Id: <1324753147-5747-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1324753147-5747-1-git-send-email-peter.maydell@linaro.org> References: <1324753147-5747-1-git-send-email-peter.maydell@linaro.org> Avoid using cpu_single_env in bank_number() -- if we were called via the gdb stub reading or writing the CPSR then it is NULL and we will segfault if we take the cpu_abort(). Signed-off-by: Peter Maydell --- target-arm/helper.c | 12 ++++++------ 1 files changed, 6 insertions(+), 6 deletions(-) diff --git a/target-arm/helper.c b/target-arm/helper.c index 65f4fbf..5b994d5 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -642,7 +642,7 @@ uint32_t HELPER(get_r13_banked)(CPUState *env, uint32_t mode) extern int semihosting_enabled; /* Map CPU modes onto saved register banks. */ -static inline int bank_number (int mode) +static inline int bank_number(CPUState *env, int mode) { switch (mode) { case ARM_CPU_MODE_USR: @@ -659,7 +659,7 @@ static inline int bank_number (int mode) case ARM_CPU_MODE_FIQ: return 5; } - cpu_abort(cpu_single_env, "Bad mode %x\n", mode); + cpu_abort(env, "Bad mode %x\n", mode); return -1; } @@ -680,12 +680,12 @@ void switch_mode(CPUState *env, int mode) memcpy (env->regs + 8, env->fiq_regs, 5 * sizeof(uint32_t)); } - i = bank_number(old_mode); + i = bank_number(env, old_mode); env->banked_r13[i] = env->regs[13]; env->banked_r14[i] = env->regs[14]; env->banked_spsr[i] = env->spsr; - i = bank_number(mode); + i = bank_number(env, mode); env->regs[13] = env->banked_r13[i]; env->regs[14] = env->banked_r14[i]; env->spsr = env->banked_spsr[i]; @@ -2125,7 +2125,7 @@ void HELPER(set_r13_banked)(CPUState *env, uint32_t mode, uint32_t val) if ((env->uncached_cpsr & CPSR_M) == mode) { env->regs[13] = val; } else { - env->banked_r13[bank_number(mode)] = val; + env->banked_r13[bank_number(env, mode)] = val; } } @@ -2134,7 +2134,7 @@ uint32_t HELPER(get_r13_banked)(CPUState *env, uint32_t mode) if ((env->uncached_cpsr & CPSR_M) == mode) { return env->regs[13]; } else { - return env->banked_r13[bank_number(mode)]; + return env->banked_r13[bank_number(env, mode)]; } }