From patchwork Fri Jan 7 15:06:32 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 77888 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A0480B7142 for ; Sat, 8 Jan 2011 02:17:39 +1100 (EST) Received: from localhost ([127.0.0.1]:53969 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PbE4O-0000GF-G1 for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2011 10:17:36 -0500 Received: from [140.186.70.92] (port=60628 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PbDtv-0001OS-Rk for qemu-devel@nongnu.org; Fri, 07 Jan 2011 10:06:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PbDts-0003lg-T4 for qemu-devel@nongnu.org; Fri, 07 Jan 2011 10:06:47 -0500 Received: from mnementh.archaic.org.uk ([81.2.115.146]:44803) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PbDts-0003jc-IY for qemu-devel@nongnu.org; Fri, 07 Jan 2011 10:06:44 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.69) (envelope-from ) id 1PbDti-0006f3-Ih for qemu-devel@nongnu.org; Fri, 07 Jan 2011 15:06:34 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 7 Jan 2011 15:06:32 +0000 Message-Id: <1294412794-25573-6-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1294412794-25573-1-git-send-email-peter.maydell@linaro.org> References: <1294412794-25573-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH 5/7] target-arm: Translate with condexec bits from TB flags, not CPUState X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org When translating, the condexec bits for the TB are in the TB flags; the CPUState condexec bits may be different. This patch fixes https://bugs.launchpad.net/bugs/604872 where we might segfault if we took an exception in the middle of a TB with an IT block, because when we came to retranslate in cpu_restore_state() the CPUState condexec bits would have advanced compared to the start of the TB and we would generate different (wrong) code. Signed-off-by: Peter Maydell --- target-arm/translate.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-) diff --git a/target-arm/translate.c b/target-arm/translate.c index 723961a..7d042ee 100644 --- a/target-arm/translate.c +++ b/target-arm/translate.c @@ -9075,8 +9075,8 @@ static inline void gen_intermediate_code_internal(CPUState *env, dc->singlestep_enabled = env->singlestep_enabled; dc->condjmp = 0; dc->thumb = tb->flags & 1; - dc->condexec_mask = (env->condexec_bits & 0xf) << 1; - dc->condexec_cond = env->condexec_bits >> 4; + dc->condexec_mask = (tb->flags & 0xf00) >> 7; + dc->condexec_cond = (tb->flags & 0xf000) >> 12; #if !defined(CONFIG_USER_ONLY) if (IS_M(env)) { dc->user = ((env->v7m.exception == 0) && (env->v7m.control & 1)); @@ -9105,7 +9105,7 @@ static inline void gen_intermediate_code_internal(CPUState *env, gen_icount_start(); /* Reset the conditional execution bits immediately. This avoids complications trying to do it at the end of the block. */ - if (env->condexec_bits) + if (dc->condexec_mask || dc->condexec_cond) { TCGv tmp = new_tmp(); tcg_gen_movi_i32(tmp, 0);