From patchwork Tue May 6 06:08:19 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: 346034 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id F0A811412E5 for ; Tue, 6 May 2014 16:19:35 +1000 (EST) Received: from localhost ([::1]:33135 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhYiz-0006tH-LC for incoming@patchwork.ozlabs.org; Tue, 06 May 2014 02:19:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhYiU-0005z1-NK for qemu-devel@nongnu.org; Tue, 06 May 2014 02:19:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WhYiO-0003EP-OW for qemu-devel@nongnu.org; Tue, 06 May 2014 02:19:02 -0400 Received: from mail-qa0-x233.google.com ([2607:f8b0:400d:c00::233]:60945) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhYiO-0003EI-Ia for qemu-devel@nongnu.org; Tue, 06 May 2014 02:18:56 -0400 Received: by mail-qa0-f51.google.com with SMTP id w8so4717821qac.24 for ; Mon, 05 May 2014 23:18:56 -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=qIK3e+gFm6z3i1/cjxKaBvIDHrsoXE9SnF+CX/8NaPw=; b=fSbpZN2JNZZrwwwmnpmF3mw6rizmx9R7TgGRbyy0+t96m77wdkjTvadWPodCkZigN8 G3An7whV62MbiNup2jc6Q4tg8QBSO64BXbBtlGJWFP7sT6P1K58mAVtoj2hREenpa7wD 7B43ecKxgTIhWNe1PBG2B0yM9KdrTIoX1+9del0vdSYFGdxjk0Tgy6OFXPNINqd8KMOc NZvsZ5JqMk3m5Koh8GMdLCagAL1MQOfQtkhPQOR0LrakefaZeHC2MvDNl31HZM3z7P3M eCqyFSTXp8qfwWJ22TdZncLKxmyspBwNksYdqBnP1AKbnlFTmUcDuiSYDg/MsG62Fk3Q Xacw== X-Received: by 10.224.50.81 with SMTP id y17mr51636000qaf.22.1399357136165; Mon, 05 May 2014 23:18:56 -0700 (PDT) Received: from localhost ([203.126.243.116]) by mx.google.com with ESMTPSA id r4sm21707839qat.16.2014.05.05.23.18.51 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 05 May 2014 23:18:55 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Tue, 6 May 2014 16:08:19 +1000 Message-Id: <1399356506-5609-16-git-send-email-edgar.iglesias@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1399356506-5609-1-git-send-email-edgar.iglesias@gmail.com> References: <1399356506-5609-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: 2607:f8b0:400d:c00::233 Cc: rob.herring@linaro.org, peter.crosthwaite@xilinx.com, john.williams@xilinx.com, alex.bennee@linaro.org, agraf@suse.de Subject: [Qemu-devel] [PATCH v1 15/22] target-arm: A64: Forbid ERET to increase the EL 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" Signed-off-by: Edgar E. Iglesias Reviewed-by: Peter Crosthwaite --- target-arm/op_helper.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/target-arm/op_helper.c b/target-arm/op_helper.c index dd9e4fc..770c776 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 = arm64_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,6 +411,10 @@ void HELPER(exception_return)(CPUARMState *env) env->regs[15] = env->elr_el[ELR_EL_IDX(1)] & ~0x1; } else { new_el = extract32(spsr, 2, 2); + if (new_el > cur_el) { + /* Disallow returns to higher ELs than the current one. */ + goto illegal_return; + } if (new_el > 1) { /* Return to unimplemented EL */ goto illegal_return;