From mboxrd@z Thu Jan 1 00:00:00 1970 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) From: =?UTF-8?q?Alex=20Benn=C3=A9e?= Date: Mon, 10 Jul 2017 20:21:28 +0100 Message-Id: <20170710192128.9048-6-alex.bennee@linaro.org> In-Reply-To: <20170710192128.9048-1-alex.bennee@linaro.org> References: <20170710192128.9048-1-alex.bennee@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [Qemu-devel] [PATCH v2 5/5] target/arm: use DISAS_EXIT for eret handling List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: peter.maydell@linaro.org, rth@twiddle.net, cota@braap.org Cc: qemu-devel@nongnu.org, =?UTF-8?q?Alex=20Benn=C3=A9e?= , Etienne Carriere , Joakim Bech , "open list:ARM" 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(-) 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; -- 2.13.0