From patchwork Thu Jul 13 14:19: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: 107682 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp2276827qge; Thu, 13 Jul 2017 07:21:14 -0700 (PDT) X-Received: by 10.200.39.196 with SMTP id x4mr5588250qtx.80.1499955674349; Thu, 13 Jul 2017 07:21:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499955674; cv=none; d=google.com; s=arc-20160816; b=NbnloeDPjf7nxdqiRl47EBB7XMi9CtK2U+1psA2zIEaN2q6dGHlFxoogw2Psrykrhm KFCWr8ZvLJe7dx49efa2FGNyBlF2SVcifv6/q3GsAPRPh9hTqHieCiwMpqGJ5COVcOER 86wGCsXmNjZzqW7Ms9DMpl2iP6TTiWQ6kSBw2j5PJeqpBaAZwfqy1t8g1GG/NO0Fybdq nShO277LXUmwJtJ9XgHCOQaEZBvLhPjHr9u5Uh7DWRaXqucfEPgPkkHINgEiJ+/bXFYM UX95ZELLg54hmUSqUv6I4E9PdByjvC5OMtdEvkSSSk2H82+O07OBJ3CS5+axcsYHBoa8 KJ8g== 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=M+8nmIK2ujRzl+PPkj/JQdJgEdEQPlAfJVlLIUiRr6Y=; b=rY0yzbkZKLrbsUaAyxBmdfQI/RCuhtxIhmTWAkp5+sQLZUQujhTS/eb3aekocv29Ma 1amzXjzINABjAen5qdJOeSwhGkQOUGHVdVJMFQ/JcrK+M6mVs7pbXYWAxH6dA0yW4pNP hI3s/dHgE2xxKF1ILF7RSreKwbMPNT93GqRVnKGSFMprTs2iOJBW6TBgegtTRmLMwARU 8g7hj+qWbHHz6qTG9AOxZvTP6mN9+TOwZNSMdR0BcmvHidJTgt3pHJogd27IYy26ehfN 7IoIv23rPlPC/WemsdqpDNApr9r5r3K5uChnirR/J0mhNRxA5LwRmFd6ApYnFt85EUPC xjrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=dpvXd4qr; 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 t69si5111647qka.264.2017.07.13.07.21.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 13 Jul 2017 07:21:14 -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=dpvXd4qr; 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]:60338 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVezP-00057Z-Pg for patch@linaro.org; Thu, 13 Jul 2017 10:21:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47947) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dVexv-0003wj-1H for qemu-devel@nongnu.org; Thu, 13 Jul 2017 10:19:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dVext-0006Is-SX for qemu-devel@nongnu.org; Thu, 13 Jul 2017 10:19:38 -0400 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]:38864) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dVext-0006ID-Mk for qemu-devel@nongnu.org; Thu, 13 Jul 2017 10:19:37 -0400 Received: by mail-wm0-x234.google.com with SMTP id f67so27728690wmh.1 for ; Thu, 13 Jul 2017 07:19: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=M+8nmIK2ujRzl+PPkj/JQdJgEdEQPlAfJVlLIUiRr6Y=; b=dpvXd4qr3G9XUTCLs4Undp3rPY7O3GQQgEI8Q4145momD7bO/Crl63PgseeeBR0k+F ow1HztiXXD/a/2NmUcoKvJcki93XCvlyMzm/INDC9kH0LUFW5Nh+LlvGbT2KezyJTbl8 yN8520QJ5z791Nfnb/YqKOVIzc9ZpX4Y7IpSs= 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=M+8nmIK2ujRzl+PPkj/JQdJgEdEQPlAfJVlLIUiRr6Y=; b=ZlkYt4UikxrlGnnDcynTAiRQ9QwVG+4cOC/Sq2Z7vAEBepFf0e8shqA+sRT54/cR64 Ol01s+fUB1ZoRc08l0GTc9tm8RAYO5NTC/MSfuGZdaXYvKjCftRlHjaqFy5A2yhCUtz8 3zLum2v2TU5AdTC9Ep6PQtn2UomS8uSyFrgfx35JW7UKmiu1SwnnARZY56/LcvRH220I 07BPpmlfa80cVoeXk1AMvV7c/PWqrEEwlk8pFhXCOBUTydbow6YUi/lScMEGIjLQIBUW 0Iu8EV+7YdZO9EKIMLaRPIxM19JfA9bo4/Z6XwtZGNiZ6FOQalvOArLszsFZkP7YPJ/l MONA== X-Gm-Message-State: AIVw112wF0TPUgynowzwpurYIH9j761y95WvcmiwR8blU925UKmuxikc Oe8HE661wYiTF9SI X-Received: by 10.28.224.134 with SMTP id x128mr2493085wmg.12.1499955576634; Thu, 13 Jul 2017 07:19:36 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id l73sm8806105wma.27.2017.07.13.07.19.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 07:19:32 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 518433E0B27; Thu, 13 Jul 2017 15:19:29 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Date: Thu, 13 Jul 2017 15:19:28 +0100 Message-Id: <20170713141928.25419-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170713141928.25419-1-alex.bennee@linaro.org> References: <20170713141928.25419-1-alex.bennee@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c09::234 Subject: [Qemu-devel] [PATCH v4 6/6] 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: "Emilio G . Cota" , qemu-devel@nongnu.org, qemu-arm@nongnu.org, Joakim Bech , Etienne Carriere , =?utf-8?q?Alex_Benn=C3=A9e?= , Jaroslaw Pelczar 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. 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 --- 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 2ac565eb10..3fa39023ca 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 d8892d9ba5..2d2b3f772c 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -4478,7 +4478,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. */ @@ -9522,7 +9523,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;