From: Greg Bellows <greg.bellows@linaro.org>
To: qemu-devel@nongnu.org, peter.maydell@linaro.org
Cc: Greg Bellows <greg.bellows@linaro.org>
Subject: [Qemu-devel] [PATCH 3/4] target-arm: Change reset to highest available EL
Date: Fri, 23 Jan 2015 08:49:22 -0600 [thread overview]
Message-ID: <1422024563-27096-4-git-send-email-greg.bellows@linaro.org> (raw)
In-Reply-To: <1422024563-27096-1-git-send-email-greg.bellows@linaro.org>
Update to arm_cpu_reset() to reset into the highest available exception level
based on the set ARM features.
Signed-off-by: Greg Bellows <greg.bellows@linaro.org>
---
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 {
--
1.8.3.2
next prev parent reply other threads:[~2015-01-23 14:49 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-23 14:49 [Qemu-devel] [PATCH 0/4] target-arm: Initial ARMv8 extended EL support Greg Bellows
2015-01-23 14:49 ` [Qemu-devel] [PATCH 1/4] target-arm: Fix RVBAR_EL1 register encoding Greg Bellows
2015-01-23 14:55 ` Peter Maydell
2015-01-23 14:59 ` Greg Bellows
2015-01-23 15:12 ` Peter Maydell
2015-01-23 14:49 ` [Qemu-devel] [PATCH 2/4] target-arm: Add extended RVBAR support Greg Bellows
2015-01-23 15:01 ` Peter Maydell
2015-01-23 14:49 ` Greg Bellows [this message]
2015-01-23 15:05 ` [Qemu-devel] [PATCH 3/4] target-arm: Change reset to highest available EL Peter Maydell
2015-01-23 15:25 ` Greg Bellows
2015-01-23 14:49 ` [Qemu-devel] [PATCH 4/4] target-arm: Add missing SP_ELx register definition Greg Bellows
2015-01-23 15:12 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1422024563-27096-4-git-send-email-greg.bellows@linaro.org \
--to=greg.bellows@linaro.org \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).