From patchwork Sun May 25 01:08:49 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: 352210 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 92839140083 for ; Sun, 25 May 2014 11:23:56 +1000 (EST) Received: from localhost ([::1]:49960 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoNAI-00073b-GP for incoming@patchwork.ozlabs.org; Sat, 24 May 2014 21:23:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58471) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoN9f-0005yo-4y for qemu-devel@nongnu.org; Sat, 24 May 2014 21:23:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WoN9Z-0007kS-6D for qemu-devel@nongnu.org; Sat, 24 May 2014 21:23:15 -0400 Received: from mail-pb0-x22b.google.com ([2607:f8b0:400e:c01::22b]:59589) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WoN9Y-0007kO-VN for qemu-devel@nongnu.org; Sat, 24 May 2014 21:23:09 -0400 Received: by mail-pb0-f43.google.com with SMTP id up15so5918646pbc.2 for ; Sat, 24 May 2014 18:23:08 -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=dO+9T73gxu+NrzPk/wee9HZMfxKP9yFWA9sLya7zj4s=; b=VHlUeG/mkUBlVNErv+7xnKhljOkHxCCh2FYbFNGblJwC0TUb1qyBubWSXKb95SE1Tf MccDBPY+mIWIC9QN85oF+tvrtklnxWt3XiGHp5cnSE1/vF3raWHQecgCCuohQUGqX7Id +J47zXlqU0vQ7N/wu+CYeQjTXiGFfi69IrF2ic8t4MjLzh9lafw5lnlYliotQEwRzNSQ dytNu+BdP2KRrRayIuYUMCp+bwnm7oyjssTg6XnRtBQD3aGQdrzglR2qNEmLInsywdSh 6CLS+SE/ABHGrOdZN2LpQ/aCxD7jGXU613eekuAjiMZLUDUEedDDEAv9mql5cF2H7awA 4Jsw== X-Received: by 10.67.22.33 with SMTP id hp1mr16843468pad.134.1400980988141; Sat, 24 May 2014 18:23:08 -0700 (PDT) Received: from localhost ([203.126.243.116]) by mx.google.com with ESMTPSA id jd5sm11300827pbb.18.2014.05.24.18.23.01 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 24 May 2014 18:23:06 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Sun, 25 May 2014 11:08:49 +1000 Message-Id: <1400980132-25949-21-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: 2607:f8b0:400e:c01::22b 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 20/23] target-arm: A64: Generalize update_spsel for the various 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/internals.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/target-arm/internals.h b/target-arm/internals.h index c9897c2..564b5fa 100644 --- a/target-arm/internals.h +++ b/target-arm/internals.h @@ -107,6 +107,7 @@ int arm_rmode_to_sf(int rmode); static inline void update_spsel(CPUARMState *env, uint32_t imm) { + unsigned int cur_el = arm_current_pl(env); /* Update PSTATE SPSel bit; this requires us to update the * working stack pointer in xregs[31]. */ @@ -115,17 +116,17 @@ static inline void update_spsel(CPUARMState *env, uint32_t imm) } env->pstate = deposit32(env->pstate, 0, 1, imm); - /* EL0 has no access rights to update SPSel, and this code - * assumes we are updating SP for EL1 while running as EL1. + /* We rely on illegal updates to SPsel from EL0 to get trapped + * at translation time. */ - assert(arm_current_pl(env) == 1); + assert(cur_el >= 1 && cur_el <= 3); if (env->pstate & PSTATE_SP) { /* Switch from using SP_EL0 to using SP_ELx */ env->sp_el[0] = env->xregs[31]; - env->xregs[31] = env->sp_el[1]; + env->xregs[31] = env->sp_el[cur_el]; } else { /* Switch from SP_EL0 to SP_ELx */ - env->sp_el[1] = env->xregs[31]; + env->sp_el[cur_el] = env->xregs[31]; env->xregs[31] = env->sp_el[0]; } }