From patchwork Sun May 25 01:08:46 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Edgar E. Iglesias" X-Patchwork-Id: 352207 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1A9E0140083 for ; Sun, 25 May 2014 11:21:45 +1000 (EST) Received: from localhost ([::1]:49934 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoN8A-0003Jc-K6 for incoming@patchwork.ozlabs.org; Sat, 24 May 2014 21:21:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58185) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoN7f-0002dd-Vi for qemu-devel@nongnu.org; Sat, 24 May 2014 21:21:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WoN7Z-0007Ei-Vo for qemu-devel@nongnu.org; Sat, 24 May 2014 21:21:11 -0400 Received: from mail-we0-x22d.google.com ([2a00:1450:400c:c03::22d]:53498) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoN7Z-0007Ed-Pa for qemu-devel@nongnu.org; Sat, 24 May 2014 21:21:05 -0400 Received: by mail-we0-f173.google.com with SMTP id u57so6494912wes.18 for ; Sat, 24 May 2014 18:21:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8nKvkUpnaTt8Zp8NPckwqxNdIjzaYLxFZaP2cAEQ3v4=; b=i8HEm7ZHr4H0Oej82V4rghbCXf/rrxNAvzGGpTaGPoFWnSffJILTFyI4ai6AKc7DeJ 3qIWLOgeBP5jjTHeWGM7rWzjJ0Vg+Y1btb6T0/3y3aYGxLZV6ePu6o/t4r/fsBTGYJU8 k8jpol66GRm0mYWK1VQb281jfXgLM+uZoqgkAq9nghjPOxEKB4bGP1IOKp7LGPw0W3n4 uitxOdKXQl5GEgwU7FSn6gyNWSwotapnKwb2l9UF5gQMxEv1vLFKsVUrjeaSuzCxFKR+ 2SRxQj3V0moBzqHKvq8ue3A4OHid5uwsTKW46aRDmR2yDd4tB2xLsB7ZPQLUUNNGIkiF aOuQ== X-Received: by 10.180.24.68 with SMTP id s4mr15312354wif.12.1400980865050; Sat, 24 May 2014 18:21:05 -0700 (PDT) Received: from localhost ([203.126.243.116]) by mx.google.com with ESMTPSA id w6sm14508112wjq.29.2014.05.24.18.20.59 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 24 May 2014 18:21:04 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Sun, 25 May 2014 11:08:46 +1000 Message-Id: <1400980132-25949-18-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1400980132-25949-1-git-send-email-edgar.iglesias@gmail.com> References: <1400980132-25949-1-git-send-email-edgar.iglesias@gmail.com> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c03::22d Cc: rob.herring@linaro.org, peter.crosthwaite@xilinx.com, aggelerf@ethz.ch, agraf@suse.de, john.williams@xilinx.com, greg.bellows@linaro.org, alex.bennee@linaro.org, christoffer.dall@linaro.org, rth@twiddle.net Subject: [Qemu-devel] [PATCH v5 17/23] target-arm: A64: Forbid ERET to higher or unimplemented ELs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: "Edgar E. Iglesias" Reviewed-by: Peter Crosthwaite Signed-off-by: Edgar E. Iglesias --- target-arm/op_helper.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c index c2b4bf0..e95a7f4 100644 --- a/target-arm/op_helper.c +++ b/target-arm/op_helper.c @@ -389,6 +389,7 @@ void HELPER(exception_return)(CPUARMState *env) unsigned int spsr_idx = aarch64_banked_spsr_index(1); uint32_t spsr = env->banked_spsr[spsr_idx]; int new_el, i; + int cur_el = arm_current_pl(env); if (env->pstate & PSTATE_SP) { env->sp_el[1] = env->xregs[31]; @@ -410,8 +411,11 @@ void HELPER(exception_return)(CPUARMState *env) env->regs[15] = env->elr_el[1] & ~0x1; } else { new_el = extract32(spsr, 2, 2); - if (new_el > 1) { - /* Return to unimplemented EL */ + if (new_el > cur_el + || (new_el == 2 && !arm_feature(env, ARM_FEATURE_EL2))) { + /* Disallow return to an EL which is unimplemented or higher + * than the current one. + */ goto illegal_return; } if (extract32(spsr, 1, 1)) {