From patchwork Tue Jul 11 17:59:37 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: 107414 Delivered-To: patch@linaro.org Received: by 10.182.45.195 with SMTP id p3csp11631obm; Tue, 11 Jul 2017 11:05:45 -0700 (PDT) X-Received: by 10.55.111.195 with SMTP id k186mr1455543qkc.206.1499796345229; Tue, 11 Jul 2017 11:05:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499796345; cv=none; d=google.com; s=arc-20160816; b=WkapgZAeM19VOLAkFkQtlhPeE/3wOZ0CX4P5jOvGJ14Ta1p4QX8EVrt/haylpI3TJG sqqvJ1XX3gryODNnd093gwMDznEpdfrIWCr6RT/0cLUbFqa9O++963IKtMt1f1xHMOtc LkRkp+dEn2YsF6JEX2OJGGTIEsCJa3vI3aljeHmzs+adm7cBdsNrFvRAwYyO5+W4SycT 5eLMIGQo4WTVJzkCFpAabWYNGq/8abw35pvB75aLLLqVOTbDv/zApt12VBp2mxjGej3w JtWeHjNhqH6W8UwYKIST8aBNsEKm88KPzLC9kOp0GTIIxChOdNsjvljUrbAyBU0Ic9/8 p5DA== 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=x2o5mdP7zuD828LkB7mQtBhpict2fQOo3TsMXHlbqVQ=; b=GjadUBdmVrWKdLf3pofuOFO4bmDAEAzUL1CFMuQy6W8zY7Wp2HdFybq8hElZ+COSbK 3FBZtFpeDu0OL5+uzcfJ2emMNP7hG8TE51aCFFXETDpDgevVatQqupNqLX8UC3yc6DvZ kGIVJ6T/G17RPdCxqv3hTX6G994va0/tWsPogNq+0T1CKjV+mtomoUqss4WwLo/npdhB ITdT7dO7JROXeujlKGAhwDw2YhU9xRDQ6O9zJ8gRmc37b1mbxR9wVZfYhPXm/EewsLDe dm9OSaMYurMAD5CicO4S3/fiSnCvx23WQXE/dPHie4rwDMJvGar7DQ0ZUTV6lvIrAq5a Ybhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.b=SQURLSEb; 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 b76si543483qkj.267.2017.07.11.11.05.44 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 11 Jul 2017 11:05:45 -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=SQURLSEb; 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]:48127 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUzXZ-0005t1-1u for patch@linaro.org; Tue, 11 Jul 2017 14:05:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56272) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dUzSu-0002WS-0R for qemu-devel@nongnu.org; Tue, 11 Jul 2017 14:00:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dUzSq-0005HG-Q8 for qemu-devel@nongnu.org; Tue, 11 Jul 2017 14:00:52 -0400 Received: from mail-wr0-f177.google.com ([209.85.128.177]:32853) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dUzSq-0005G0-KE for qemu-devel@nongnu.org; Tue, 11 Jul 2017 14:00:48 -0400 Received: by mail-wr0-f177.google.com with SMTP id r103so9571833wrb.0 for ; Tue, 11 Jul 2017 11:00:48 -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=x2o5mdP7zuD828LkB7mQtBhpict2fQOo3TsMXHlbqVQ=; b=SQURLSEbmMsBxeGSV/TrY7oZTfR9/Kvv2Ex88B9UTJ4NwlobhIetBT4BoRSpqdM4QE EPNMgDgcjzUtnMKQ95k8DOh6I5r+bkRzlt9kQF3fsMHqgE7eyYhTGHNzdb38Kt92YZFD F204zdTsAP0NVQy3LuNfMGTFZcv1j+CB6hRb0= 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=x2o5mdP7zuD828LkB7mQtBhpict2fQOo3TsMXHlbqVQ=; b=Zxizq811wtxquZJdgs0HMdUr1XkWMWkhz6/nbwAY5aYQsbifHwTunwiH6p+YFtmBdj tztbGVsqhetqL2jnjK0fTU3Z8ruzkWwjqwMNV09DH/gJq8xMTSrbtX0vPH+7BvR3TXUz Jmp7EywuIni/JXQ4mo/yina17HWkqCA1JfT6u0T+6jf/3WK0hSaPDicgPWf7uTY33M5N 4q4QxJNaFC/Ny1bKUYAIiqqNHHy31rl1XiIwlReMl6DvIRn+xhB2DfrIWsyX2CY0etoQ 9uWIeFMRCIE46ZEm5AX6piclx39r9A9YvPcrUe1j4OuUgVlsYSSugj4b9+qc9TisqFCv 9XQA== X-Gm-Message-State: AIVw110ulf+SrCviZLaGdXvna5NxzVi1QrRdmBl23ba+P0bJuoLLtyLP hiV/vKrgo6De2Al8 X-Received: by 10.28.133.76 with SMTP id h73mr12314205wmd.92.1499795987436; Tue, 11 Jul 2017 10:59:47 -0700 (PDT) Received: from zen.linaro.local ([81.128.185.34]) by smtp.gmail.com with ESMTPSA id g66sm13986221wmc.6.2017.07.11.10.59.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jul 2017 10:59:42 -0700 (PDT) Received: from zen.linaroharston (localhost [127.0.0.1]) by zen.linaro.local (Postfix) with ESMTP id 5C5593E0F9A; Tue, 11 Jul 2017 18:59:38 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org, rth@twiddle.net, cota@braap.org Date: Tue, 11 Jul 2017 18:59:37 +0100 Message-Id: <20170711175937.23140-7-alex.bennee@linaro.org> X-Mailer: git-send-email 2.13.0 In-Reply-To: <20170711175937.23140-1-alex.bennee@linaro.org> References: <20170711175937.23140-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 v3 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: 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. CC: Etienne Carriere CC: Joakim Bech 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 Reviewed-by: Emilio G. Cota 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 dbf919cce3..f1023d5263 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;