From patchwork Mon Jul 10 15:47:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 107311 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp3598410qge; Mon, 10 Jul 2017 08:52:43 -0700 (PDT) X-Received: by 10.237.56.135 with SMTP id k7mr5389479qte.134.1499701962850; Mon, 10 Jul 2017 08:52:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499701962; cv=none; d=google.com; s=arc-20160816; b=ro7qSRCpGRKEgXst1OOjfFbKgJ7l32D8sXh5eEtOwbND5+dU1IlL63Dj3a0vjDHAGP O6T0r8pkMGagovaixA2En7oBTZac9htRi5F+qMrNnNgdr2jWtPs0cJmcVnjfmQA8r4lP jA3DOc3lEpAoLgPzRsqWlNu/KQmoFLONhlvU7Oa6wkTMxez2kaTof8XiSKAzQeFeGVOi Xzv7WKomIoaFLNudQYPETXXnLLkLV6bzD82965RQ+LDHvahD8KH2Ia4mw7X+D1F6+jlQ ikKvhsA+qoHnCnWVY4FySoBpapBOmJA3yes4MehS5tYdxyKcVixT1FMcxGOK+c1pP0nC i79w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=MpW4kpAdpZa/Gc/khB4sKzgwfCdsKuoSez0xM1QRAgc=; b=xc9JPn+if6uLCsPhKFZ5dCGGgdFEOyqzO14i3JjtcYTiFWjE6JmL11d71eTIcec7aK 4f3NKTGrcIMotcncrLLxv0MPPVN2+fcjkdlXTAe3iD4zyulaEAlShg3p+gWmbDtydQb5 N/n/vNeKVBQ9dRIexYt2ISd2pU6BQ3x+Syt+g8HMxalAaOBbfJX6pwzjv9f/DDwqxy6g gDnQVTsqlQLpj5j2flSz1fu9SXYWu1wSQatYWVMH1FgugZLxPgMiqpi1cOc/yLC5vShN rC4ks255sBOjk+hqg4qfeWgPyQsR0iPkZU70WoyxA07MHwRAXFym8ljN7rTeFPFanPld /HbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=MVm6QaQ+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t46si11206219qtc.261.2017.07.10.08.52.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 10 Jul 2017 08:52:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.b=MVm6QaQ+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41531 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUazH-0000ve-ON for patch@linaro.org; Mon, 10 Jul 2017 11:52:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUavl-0006iy-9H for qemu-devel@nongnu.org; Mon, 10 Jul 2017 11:49:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUavk-0004BX-6r for qemu-devel@nongnu.org; Mon, 10 Jul 2017 11:49:01 -0400 Received: from mail-wr0-f170.google.com ([209.85.128.170]:33200) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dUavk-0004BB-0C for qemu-devel@nongnu.org; Mon, 10 Jul 2017 11:49:00 -0400 Received: by mail-wr0-f170.google.com with SMTP id r103so144222511wrb.0 for ; Mon, 10 Jul 2017 08:48:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MpW4kpAdpZa/Gc/khB4sKzgwfCdsKuoSez0xM1QRAgc=; b=MVm6QaQ+khCtdIlIRk93nY6zuW+ZhvZGeBa/KDODX7DhTzfAnDLxW31V36CoMN2bbH jVj2Bz2erku9CgeyjwhFZF39+cxBa3ISN7/Mz/DVxXtdmRSC38ZEslN16qgXILDDfCP0 GHpebYp9BvpKhq6DXLB4kLVsnYcjkZJuUWXsw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MpW4kpAdpZa/Gc/khB4sKzgwfCdsKuoSez0xM1QRAgc=; b=c4tM/4YzqGAFpQrkqnJmrsspmebOCHfeKjTbH8sfbljU+eYIUnDFrzkARKNRFlYJuj OdrnnLYQ8d7NO2jPlXL0MAM4f772r7j5jgUruU1AmiBxCm2HtW10g195FklRrPsCyI7B /I+S4P9cK2fxVgJXNg11zTUF4pg5yU8qRT95oO6TvttEZPNsUAyy8k+EiH+tplOczBOx ablaNLAw1F6xf94ViC737cnAAyRf3sDekO7z2WKahH8QQs0cbjB3YfQVr7Y61avnXmbX 9hxKnpjymomAfpeKkLYoQP/8pv1x4VcCcsBzeFjSh2UblQ6zjjBmR1GCMqXZLVhQWkwZ cEDA== X-Gm-Message-State: AIVw113Qflok/CEQd32AxbArB0s8CPhW6HkghekArnqLiGoa56V0s+EL xbJ7f1uctoPn6ji4 X-Received: by 10.223.175.229 with SMTP id y37mr8465840wrd.61.1499701678324; Mon, 10 Jul 2017 08:47:58 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id b30sm7277194wra.42.2017.07.10.08.47.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Jul 2017 08:47:54 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id E2E1F3E0F9A; Mon, 10 Jul 2017 16:47:49 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org, rth@twiddle.net, cota@braap.org Date: Mon, 10 Jul 2017 16:47:49 +0100 Message-Id: <20170710154749.13624-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170710154749.13624-1-alex.bennee@linaro.org> References: <20170710154749.13624-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.128.170 Subject: [Qemu-devel] [PATCH v1 6/6] target/arm: ensure eret exits the run-loop via DISAS_UPDATE X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joakim Bech , Etienne Carriere , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, "open list:ARM" Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Previously DISAS_JUMP did ensure this but with the optimisation of 8a6b28c7 (optimize indirect branches) we might not leave the loop. This means if any pending interrupts are cleared by changing IRQ flags we might never get around to servicing them. You usually notice this by seeing the lookup_tb_ptr() helper gainfully chaining TBs together while cpu->interrupt_request remains high and the exit_request has not been set. This breaks amongst other things the OPTEE test suite which executes an eret from the secure world after a non-secure world IRQ has gone pending which then never gets serviced. Instead of using the previously implied semantics of DISAS_JUMP we use DISAS_UPDATE which (now) clearly states that the run-loop should be exited as wider CPU State other than just the PC has changed. Signed-off-by: Alex Bennée CC: Etienne Carriere CC: Joakim Bech CC: Peter Maydell CC: Emilio G. Cota CC: Richard Henderson --- target/arm/translate-a64.c | 3 ++- target/arm/translate.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) -- 2.13.0 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index fd9724b890..9efcba49d6 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1791,7 +1791,8 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) return; } gen_helper_exception_return(cpu_env); - s->is_jmp = DISAS_JUMP; + /* Must exit loop to check un-masked IRQs */ + s->is_jmp = DISAS_UPDATE; return; case 5: /* DRPS */ if (rn != 0x1f) { diff --git a/target/arm/translate.c b/target/arm/translate.c index f7f5f917c7..75bdc6c7dd 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -4488,7 +4488,8 @@ static void gen_rfe(DisasContext *s, TCGv_i32 pc, TCGv_i32 cpsr) */ gen_helper_cpsr_write_eret(cpu_env, cpsr); tcg_temp_free_i32(cpsr); - s->is_jmp = DISAS_JUMP; + /* Must exit loop to check un-masked IRQs */ + s->is_jmp = DISAS_UPDATE; } /* Generate an old-style exception return. Marks pc as dead. */ @@ -9534,7 +9535,8 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) tmp = load_cpu_field(spsr); gen_helper_cpsr_write_eret(cpu_env, tmp); tcg_temp_free_i32(tmp); - s->is_jmp = DISAS_JUMP; + /* Must exit loop to check un-masked IRQs */ + s->is_jmp = DISAS_UPDATE; } } break;