armv7m: honour CCR.STACKALIGN on exception entry

The CCR.STACKALIGN bit controls whether the CPU is supposed to force
8-alignment of the stack pointer on entry to the exception handler.

Backports commit dc858c6633a9af8b80c1509cf6f825e4390d3ad1 from qemu
This commit is contained in:
Michael Davidsaver 2018-03-02 13:45:02 -05:00 committed by Lioncash
parent 7870bcfcb0
commit 2297b8134b
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

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