From patchwork Tue May 6 06:08:22 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: 346037 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 049081412E6 for ; Tue, 6 May 2014 16:21:35 +1000 (EST) Received: from localhost ([::1]:33163 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhYku-0001WA-JX for incoming@patchwork.ozlabs.org; Tue, 06 May 2014 02:21:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhYkP-0000l6-4h for qemu-devel@nongnu.org; Tue, 06 May 2014 02:21:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WhYkI-0004qE-UM for qemu-devel@nongnu.org; Tue, 06 May 2014 02:21:01 -0400 Received: from mail-qg0-x22d.google.com ([2607:f8b0:400d:c04::22d]:56452) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WhYkI-0004q7-Q9 for qemu-devel@nongnu.org; Tue, 06 May 2014 02:20:54 -0400 Received: by mail-qg0-f45.google.com with SMTP id z60so3014633qgd.18 for ; Mon, 05 May 2014 23:20:54 -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=AOvvo6S1gaFKfw6kCoi8TUGWhdSaGuAoc6HAFv3uB6Q=; b=gHHtFUHpHLPXjvS8Ws5oksshbWG+1Bc7+qKAoku0HEoIypa+cNZ+yuxqEn/YYpu3ZL f4jugvhDdG6gfiYnxKKOMu5B4De9y7gcbC0fbxRRnAMFvYfNFwGP7jGMRp/MSkRs4su4 aSZZpp3oMCrz5F+hquKkzgYS4cMggsFZrn8YoAV3r3C823AnaqTx1H01NI6FdIh3pquN ZohD0p1en2Ez13fQZ/+kqj4wEjVpdm+ncbvU2rBH+CK9riMYOlB6uRll916XqxzjMuRv 9n24Cuvod8Ocy8/A5st8AWW1qT/3M/PfgHps4/atU+mg1/gVq9UX7cjv1BAJz83/RlYT VnQA== X-Received: by 10.224.44.17 with SMTP id y17mr52871631qae.36.1399357254361; Mon, 05 May 2014 23:20:54 -0700 (PDT) Received: from localhost ([203.126.243.116]) by mx.google.com with ESMTPSA id w2sm21712312qar.21.2014.05.05.23.20.49 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Mon, 05 May 2014 23:20:53 -0700 (PDT) From: "Edgar E. Iglesias" To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Tue, 6 May 2014 16:08:22 +1000 Message-Id: <1399356506-5609-19-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:c04::22d 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 18/22] 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" Signed-off-by: Edgar E. Iglesias Reviewed-by: Peter Crosthwaite --- target-arm/internals.h | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/target-arm/internals.h b/target-arm/internals.h index 7c39946..5d802db 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,15 @@ 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. - */ - assert(arm_current_pl(env) == 1); + /* EL0 has no access rights to update SPSel. */ + 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]; } }