]> xenbits.xensource.com Git - qemu-upstream-4.6-testing.git/commitdiff
target-arm: A64: Introduce aarch64_banked_spsr_index()
authorEdgar E. Iglesias <edgar.iglesias@xilinx.com>
Tue, 27 May 2014 16:09:52 +0000 (17:09 +0100)
committerPeter Maydell <peter.maydell@linaro.org>
Tue, 27 May 2014 16:09:52 +0000 (17:09 +0100)
Add aarch64_banked_spsr_index(), used to map an Exception Level
to an index in the banked_spsr array.

Reviewed-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Message-id: 1400980132-25949-13-git-send-email-edgar.iglesias@gmail.com
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
target-arm/helper-a64.c
target-arm/internals.h
target-arm/op_helper.c

index b8e6d56b3b93a9bb9c8c425f894bdaaa53063c37..b970fd1d691049906e35d04ce16472109fc6b169 100644 (file)
@@ -488,7 +488,7 @@ void aarch64_cpu_do_interrupt(CPUState *cs)
     }
 
     if (is_a64(env)) {
-        env->banked_spsr[0] = pstate_read(env);
+        env->banked_spsr[aarch64_banked_spsr_index(1)] = pstate_read(env);
         env->sp_el[arm_current_pl(env)] = env->xregs[31];
         env->xregs[31] = env->sp_el[1];
         env->elr_el[1] = env->pc;
index d63a975a7e1fac3b9712fb8a227765b0bc4e95aa..c9897c2cbadc2bef26649d2883712130a024107a 100644 (file)
@@ -75,6 +75,20 @@ static inline void arm_log_exception(int idx)
  */
 #define GTIMER_SCALE 16
 
+/*
+ * For AArch64, map a given EL to an index in the banked_spsr array.
+ */
+static inline unsigned int aarch64_banked_spsr_index(unsigned int el)
+{
+    static const unsigned int map[4] = {
+        [1] = 0, /* EL1.  */
+        [2] = 6, /* EL2.  */
+        [3] = 7, /* EL3.  */
+    };
+    assert(el >= 1 && el <= 3);
+    return map[el];
+}
+
 int bank_number(int mode);
 void switch_mode(CPUARMState *, int);
 void arm_cpu_register_gdb_regs_for_features(ARMCPU *cpu);
index f120b027b43c097a39878e6679dcaa90a111aa1d..c2b4bf0fd7d0877f98607a4e8825a15fb3e81f19 100644 (file)
@@ -386,7 +386,8 @@ void HELPER(msr_i_pstate)(CPUARMState *env, uint32_t op, uint32_t imm)
 
 void HELPER(exception_return)(CPUARMState *env)
 {
-    uint32_t spsr = env->banked_spsr[0];
+    unsigned int spsr_idx = aarch64_banked_spsr_index(1);
+    uint32_t spsr = env->banked_spsr[spsr_idx];
     int new_el, i;
 
     if (env->pstate & PSTATE_SP) {