From patchwork Mon Jul 17 12:44:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 107932 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp4481190qge; Mon, 17 Jul 2017 05:59:29 -0700 (PDT) X-Received: by 10.237.62.157 with SMTP id n29mr12020297qtf.0.1500296369787; Mon, 17 Jul 2017 05:59:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500296369; cv=none; d=google.com; s=arc-20160816; b=QHImsqbHxij4RsNqGQi9YIujPvtBSnd3jnaEuFurw8Mg9ORjAkwaJZ+ViWSJ3t+rZj 7iDSRvL/FthFrTFDloEGVsP1b5bI+xI4uFsPfAKRpFrGVRfsC1INv2TAPn5i3o/OBwPo Dms4fhmaRzm0HLdWtmzykNFFEvvvPGKjBniOQ0IUakgYKwmsLqxIuH6s2wZUpWIaklG5 PHlCIOqTX3ISFkd/CLjHoA1mi/IofA5byCdGcqF4tw8XHIkPh9A/EXUKHvZsmy40yqvQ hEgsNwBzvKkc/EaqEgM0LL6QeN/t5dkoBqQzb7KWXgugD/azJ3OY7PnRjyCM4+qIKwfL w8zw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to: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:arc-authentication-results; bh=5zW2sexFpzukGuFe4vZpEkR4fU2AVc/io2UfDWdz+h0=; b=ll1+0nmXEQpHy1ZA3WWE50J41+eiKFVusTW153NrBuutJ3NvpfFpEHdOHSYC9BeQ5P 31ItzfHROy/vrod73AMIWkDoMFtqcdnu6Az0k2qc3xnXCevlvk6LvN90IjKL9z1mBzjr aLPwmVq3mP8D9SdnN8UHbF1d0Z1UoGFfM7be5zQWmJfNA0MF/TsHu3h1/8iuMybFnT3U InwoqKKLy0XMz7erYY0kxAR1AYoF/KKpAe6h8jZn0mLlvvzI1K3HK65SDVLeZ/d1vnwo RFM4QXF4V2Yqao0tLfxRSZxQ5cTokFrgGULNUs3N8riRr2Obcgp8aaTtsns4xQ/A6nlP A/cw== ARC-Authentication-Results: i=1; mx.google.com; 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 43si15043526qtn.289.2017.07.17.05.59.29 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 17 Jul 2017 05:59:29 -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; 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]:50236 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX5cV-0002Xa-D5 for patch@linaro.org; Mon, 17 Jul 2017 08:59:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59119) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dX5Of-0007uV-5S for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:45:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dX5Oe-0002Hf-4C for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:45:09 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:37640) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dX5Od-0002Ci-Tn for qemu-devel@nongnu.org; Mon, 17 Jul 2017 08:45:08 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1dX5OV-0003UO-NW for qemu-devel@nongnu.org; Mon, 17 Jul 2017 13:44:59 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 17 Jul 2017 13:44:45 +0100 Message-Id: <1500295494-8991-10-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1500295494-8991-1-git-send-email-peter.maydell@linaro.org> References: <1500295494-8991-1-git-send-email-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 09/18] target/arm: use DISAS_EXIT for eret handling 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Alex Bennée 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_EXIT which will always exit the run-loop. CC: Etienne Carriere CC: Joakim Bech CC: Jaroslaw Pelczar CC: Peter Maydell CC: Emilio G. Cota Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-id: 20170713141928.25419-7-alex.bennee@linaro.org Signed-off-by: Peter Maydell --- target/arm/translate-a64.c | 3 ++- target/arm/translate.c | 6 ++++-- 2 files changed, 6 insertions(+), 3 deletions(-) -- 2.7.4 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 2ac565e..3fa3902 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1788,7 +1788,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_EXIT; return; case 5: /* DRPS */ if (rn != 0x1f) { diff --git a/target/arm/translate.c b/target/arm/translate.c index 75cdeca..e27736c 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -4479,7 +4479,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_EXIT; } /* Generate an old-style exception return. Marks pc as dead. */ @@ -9523,7 +9524,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_EXIT; } } break;