From 2297b8134bf79e45eabd9038fed230aacb3e1ec7 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Fri, 2 Mar 2018 13:45:02 -0500 Subject: [PATCH] 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 --- qemu/target/arm/helper.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/qemu/target/arm/helper.c b/qemu/target/arm/helper.c index bd4dcaf6..a1ef6a96 100644 --- a/qemu/target/arm/helper.c +++ b/qemu/target/arm/helper.c @@ -5483,10 +5483,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; }