From patchwork Mon Jul 10 15:47:44 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: 107306 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp3595227qge; Mon, 10 Jul 2017 08:49:50 -0700 (PDT) X-Received: by 10.200.46.253 with SMTP id i58mr5398479qta.89.1499701789524; Mon, 10 Jul 2017 08:49:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499701789; cv=none; d=google.com; s=arc-20160816; b=leBVAqiX5ADabTdqTXvPHmsHqBoBxNf31VUB2XOjic5Nw8htX2BFBAJLY5+CnNnFnm BDvrfthFpW7AfhOVU4k48XRWCEcYId/j/7bFOwsiwr6seOqxFkCGBA67cJnAuztzQZGR fgTdk4nCCO8i2xFmKjWCUsA6Q4hHBLIzCdKN4fEDbcMtzwvtalssnca8PKIAhGZqwRza nntVlIq2ZN3JSjd2hsux8d3Asxb2yvgh0U/3rpwAxxRfkqKRD7syZgxlA8XuwGHQB9i4 rpoiYo9HVC4dCH31mrAEVeQF2ClASE+gWQ7In3FVqfAE0s3QQ8Apsn40gSyJSTq1UObH 4b2Q== 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=oiYY7L6CJhTMaujluKlhbW1IrGWZZrdUFXSimciraWk=; b=OJAkz+7pZdveKsZFixhPC9NjwaDkJrjOHSipqb3lzlMJRL2sJ0rhRGoQP/jX/M+Uxv ycK15MU7x1/WlC6Cq9tq10g4ygHus8ejZbgNTz7CTnaYNp6mtlrSiA541x8h0zHbMC2m QWF7nNqU8WeZmpmXjjQ86VGQXWDjuO5MivqOlbRmNh0n6fYXLVuLyHpZCeQ3b35IL7Dg lLWzN7UMQ9nm9u0zXIIpJj6JzIiEKYIIOE2YCWX7YOZqARrWHVJNCs3cepRobpK7D1JQ p1+6QR/Gpqtm3fM4Hzmtnh5VYO5BCH8hdJfWuhGE3reG/vm12G+yT/MPgDA3S7dHOmm/ K2XQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=h/7CfWg/; 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 t85si11070781qkl.159.2017.07.10.08.49.49 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 10 Jul 2017 08:49:49 -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=h/7CfWg/; 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]:41510 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUawV-0006nw-0T for patch@linaro.org; Mon, 10 Jul 2017 11:49:47 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUauj-00061N-0c for qemu-devel@nongnu.org; Mon, 10 Jul 2017 11:47:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUauf-0003WS-RM for qemu-devel@nongnu.org; Mon, 10 Jul 2017 11:47:57 -0400 Received: from mail-wr0-x236.google.com ([2a00:1450:400c:c0c::236]:34150) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dUauf-0003W7-Ie for qemu-devel@nongnu.org; Mon, 10 Jul 2017 11:47:53 -0400 Received: by mail-wr0-x236.google.com with SMTP id 77so144029784wrb.1 for ; Mon, 10 Jul 2017 08:47:53 -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=oiYY7L6CJhTMaujluKlhbW1IrGWZZrdUFXSimciraWk=; b=h/7CfWg/SKGebGd8i5qjlitz2pxj6Ws0dujvU/W7raGar69kIroM7QEvsHZfuVveFD Y/33jiJ6T6cKPcSjbk0MyjmihvBg2w44gx6l+kSaEvGZlR081HpKV5mIXGsT1I/iifH5 gHD1bQqTHkSe2WgG+Uy6LOw/t4EAFxVBAGmIM= 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=oiYY7L6CJhTMaujluKlhbW1IrGWZZrdUFXSimciraWk=; b=WstPBN+kN7o6vSyWWiVuR7ut57AkJ62Co4cP0SMwPr86TUhmkVfFUKCuknBy8itCs5 PCA97K9ivMwCdKq9IXSAIvlCNr4niCDpgvGeeUVIJjFsf7rsazrsA5xob/JvpRfbEg/Y sV8DF1HkbHH8uZqqt07PwpNTuGxq/VdHvIBVq0yHibCKnN4XjvDzhBLDLvs10VjtKozK gF9ULJ9NLxZwoSNZI2ZQM/jHR25ozgLVU1Rt1jSpc9HeOzwY8Zprxz3fHCJAQsHZZaGH s3qjfvnPlf52VfmHcMspTPoOUaN4ogEAYaEuLBkeJgMoY9nlIxeXY5hn08ChcQa06wZ0 9oww== X-Gm-Message-State: AIVw11054ysTkOvLZO3qbrWMIBtlyf+BxwVbcvTMTq+9qurxl8hGsTsD DeO1gYey+3i9fO3Z X-Received: by 10.223.164.80 with SMTP id e16mr8412000wra.24.1499701672385; Mon, 10 Jul 2017 08:47:52 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id x94sm8938261wrb.47.2017.07.10.08.47.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Jul 2017 08:47:49 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 5E6AA3E0258; 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:44 +0100 Message-Id: <20170710154749.13624-2-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: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::236 Subject: [Qemu-devel] [PATCH v1 1/6] include/exec/exec-all: document common exit conditions 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: Paolo Bonzini , Peter Crosthwaite , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, =?utf-8?q?Llu=C3=ADs_Vilanova?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" As a precursor to later patches attempt to come up with a more concrete wording for what each of the common exit cases would be. CC: Emilio G. Cota CC: Richard Henderson CC: Lluís Vilanova Signed-off-by: Alex Bennée --- include/exec/exec-all.h | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) -- 2.13.0 diff --git a/include/exec/exec-all.h b/include/exec/exec-all.h index 8096d64a1d..a23894f687 100644 --- a/include/exec/exec-all.h +++ b/include/exec/exec-all.h @@ -35,11 +35,34 @@ typedef abi_ulong tb_page_addr_t; typedef ram_addr_t tb_page_addr_t; #endif -/* is_jmp field values */ +/* DisasContext is_jmp field values + * + * is_jmp starts as DISAS_NEXT. The translator will keep processing + * instructions until an exit condition is reached. If we reach the + * exit condition and is_jmp is still DISAS_NEXT (because of some + * other condition) we simply "jump" to the next address. + * The remaining exit cases are: + * + * DISAS_JUMP - Only the PC was modified dynamically (e.g computed) + * DISAS_TB_JUMP - Only the PC was modified statically (e.g. branch) + * + * In these cases as long as the PC is updated we can chain to the + * next TB either by exiting the loop or looking up the next TB via + * the loookup helper. + * + * DISAS_UPDATE - CPU State was modified dynamically + * + * This covers any other CPU state which necessities us exiting the + * TCG code to the main run-loop. Typically this includes anything + * that might change the interrupt state. + * + * Individual translators may define additional exit cases to deal + * with per-target special conditions. + */ #define DISAS_NEXT 0 /* next instruction can be analyzed */ #define DISAS_JUMP 1 /* only pc was modified dynamically */ -#define DISAS_UPDATE 2 /* cpu state was modified dynamically */ -#define DISAS_TB_JUMP 3 /* only pc was modified statically */ +#define DISAS_TB_JUMP 2 /* only pc was modified statically */ +#define DISAS_UPDATE 3 /* cpu state was modified dynamically */ #include "qemu/log.h" From patchwork Mon Jul 10 15:47:45 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: 107312 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp3600994qge; Mon, 10 Jul 2017 08:55:11 -0700 (PDT) X-Received: by 10.55.17.77 with SMTP id b74mr4999709qkh.257.1499702111303; Mon, 10 Jul 2017 08:55:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499702111; cv=none; d=google.com; s=arc-20160816; b=y2HvfnjaPTLIUkFXs0vVjYMMwWZb6GG2aa+6zdTM45V2VNeEaARAhgWiYP5OlBtZRY pa3WJ60fWIQwqi6OwWOZ7ANr1137HEznzIhjGsVl/K5Ub/v5fn0XWMIUs9ZXxARDkGwB /qE2qVc6UT1XokHdl5aev00TjxVqC2qXEC8nJXo2wZAV1eoc380BFKS/IFVfkCfsK+kn KRUzxME6AcgRrcktyWFJpMEuYiUucG16DcepB9m8FbxdZt6BQf623PBImS/oLqYgE8bh 67+SYczImlQaxjiHcEwHoARWFFtKbBlClFIcTSGD07VnA2Zd/qvTEFNCQbFoUxrtLEUi z/mQ== 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=d+lUf75p7oCpeoNpdjeEYcXfr0douZtxpAcsHe48WmA=; b=qa4fBn8T8nnpG5J+J7b0vHjCK61rJPoZ2yVUhfj6eCPM9MD9FRjsDKNm9D+OdOsQTg cqk+BFF/5A8OADc8jdNbxaJn6FTF2Prmb5BA53NLO/2EVnFLSM16ezNq7TkLFWM0nWW4 9BV4CryjMsndBa4t3jknxQ5fccLBBbl4SkhxIV9baEC0s7GdAKkl2L3PFFlRledc/mDz ZNSVO+1L/aysF2pRfXldHeQ+CNHtFT7UkStlk6g70ebYgcfa5yDB41O+BYcFIweTx1s5 vaJWL4ebvi7TCRFojxtxfJ0lC/MX5+pXaML2wc2oQ6ZIRhDm0S5E6rM2PHIRHPER1s75 Y5dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=JOpQYNS0; 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 h23si11038931qtc.321.2017.07.10.08.55.10 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 10 Jul 2017 08:55:11 -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=JOpQYNS0; 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]:41548 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUb1h-0003oi-1f for patch@linaro.org; Mon, 10 Jul 2017 11:55:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUavi-0006g9-Sh for qemu-devel@nongnu.org; Mon, 10 Jul 2017 11:49:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUavf-00048d-QB for qemu-devel@nongnu.org; Mon, 10 Jul 2017 11:48:58 -0400 Received: from mail-wr0-f170.google.com ([209.85.128.170]:33143) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dUavf-00048A-Jo for qemu-devel@nongnu.org; Mon, 10 Jul 2017 11:48:55 -0400 Received: by mail-wr0-f170.google.com with SMTP id r103so144219685wrb.0 for ; Mon, 10 Jul 2017 08:48:55 -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=d+lUf75p7oCpeoNpdjeEYcXfr0douZtxpAcsHe48WmA=; b=JOpQYNS0c8cQLeacsigAr9qXuJl1vd9St8eamPiGMe7jfuwOR4Ztsx+wP3d5i9Flpj Tp2eRWrKFL/BnEEJl0lbW5JPuZV4wBX1VC7pDkoPcYauuSbEUBkOrct2r7GzZxKJO0NN TOfcv2wmnIc8jaTz9cWAB0otX4B90upf7ZupY= 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=d+lUf75p7oCpeoNpdjeEYcXfr0douZtxpAcsHe48WmA=; b=RoS1BJ/gz3vt54gf9CYH0jyXzBaSFsQ3rUq3ZPwJ5BpgW5nsmTD4AhOedY3koFC9Bn K5wUNBgT0u90FLdsOw6P/NsVtPSHEnhjI2FG9lrkPWEDGg8ZleBq3pXhvXZE6DbzYoTx AIaZndVy/o0435269FG4j+rzJByKWXIq0PDqFXVLCVw8p8KQr2tevXV+p25gEFC9RcZF azqO85m6GfyTvIVE4qXSFuG9MsX2MzOEwpwJkN4x52sj1zulZPhqDr15D6/+Xapi9CGP YkpPs7aDLH4Ka0htsUX4PGqBJD0WZuPy5V/vIsf21u76kP2+K7NuBuQw6HrObkvgmri2 MPaw== X-Gm-Message-State: AIVw112qoT1fVqmxbK1a6ltqYNPjaEh9utcw+NgFmILp4kIpstoy9AEU 5UqW1ft8R3ipIhvn X-Received: by 10.28.139.204 with SMTP id n195mr8390319wmd.14.1499701674336; Mon, 10 Jul 2017 08:47:54 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id z190sm11434839wmz.31.2017.07.10.08.47.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Jul 2017 08:47:51 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 77CCD3E03FE; 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:45 +0100 Message-Id: <20170710154749.13624-3-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 2/6] target/arm/translate.c: make DISAS_UPDATE match declared semantics 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: "open list:ARM" , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" DISAS_UPDATE should be used when the wider CPU state other than just the PC has been updated and we should therefor exit the TCG runtime and return to the main execution loop rather assuming DISAS_JUMP would do that. As some DISAS_UPDATE users may update the PC dynamically via a helper we also push the updating to the PC to hhe call sites which set ->is_jmp to DISAS_UPDATE. Signed-off-by: Alex Bennée --- target/arm/translate.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) -- 2.13.0 diff --git a/target/arm/translate.c b/target/arm/translate.c index 0862f9e4aa..f9c4aee1b6 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -4430,6 +4430,7 @@ static void gen_msr_banked(DisasContext *s, int r, int sysm, int rn) tcg_temp_free_i32(tcg_tgtmode); tcg_temp_free_i32(tcg_regno); tcg_temp_free_i32(tcg_reg); + gen_set_pc_im(s, s->pc); s->is_jmp = DISAS_UPDATE; } @@ -4452,6 +4453,7 @@ static void gen_mrs_banked(DisasContext *s, int r, int sysm, int rn) tcg_temp_free_i32(tcg_tgtmode); tcg_temp_free_i32(tcg_regno); store_reg(s, rn, tcg_reg); + gen_set_pc_im(s, s->pc); s->is_jmp = DISAS_UPDATE; } @@ -8058,6 +8060,7 @@ static void gen_srs(DisasContext *s, tcg_temp_free_i32(tmp); } tcg_temp_free_i32(addr); + gen_set_pc_im(s, s->pc); s->is_jmp = DISAS_UPDATE; } @@ -8146,6 +8149,7 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) /* setend */ if (((insn >> 9) & 1) != !!(s->be_data == MO_BE)) { gen_helper_setend(cpu_env); + gen_set_pc_im(s, s->pc); s->is_jmp = DISAS_UPDATE; } return; @@ -11619,6 +11623,7 @@ static void disas_thumb_insn(CPUARMState *env, DisasContext *s) ARCH(6); if (((insn >> 3) & 1) != !!(s->be_data == MO_BE)) { gen_helper_setend(cpu_env); + gen_set_pc_im(s, s->pc); s->is_jmp = DISAS_UPDATE; } break; @@ -12076,7 +12081,6 @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb) break; case DISAS_NEXT: case DISAS_UPDATE: - gen_set_pc_im(dc, dc->pc); /* fall through */ default: /* FIXME: Single stepping a WFI insn will not halt the CPU. */ @@ -12095,12 +12099,11 @@ void gen_intermediate_code(CPUARMState *env, TranslationBlock *tb) case DISAS_NEXT: gen_goto_tb(dc, 1, dc->pc); break; - case DISAS_UPDATE: - gen_set_pc_im(dc, dc->pc); - /* fall through */ case DISAS_JUMP: gen_goto_ptr(); break; + case DISAS_UPDATE: + /* fall through */ default: /* indicate that the hash table must be used to find the next TB */ tcg_gen_exit_tb(0); From patchwork Mon Jul 10 15:47:46 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: 107309 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp3597847qge; Mon, 10 Jul 2017 08:52:11 -0700 (PDT) X-Received: by 10.200.38.244 with SMTP id 49mr5133460qtp.236.1499701931716; Mon, 10 Jul 2017 08:52:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499701931; cv=none; d=google.com; s=arc-20160816; b=R7P5qvol85Im1TMP0U6ybKXTxCceiH0qSSmHgEa681fwTXHi6/ephpemMGqfRobflS vX5p42ZR1kdgmzDye7totwXqa6IMdVackWAuh9Qnrm5yJUz6t1BSShIRvwztqNh17ZGQ KQo8shjIyzuPBmBVlJPM6PQoXA2P1+sZI+9WlCPUkcDnBsmXJ6IE1m8ZhGNipVh4XWM5 S46sB0cmBX7Ath0tQhzE/JEYk69173FZxdJklTWuzjptwDufqm3KLKSvkH5y5U3N8Xy1 1eBOXz6shMDpknzZb0+nWYacOxk5ACabNkiJCW9QE6A0o6vnNoK0ENb10UNYIQ9k355w 9Kzw== 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=LsuhQWEAyocl0g3jXFez4wFNmW3AINMa1lQKC+nMR34=; b=pOYq+p6hDBWigyKwCQ3Oh2K7gNx3oYZmvPmxkoUxwCgbnWGTus17s8aZhsQeZHdfCL c4afwrdOpJYzK4vYs4k4YJNC2WX66AtrH8XxNx1u3Yb3vP6L/122A+31QMKxJfjfvWi8 0961CbIN2GU/Qv7nLYdkBy8SEMmNFG3A48S9IJTzhR3Kt/pc7qZd6ln+OkOx0hDP/otM x60q3QiMY+sCWVCWJ7dYDkg5Fki8fbJwVYuA6L3+2MMwZ+vHWpYEk6qy+9mv9Mhqt9jc /2uY1yjMwq0dgQBhjQphYaUyA2rGcJQCWkAJwjG37xPvxbMCqyQ//UW2t5vjonxGnqGr oAvA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=HAdy5DkG; 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 c185si11036585qka.342.2017.07.10.08.52.11 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 10 Jul 2017 08:52:11 -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=HAdy5DkG; 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]:41529 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUayn-0000lm-4o for patch@linaro.org; Mon, 10 Jul 2017 11:52:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUavl-0006jR-QR for qemu-devel@nongnu.org; Mon, 10 Jul 2017 11:49:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUavi-0004Ai-Mz for qemu-devel@nongnu.org; Mon, 10 Jul 2017 11:49:01 -0400 Received: from mail-wr0-f177.google.com ([209.85.128.177]:36318) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dUavi-0004AQ-Gd for qemu-devel@nongnu.org; Mon, 10 Jul 2017 11:48:58 -0400 Received: by mail-wr0-f177.google.com with SMTP id c11so144113337wrc.3 for ; Mon, 10 Jul 2017 08:48:58 -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=LsuhQWEAyocl0g3jXFez4wFNmW3AINMa1lQKC+nMR34=; b=HAdy5DkGWqNrMEI3rV9UKeOqNL9HlJPor/RKO4NcR1eqMuOlRh1yEOGNLBTwXOoHto ThrW4ZM0/T941yhupw01Q6Oa2AlZlfvlOg6154cKqiFGYzK3gvVSUIgJqd3kvs3QrdoO 0qwxPRb3MiTz1oEn/+LijwfRtX5f7xMfge128= 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=LsuhQWEAyocl0g3jXFez4wFNmW3AINMa1lQKC+nMR34=; b=R4tyL5nxXVTFoIjD9pqI8tGqTMl79gF5lOzCd27RJTnrLsEtWawoI2zWakS0Cotc/S 2iZJKtTa8ctuQty3yPiP+J/iXYV9sbvSy2KrKwktEsyc8yBEISIFiLHXR8hzvHuBZfWM 1X35whCoZBwY6gsxDr4jf7w02GqJXxBFf2+ze7pDvOHU521s6/JnWp5o3vG0BJGax9Ac zvbvdG126OdPOk7R2QMmn1caOpnq9HU3UCWJOzafkAjxb1GmMAN3iviFs9lZNXrXqfWp NLwtuTyp2dAVkj22Rtw0J+jZERxeiEM8pyFx872eZ61KYdw11JPPKWBPPDalDSjv7lg9 csww== X-Gm-Message-State: AIVw111td6Pg1sfMaGFSFP2lATNnlGoMOmSjkYIzr4B5MtamHKaWmZlm 8GQ4rpCVqMh5Ljeg X-Received: by 10.28.0.84 with SMTP id 81mr8316068wma.58.1499701677347; Mon, 10 Jul 2017 08:47:57 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id n71sm10820242wrb.62.2017.07.10.08.47.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Jul 2017 08:47:52 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 8B83C3E0641; 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:46 +0100 Message-Id: <20170710154749.13624-4-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.177 Subject: [Qemu-devel] [PATCH v1 3/6] target/arm/translate-a64: make DISAS_UPDATE match declared semantics 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: "open list:ARM" , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" DISAS_UPDATE should be used when the wider CPU state other than just the PC has been updated and we should therefor exit the TCG runtime and return to the main execution loop rather assuming DISAS_JUMP would do that. As some DISAS_UPDATE users may update the PC dynamically via a helper we also push the updating to the PC to the call sites which set ->is_jmp to DISAS_UPDATE. Signed-off-by: Alex Bennée --- target/arm/translate-a64.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) -- 2.13.0 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index e55547d95d..fe1c49b565 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1393,6 +1393,7 @@ static void handle_sync(DisasContext *s, uint32_t insn, * a self-modified code correctly and also to take * any pending interrupts immediately. */ + gen_a64_set_pc_im(s->pc); s->is_jmp = DISAS_UPDATE; return; default: @@ -1593,12 +1594,14 @@ static void handle_sys(DisasContext *s, uint32_t insn, bool isread, if ((s->tb->cflags & CF_USE_ICOUNT) && (ri->type & ARM_CP_IO)) { /* I/O operations must end the TB here (whether read or write) */ gen_io_end(); + gen_a64_set_pc_im(s->pc); s->is_jmp = DISAS_UPDATE; } else if (!isread && !(ri->type & ARM_CP_SUPPRESS_TB_END)) { /* We default to ending the TB on a coprocessor register write, * but allow this to be suppressed by the register definition * (usually only necessary to work around guest bugs). */ + gen_a64_set_pc_im(s->pc); s->is_jmp = DISAS_UPDATE; } } @@ -11364,16 +11367,9 @@ void gen_intermediate_code_a64(ARMCPU *cpu, TranslationBlock *tb) case DISAS_NEXT: gen_goto_tb(dc, 1, dc->pc); break; - default: - case DISAS_UPDATE: - gen_a64_set_pc_im(dc->pc); - /* fall through */ case DISAS_JUMP: tcg_gen_lookup_and_goto_ptr(cpu_pc); break; - case DISAS_EXIT: - tcg_gen_exit_tb(0); - break; case DISAS_TB_JUMP: case DISAS_EXC: case DISAS_SWI: @@ -11397,6 +11393,11 @@ void gen_intermediate_code_a64(ARMCPU *cpu, TranslationBlock *tb) */ tcg_gen_exit_tb(0); break; + case DISAS_UPDATE: + case DISAS_EXIT: + default: + tcg_gen_exit_tb(0); + break; } } From patchwork Mon Jul 10 15:47:47 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: 107307 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp3595438qge; Mon, 10 Jul 2017 08:50:01 -0700 (PDT) X-Received: by 10.237.43.100 with SMTP id p91mr5055531qtd.130.1499701801146; Mon, 10 Jul 2017 08:50:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499701801; cv=none; d=google.com; s=arc-20160816; b=pXcTEVOYJnH7bl1y1D++U/fwU1oGxUcFt+OHIsiTKHZ7VQ/hRcIA6PTTYQIVD0xV68 wMlX5mkor87qcF8iItWS1ryA61Ndu+ADRzQSwq8jmccYnVsmt4PcJ2VpdldzkxPaqBjS odDOzuJqpPm422V5oPSzRshPdUAG0hyZpa5WgF/JKTqbISM3KZW5OAgB5NT6IrSwjA0q eqpEeawx+iKE2OBw8ntAfR33hByufZ2NpVnxZgUkcxcz+bXGoQPJzLsPdqlTru6xBtAD orKxL5HjxrnGO0n33YpbSTbU6eUsEOvUyuOl0CuNvxsAcuvCNE2W3VfE5C24AdGK08u8 9TOw== 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=hyKMaKTk7jLtaMWZRLtpBIFzt1M4l1/ZhOCmvMZZZNY=; b=rCy0FGjByOm6AgMyZY8f5k+vx5Ri3IU//vvmIunkK8rCnurRWELMKZ7biW8w7sPx7g 5axsiMDlqDC8FHX9gjGUy6sAXgFwVcbPjXQ3psc97NxJRBvA3rr1J7z01wwu5hlzCQ5b WQhlsQh4INiQD76onzx7SXUX1VjseqtpF6QwL4e1duoxqJ5V42gFkP5SZ2aYbAS1drR/ u3Xvx3WYXd02zv6CcMmjuPDYra3OJDUZRc8gaHqzWhjvLpwmrHyAxQuBfzQkYOOohaq0 HiHdeTBXFOY9LZPbHgcJaWA8OjVpDyVaQ+7Q6fKEJc3GSRzI8N3nEWvsHEcOd4AaYynU Gn5A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=hsjvlJSB; 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 f124si10918754qkj.308.2017.07.10.08.49.59 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 10 Jul 2017 08:50:01 -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=hsjvlJSB; 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]:41512 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUawf-0006xS-N2 for patch@linaro.org; Mon, 10 Jul 2017 11:49:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60785) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUauj-00061P-W8 for qemu-devel@nongnu.org; Mon, 10 Jul 2017 11:47:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUaui-0003Yg-R6 for qemu-devel@nongnu.org; Mon, 10 Jul 2017 11:47:57 -0400 Received: from mail-wr0-x235.google.com ([2a00:1450:400c:c0c::235]:36443) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dUaui-0003XH-K9 for qemu-devel@nongnu.org; Mon, 10 Jul 2017 11:47:56 -0400 Received: by mail-wr0-x235.google.com with SMTP id c11so144112136wrc.3 for ; Mon, 10 Jul 2017 08:47:56 -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=hyKMaKTk7jLtaMWZRLtpBIFzt1M4l1/ZhOCmvMZZZNY=; b=hsjvlJSBPzASXfWKDL9H2juO5YAVhQ97xDV5xwmr+jMYmL3BPXAbPeUuz+nmdvJJb+ 1+OWJIj1n3hVG4OMnNW0j7qwywvkyiLI7fxObQctuGe0rfhnyjdBooU+S0MRsLEY3s13 R/X6MDeOTTtixrbcfNLm0g4UHMqTt+Ofv79tc= 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=hyKMaKTk7jLtaMWZRLtpBIFzt1M4l1/ZhOCmvMZZZNY=; b=bgGeMEMu+Wi7FLx/eSf2c9j9hnhP14tMAC09BSlmSkHRkUCmRd2uqZdNiOHGZOiaZg AOlEgvbqbD2yEwtxqQX01RJPXrj9tujHbXAUFwODAsyvnfvvq8Xnn/R1ocW73Gsf6OMa 2jHDyADo5KDO4euFSROiSNuWCfHQ00kVn3ptQ2KtHEesXiCC/RdGa3q7f1Q33SKXRH3M bEkGxMmbwcnobmMwN/8mUO6TXyRB1Ns6QZ7rwFCWFYihtHBgzGims3J1nOlsF9bXIA9L 6rr9GcfoPuW/UpeyJtArfwhlYB3L1OI9xKq0c7WJeHnhTs1O9U4DJJojLRl5nHg3gdyl SYCw== X-Gm-Message-State: AIVw110f1fHgpcNMy2fIwufe/VheZ30FjFXa98ZFYNXr7bQy+Na7dcdF SYffhQJnY9R6yp7FokLTCQ== X-Received: by 10.28.156.202 with SMTP id f193mr8115763wme.22.1499701675451; Mon, 10 Jul 2017 08:47:55 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id y35sm11384307wrc.51.2017.07.10.08.47.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 10 Jul 2017 08:47:52 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id A9CFC3E07CF; 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:47 +0100 Message-Id: <20170710154749.13624-5-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: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::235 Subject: [Qemu-devel] [PATCH v1 4/6] target/arm/translate-a64: get rid of DISAS_EXIT 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: "open list:ARM" , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" We already have an exit condition that declares we should exit to the run-loop because wider CPU state changes have been made. Use DISAS_UPDATE and kill the architecture specific DISAS_EXIT. Signed-off-by: Alex Bennée --- target/arm/translate-a64.c | 3 +-- target/arm/translate.c | 6 ++++-- target/arm/translate.h | 4 ---- 3 files changed, 5 insertions(+), 8 deletions(-) -- 2.13.0 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index fe1c49b565..bde6ca934e 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1425,7 +1425,7 @@ static void handle_msr_i(DisasContext *s, uint32_t insn, tcg_temp_free_i32(tcg_op); /* For DAIFClear, exit the cpu loop to re-evaluate pending IRQs. */ gen_a64_set_pc_im(s->pc); - s->is_jmp = (op == 0x1f ? DISAS_EXIT : DISAS_JUMP); + s->is_jmp = (op == 0x1f ? DISAS_UPDATE : DISAS_JUMP); break; } default: @@ -11394,7 +11394,6 @@ void gen_intermediate_code_a64(ARMCPU *cpu, TranslationBlock *tb) tcg_gen_exit_tb(0); break; case DISAS_UPDATE: - case DISAS_EXIT: default: tcg_gen_exit_tb(0); break; diff --git a/target/arm/translate.c b/target/arm/translate.c index f9c4aee1b6..e840499c6f 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1194,11 +1194,13 @@ static void gen_exception_insn(DisasContext *s, int offset, int excp, s->is_jmp = DISAS_EXC; } -/* Force a TB lookup after an instruction that changes the CPU state. */ +/* Force a TB lookup after an instruction that changes the CPU state. + * (other than just the PC) + */ static inline void gen_lookup_tb(DisasContext *s) { tcg_gen_movi_i32(cpu_R[15], s->pc & ~1); - s->is_jmp = DISAS_EXIT; + s->is_jmp = DISAS_UPDATE; } static inline void gen_hlt(DisasContext *s, int imm) diff --git a/target/arm/translate.h b/target/arm/translate.h index 15d383d9af..6b2cc34c33 100644 --- a/target/arm/translate.h +++ b/target/arm/translate.h @@ -139,10 +139,6 @@ static void disas_set_insn_syndrome(DisasContext *s, uint32_t syn) * custom end-of-TB code) */ #define DISAS_BX_EXCRET 11 -/* For instructions which want an immediate exit to the main loop, - * as opposed to attempting to use lookup_and_goto_ptr. - */ -#define DISAS_EXIT 12 #ifdef TARGET_AARCH64 void a64_translate_init(void); From patchwork Mon Jul 10 15:47:48 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: 107310 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp3598320qge; Mon, 10 Jul 2017 08:52:36 -0700 (PDT) X-Received: by 10.55.100.130 with SMTP id y124mr4752541qkb.54.1499701956725; Mon, 10 Jul 2017 08:52:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499701956; cv=none; d=google.com; s=arc-20160816; b=dUHvIYt9liowZLSnQLXZavxX+vw8bFawXIjJ7bnWCBCiSRA1W91jhGqB0FEGB7p4Pa pHRYW5k3VWeHyzaPKYQm/KZaSqHgTUvls1X4VHygsGRgUw7ss18YuL6rIBlETszqwEoF 6VNesDgfJvSI6VcRaAUxAZOkfJDARD9ZULSfwq+x4RPI8xHeUJ0hmnySsTHewoVBXPQo O0xuylHBn1MdhdFyNuCs0/A5uLBtKs4VoGHcgiM2oZOEtnLowyN9US4+95adygqjQRFM teM3/M+7W2YZH7hQxjMG5GbeE9e4wb4zyxa7EtAULHtAnIPX+XjcqHPq4Jko+VmRW1fU 2mlg== 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=xaXIChuFtQzU2BFFQRDYvr57aCCwpvRqSY/ssnz7wE4=; b=x9tqMOzZQQII0D2OTIZRLK6XW/XQ3harsL27idbwijuBs66bkoO1HzxfaMCOaiyBh6 VGxycfaVim+EvGFGCgDN2AfFAl1HamvhMS0MAzhtXTyGFrOfCwAYp6U5UvrwuXDJnrhZ fLGxCmFuPlVgs217eVYcTrQF818FDXeMpYw2fJPE+vPxVtxNSXaJZ3JFMpRapfD6Q5zH zB+YlNmal8DdxHgPG5U3bxfrBVn0FC81pWANEBeE7NzkCKGyl2uLh+rZtl9i29YiXMFv GLd0SeH4JSNiuNPsa9QKtXF/wZSaG4vNm97bBka8VX0z63P4AbrE0fglL4qv4Fv9cmxD dWQg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=Kn6tlPwa; 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 h2si11224683qte.246.2017.07.10.08.52.36 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 10 Jul 2017 08:52:36 -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=Kn6tlPwa; 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]:41530 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUazC-0000sz-4P for patch@linaro.org; Mon, 10 Jul 2017 11:52:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60819) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUaun-00063j-Um for qemu-devel@nongnu.org; Mon, 10 Jul 2017 11:48:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUaun-0003aR-0m for qemu-devel@nongnu.org; Mon, 10 Jul 2017 11:48:01 -0400 Received: from mail-wr0-x234.google.com ([2a00:1450:400c:c0c::234]:34231) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dUaum-0003a5-QR for qemu-devel@nongnu.org; Mon, 10 Jul 2017 11:48:00 -0400 Received: by mail-wr0-x234.google.com with SMTP id 77so144034242wrb.1 for ; Mon, 10 Jul 2017 08:48:00 -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=xaXIChuFtQzU2BFFQRDYvr57aCCwpvRqSY/ssnz7wE4=; b=Kn6tlPwaWrvJBLX1PVi/wQHyvCa+tnA1ZLtMlCoRUeaDIalSfatqE2AHpxMIBdP/re HWq19yPVjE/VxqH7KCpli1A6ylMQNyx24uTZk5wHLYoXtp4ExD+Zk+dWavh1F4C0FcAr ugIOmZiV8ZtSH1sM/efWLlAWBh+aAZ7+E0EMg= 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=xaXIChuFtQzU2BFFQRDYvr57aCCwpvRqSY/ssnz7wE4=; b=pevId57S3Mf4G/1MC7mvMMX93d/ZpET4/9gQRo+wo2y93CGapRSm0X35PkEbwgSOqG rasUx4PN+vQZ6J7MWi78S3wgJvHCStxotp/jBVUGkNf/LvAgPdSEeuASqhhHnA6SeXVY i1mAxcsUwM+vZ/iW5Kem1EZc+wWkB/yyQW3EuM08kOUbbV9axNFKW9C5olB32ONtZw5a Y/TlSFkPQHwa2kMsL8ZPCPQUFSgW0fZKlx6FWlELJHdPAaGvwJUgzLqqWKG+aLQm7DdO VWEeohZwsIWva1GAlNEenUgEh2BnXWy4lPVzwGi3o8FEa72kX1uhgw6JDRCOSBj+Gv4R rupA== X-Gm-Message-State: AIVw112C5smlBjn1KKSwznQstynjblZIb93IwCUd08OnC4aUP5Yqs0Sd zZ34OSQHdvW8nfb+ X-Received: by 10.223.147.132 with SMTP id 4mr7603256wrp.107.1499701679560; Mon, 10 Jul 2017 08:47:59 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id m26sm19363033wrm.4.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 C76333E0A57; 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:48 +0100 Message-Id: <20170710154749.13624-6-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: Genre and OS details not recognized. X-Received-From: 2a00:1450:400c:c0c::234 Subject: [Qemu-devel] [PATCH v1 5/6] target/arm: use DISAS_JUMP for ISB 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: "open list:ARM" , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" While an ISB will ensure any raised IRQs happen on the next instruction it doesn't cause any to get raised by itself. We can therefor use DISAS_JUMP for ISB instructions and rely on the exit_request check at the top of each TB to deal with exiting if needed. Signed-off-by: Alex Bennée --- target/arm/translate-a64.c | 2 +- target/arm/translate.c | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) -- 2.13.0 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index bde6ca934e..fd9724b890 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -1394,7 +1394,7 @@ static void handle_sync(DisasContext *s, uint32_t insn, * any pending interrupts immediately. */ gen_a64_set_pc_im(s->pc); - s->is_jmp = DISAS_UPDATE; + s->is_jmp = DISAS_JUMP; return; default: unallocated_encoding(s); diff --git a/target/arm/translate.c b/target/arm/translate.c index e840499c6f..f7f5f917c7 100644 --- a/target/arm/translate.c +++ b/target/arm/translate.c @@ -1203,6 +1203,15 @@ static inline void gen_lookup_tb(DisasContext *s) s->is_jmp = DISAS_UPDATE; } +/* End the current block and force a TB lookup. We may chain to the + * next TB but exit_req will be immediately checked so we will exit to + * the main loop if we need to */ +static inline void gen_jump_tb(DisasContext *s) +{ + tcg_gen_movi_i32(cpu_R[15], s->pc & ~1); + s->is_jmp = DISAS_JUMP; +} + static inline void gen_hlt(DisasContext *s, int imm) { /* HLT. This has two purposes. @@ -8171,7 +8180,7 @@ static void disas_arm_insn(DisasContext *s, unsigned int insn) * self-modifying code correctly and also to take * any pending interrupts immediately. */ - gen_lookup_tb(s); + gen_jump_tb(s); return; default: goto illegal_op; @@ -10564,7 +10573,7 @@ static int disas_thumb2_insn(CPUARMState *env, DisasContext *s, uint16_t insn_hw * and also to take any pending interrupts * immediately. */ - gen_lookup_tb(s); + gen_jump_tb(s); break; default: goto illegal_op; 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;