armv7m: honour CCR.STACKALIGN on exception entry
authorMichael Davidsaver <mdavidsaver@gmail.com>
Fri, 27 Jan 2017 15:20:23 +0000 (15:20 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Fri, 27 Jan 2017 15:29:08 +0000 (15:29 +0000)
The CCR.STACKALIGN bit controls whether the CPU is supposed to force
8-alignment of the stack pointer on entry to the exception handler.

Signed-off-by: Michael Davidsaver <mdavidsaver@gmail.com>
Message-id: 1485285380-10565-6-git-send-email-peter.maydell@linaro.org
[PMM: commit message and comment tweaks]
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
target/arm/helper.c

index ce7e43bbaca8cde4e8dda8c64bc6c6e2b79702ac..7dc30f57696989829b13d66cb2ab3be087aa13ab 100644 (file)
@@ -6110,10 +6110,8 @@ void arm_v7m_cpu_do_interrupt(CPUState *cs)
         return; /* Never happens.  Keep compiler happy.  */
     }
 
-    /* Align stack pointer.  */
-    /* ??? Should only do this if Configuration Control Register
-       STACKALIGN bit is set.  */
-    if (env->regs[13] & 4) {
+    /* Align stack pointer if the guest wants that */
+    if ((env->regs[13] & 4) && (env->v7m.ccr & R_V7M_CCR_STKALIGN_MASK)) {
         env->regs[13] -= 4;
         xpsr |= 0x200;
     }