From patchwork Sat Feb 15 16:07:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 24701 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f197.google.com (mail-vc0-f197.google.com [209.85.220.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 48507203BE for ; Sat, 15 Feb 2014 16:08:18 +0000 (UTC) Received: by mail-vc0-f197.google.com with SMTP id hq11sf27576496vcb.4 for ; Sat, 15 Feb 2014 08:08:17 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=nry2BwOXq29dtt15mejHZ+IDU9M2ayDm+hoFzQjhRdk=; b=V055dAsxYnaUqqnxEBf91lPwvgetT2i5q652L1lgRtz9gTibJzlxxaXRCal/fJjAXo FNbdK5sltYWD+kkdVfrGEsaATuzEYn4wRGcIhb4KF+Zg4pnpIJT+H6JeS7kZvnsFkwP/ Ano/flP2FeRTyUuKwiaCqDfWpX6aNztF6e8c06epVXo5b4ompEBC/koc0FTtN0JQ+a5f 3wWZjiUcPW9R8IAqpj58foz3idnn/xp4n8jfvSyUHIj3EkHBdbFcEDeC0naTckYv+GSI yMQs+pq2/2AUUG5L22VShjl67o3fAONRjEp8JWSMJ+1rnyi9upRxsuOFVybvmvxR/wlY CoMQ== X-Gm-Message-State: ALoCoQkbZsf4CJJCW8Xgyphab+MhGwZt8G9rX/jnX7p6NMdZ69oxJzkJxxyDzVw012k6MWZ4SBuQ X-Received: by 10.236.179.172 with SMTP id h32mr4941809yhm.16.1392480497403; Sat, 15 Feb 2014 08:08:17 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.40.11 with SMTP id w11ls396187qgw.42.gmail; Sat, 15 Feb 2014 08:08:17 -0800 (PST) X-Received: by 10.52.190.1 with SMTP id gm1mr2693857vdc.21.1392480497313; Sat, 15 Feb 2014 08:08:17 -0800 (PST) Received: from mail-ve0-f180.google.com (mail-ve0-f180.google.com [209.85.128.180]) by mx.google.com with ESMTPS id si7si3010028vdc.11.2014.02.15.08.08.17 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sat, 15 Feb 2014 08:08:17 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.180; Received: by mail-ve0-f180.google.com with SMTP id db12so10343774veb.25 for ; Sat, 15 Feb 2014 08:08:17 -0800 (PST) X-Received: by 10.52.168.39 with SMTP id zt7mr4726769vdb.42.1392480497204; Sat, 15 Feb 2014 08:08:17 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp25602vcz; Sat, 15 Feb 2014 08:08:16 -0800 (PST) X-Received: by 10.180.25.46 with SMTP id z14mr6500748wif.49.1392480475189; Sat, 15 Feb 2014 08:07:55 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id ei5si3859525wib.82.2014.02.15.08.07.53 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 15 Feb 2014 08:07:55 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::1 as permitted sender) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1WEhm1-0006gM-Ud; Sat, 15 Feb 2014 16:07:25 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Alexander Graf , Michael Matz , Claudio Fontana , Dirk Mueller , Laurent Desnogues , kvmarm@lists.cs.columbia.edu, Richard Henderson , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Christoffer Dall , Will Newton , Peter Crosthwaite , Rob Herring Subject: [PATCH v3 24/31] target-arm: Add utility function for checking AA32/64 state of an EL Date: Sat, 15 Feb 2014 16:07:17 +0000 Message-Id: <1392480444-25565-25-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1392480444-25565-1-git-send-email-peter.maydell@linaro.org> References: <1392480444-25565-1-git-send-email-peter.maydell@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , There are various situations where we need to behave differently depending on whether a given exception level is in AArch64 or AArch32 state. The state of the current exception level is stored in env->aarch64, but there's no equivalent guest-visible architected state bits for the status of the exception levels "above" the current one which may still affect execution. At the moment we only support EL1 (ie no EL2 or EL3) and insist that AArch64 capable CPUs run with EL1 in AArch64 state, but these may change in the future, so abstract out the "what state is this?" check into a utility function which can be enhanced later if necessary. Signed-off-by: Peter Maydell --- target-arm/cpu.h | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/target-arm/cpu.h b/target-arm/cpu.h index 1f6f65d..f530333 100644 --- a/target-arm/cpu.h +++ b/target-arm/cpu.h @@ -633,6 +633,22 @@ static inline int arm_feature(CPUARMState *env, int feature) return (env->features & (1ULL << feature)) != 0; } +/* Return true if the specified exception level is running in AArch64 state. */ +static inline bool arm_el_is_aa64(CPUARMState *env, int el) +{ + /* We don't currently support EL2 or EL3, and this isn't valid for EL0 + * (if we're in EL0, is_a64() is what you want, and if we're not in EL0 + * then the state of EL0 isn't well defined.) + */ + assert(el == 1); + /* AArch64-capable CPUs always run with EL1 in AArch64 mode. This + * is a QEMU-imposed simplification which we may wish to change later. + * If we in future support EL2 and/or EL3, then the state of lower + * exception levels is controlled by the HCR.RW and SCR.RW bits. + */ + return arm_feature(env, ARM_FEATURE_AARCH64); +} + void arm_cpu_list(FILE *f, fprintf_function cpu_fprintf); /* Interface between CPU and Interrupt controller. */