From patchwork Fri Jan 23 14:49:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Bellows X-Patchwork-Id: 43648 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f71.google.com (mail-ee0-f71.google.com [74.125.83.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5B86E218DB for ; Fri, 23 Jan 2015 14:50:46 +0000 (UTC) Received: by mail-ee0-f71.google.com with SMTP id d49sf5067260eek.2 for ; Fri, 23 Jan 2015 06:50:45 -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:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=eKdIGdlcLQF3GKFdoKp/L4tv64KOxdkwvmKaMrs3dCM=; b=LyfcNc2RaorvRl/BHSoGsDsknYMbCBJMwhttvyV6TOLaaorxtZs/CVCdnpvqOMOd4p uo8Yajuyd7fRserxOPHpz5Qdplz5kxtXZ3glfUAWFuwbxA2UQQZ4G1S/T7m1OicUdlcJ Jxvngsa0X6ZJYpjI5c6/XtTueFffwKd2+paCeqda3oJqVokzy08RIOLJMO2XN3a8qakH ywQC/kOIKT+fxGeuo2hRA6WyXEAk5k989NFC+9/tVkTagMZrWLQ1FIrLj5VLV4UkpxJz yNMn2GT0UQE6gvm199HUelLetx6B1rdMZ4JFm8F4D8Fvdo+Okwr4xi7v9VFBWxWp+KMj G/hA== X-Gm-Message-State: ALoCoQnG2kmTHqm3xDPxRdn/ddr+7itU6SDb4BCHkVzDHcE75zdA86rW80Vn9IkpoBPXyWACVixR X-Received: by 10.152.5.98 with SMTP id r2mr269208lar.6.1422024645422; Fri, 23 Jan 2015 06:50:45 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.22.40 with SMTP id a8ls267339laf.66.gmail; Fri, 23 Jan 2015 06:50:45 -0800 (PST) X-Received: by 10.152.29.193 with SMTP id m1mr7724931lah.84.1422024645250; Fri, 23 Jan 2015 06:50:45 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id ay3si1589311lbc.17.2015.01.23.06.50.45 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Jan 2015 06:50:45 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id p9so7404338lbv.8 for ; Fri, 23 Jan 2015 06:50:45 -0800 (PST) X-Received: by 10.112.125.41 with SMTP id mn9mr7718287lbb.80.1422024645115; Fri, 23 Jan 2015 06:50:45 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.9.200 with SMTP id c8csp278910lbb; Fri, 23 Jan 2015 06:50:44 -0800 (PST) X-Received: by 10.140.92.138 with SMTP id b10mr13848614qge.59.1422024643928; Fri, 23 Jan 2015 06:50:43 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [208.118.235.17]) by mx.google.com with ESMTPS id e10si2179657qag.68.2015.01.23.06.50.43 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 23 Jan 2015 06:50:43 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; Received: from localhost ([::1]:59528 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEfZL-0001T5-5b for patch@linaro.org; Fri, 23 Jan 2015 09:50:43 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEfYM-0000H5-GH for qemu-devel@nongnu.org; Fri, 23 Jan 2015 09:49:46 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEfYJ-0005Hl-B9 for qemu-devel@nongnu.org; Fri, 23 Jan 2015 09:49:42 -0500 Received: from mail-pa0-f42.google.com ([209.85.220.42]:50641) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEfYJ-0005HE-1P for qemu-devel@nongnu.org; Fri, 23 Jan 2015 09:49:39 -0500 Received: by mail-pa0-f42.google.com with SMTP id bj1so8029495pad.1 for ; Fri, 23 Jan 2015 06:49:38 -0800 (PST) X-Received: by 10.68.227.6 with SMTP id rw6mr11903228pbc.2.1422024578522; Fri, 23 Jan 2015 06:49:38 -0800 (PST) Received: from gbellows-linaro.qualcomm.com (rrcs-67-52-129-61.west.biz.rr.com. [67.52.129.61]) by mx.google.com with ESMTPSA id oc7sm2146455pdb.68.2015.01.23.06.49.37 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 23 Jan 2015 06:49:37 -0800 (PST) From: Greg Bellows To: qemu-devel@nongnu.org, peter.maydell@linaro.org Date: Fri, 23 Jan 2015 08:49:22 -0600 Message-Id: <1422024563-27096-4-git-send-email-greg.bellows@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1422024563-27096-1-git-send-email-greg.bellows@linaro.org> References: <1422024563-27096-1-git-send-email-greg.bellows@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.85.220.42 Cc: Greg Bellows Subject: [Qemu-devel] [PATCH 3/4] target-arm: Change reset to highest available 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: greg.bellows@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Update to arm_cpu_reset() to reset into the highest available exception level based on the set ARM features. Signed-off-by: Greg Bellows --- hw/arm/boot.c | 10 ++++++++++ target-arm/cpu.c | 10 +++++++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 52ebd8b..148011b 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -464,6 +464,16 @@ static void do_cpu_reset(void *opaque) * requested. */ if (arm_feature(env, ARM_FEATURE_EL3) && !info->secure_boot) { + /* AArch64 is defined to come out of reset into EL3 if enabled. + * If we are booting Linux then we need to adjust our EL as + * Linux expects us to be EL1. AArch32 resets into SVC, which + * Linux expects, so no privilege/exception level to adjust. + */ + if (env->aarch64) { + env->pstate = PSTATE_MODE_EL1h; + } + + /* Linux expects non-secure state */ env->cp15.scr_el3 |= SCR_NS; } diff --git a/target-arm/cpu.c b/target-arm/cpu.c index 285947f..6793596 100644 --- a/target-arm/cpu.c +++ b/target-arm/cpu.c @@ -113,7 +113,15 @@ static void arm_cpu_reset(CPUState *s) /* and to the FP/Neon instructions */ env->cp15.c1_coproc = deposit64(env->cp15.c1_coproc, 20, 2, 3); #else - env->pstate = PSTATE_MODE_EL1h; + /* Reset into the highest available EL */ + if (arm_feature(env, ARM_FEATURE_EL3)) { + env->pstate = PSTATE_MODE_EL3h; + env->cp15.scr_el3 &= ~SCR_NS; + } else if (arm_feature(env, ARM_FEATURE_EL3)) { + env->pstate = PSTATE_MODE_EL2h; + } else { + env->pstate = PSTATE_MODE_EL1h; + } env->pc = cpu->rvbar; #endif } else {