From patchwork Mon Jul 10 19:21:28 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: 107317 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp3837285qge; Mon, 10 Jul 2017 12:23:28 -0700 (PDT) X-Received: by 10.233.235.3 with SMTP id b3mr2743461qkg.138.1499714608857; Mon, 10 Jul 2017 12:23:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499714608; cv=none; d=google.com; s=arc-20160816; b=pxccjZGS67XwaDQUPGNES9CLK9A3/ASrtny08PocjgdpjWYS3EdMDmv4ii3fOTnNqC qQp25PfaUHzgMVHCv7RTF0HMPsZHKKQTcT3dhflPSI5o/QckqD7as3/0GMPGLNDSPHZI GxXfHY1IgzzvBuu5pvW1naoCAcBeXNwzIGn7trUV8B5eCqPyS4jv5HLnXGckN8G/Ir4B S1bsv0nuEod2JBybgRmt+LwWDxNgdXHkyRtK326s4T/ahGGU1T3cx4oNi447Bc5zeCgu nifDgMVe2Gafbtwhuo27TC5NZBV5F6ugN6wlNcO5hCqIj6wgc2gB4w50YNgsbaN6R44P SOvw== 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=V65CAUygFd3FgfSYAI4WlSRIEmrkC8Vsu1/ZrV/v9Eo=; b=I+5Nj/A2ipEsBm1VokhkFI6rI81j9NWzaLsN01Ar1rogDLVQlOgkrtjNzclQrropDJ fckWKead1UlSxFHgZAL+470GOpgvQ0ilaUtOV7qjrTt/hDq1bD8dfXgmv49VUABcegi9 lZblzKDfmErS6H1OdzxNa3YiaLh6QyNxWJry6f7fB/57JVbzPcU2VoKwH7cfNftLKYNm oTDnbRDJAx8QDhDopa39UJmQwSc53Ss0vm8vjZKPJ4zYON5f1I36HRjxLM0kQJUO8GxE l+PyTuCdiq1MnxPTM8arbcLPhFvuiJlDQyMPovG6gKJc53IgKAEvi5RFd2JOAKwfaCpT anZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=CBpdjjhJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 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. [208.118.235.17]) by mx.google.com with ESMTPS id c2si11963874qtd.114.2017.07.10.12.23.28 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 10 Jul 2017 12:23:28 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.b=CBpdjjhJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 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]:42625 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUeHG-00006h-7S for patch@linaro.org; Mon, 10 Jul 2017 15:23:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUeGX-0008BK-5Y for qemu-devel@nongnu.org; Mon, 10 Jul 2017 15:22:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUeGT-00078U-Qb for qemu-devel@nongnu.org; Mon, 10 Jul 2017 15:22:41 -0400 Received: from mail-wr0-f179.google.com ([209.85.128.179]:33527) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dUeGT-00078B-KJ for qemu-devel@nongnu.org; Mon, 10 Jul 2017 15:22:37 -0400 Received: by mail-wr0-f179.google.com with SMTP id r103so151966375wrb.0 for ; Mon, 10 Jul 2017 12:22:37 -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=V65CAUygFd3FgfSYAI4WlSRIEmrkC8Vsu1/ZrV/v9Eo=; b=CBpdjjhJvPz5fbs5ABWddP3HczcOoukjY6GRx4yYbviSFeT3uuRzxG6KA9Bk+oSijr 2VpwPMeldS2nyGbOEDagBMLnQxf804gjkcC39S8avxl7euyXHiQBCs+0zPiuPxPAzY+p Oc2kAgEeDUl+wU/AQNVybU1rk+IVKZbaoQjN4= 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=V65CAUygFd3FgfSYAI4WlSRIEmrkC8Vsu1/ZrV/v9Eo=; b=rGHqU/JON1L4mLz78KDvOoONp4s7tD8nv30YgkArNigT9HpuUzFey/nhZ7CFoGRbbj aKQEDy5btanFiTKW5cbz8Em9W0aQMfKnI6HgIN8+XZmmmUCIg0RxEoCXOZladW8muewC ka3WA5iRFUtJ2FSTWm0vhh2cqX90An6ZgoGy1pw0mMrxXr48uadPWc8uGIrIhQ1KNltk mASFo7z+hEKQRhzUAddtWQUtrmiuJOjnETzStQp/awEeRpG9UUsYSU6m3IbLn6W1DCiT O4UIJFAIX8cn6prQo/n+d8u2DjXCXAmBDM/17AW9dAsCGECiQD/cXyoAqK2RyLhnky3/ kEAQ== X-Gm-Message-State: AIVw112RfMSGPnjLC5BtTIdj4XDE3rLmPhFAJJx+puobK8RbV7GNUVYp 7dUceNVwSDdI3P3Q X-Received: by 10.28.174.80 with SMTP id x77mr8970886wme.73.1499714496553; Mon, 10 Jul 2017 12:21:36 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id l73sm17172935wma.27.2017.07.10.12.21.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Jul 2017 12:21:32 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id C65D03E0A57; Mon, 10 Jul 2017 20:21:28 +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 20:21:28 +0100 Message-Id: <20170710192128.9048-6-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170710192128.9048-1-alex.bennee@linaro.org> References: <20170710192128.9048-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.179 Subject: [Qemu-devel] [PATCH v2 5/5] 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: , 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_EXIT which will always exit the run-loop. 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 Reviewed-by: Richard Henderson diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index ad46d84efb..48825f5722 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1789,7 +1789,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 94aa4bbb4d..c67a4f90d4 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -4484,7 +4484,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. */ @@ -9528,7 +9529,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;