From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51734) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJT39-0004fx-Im for qemu-devel@nongnu.org; Tue, 10 Sep 2013 14:52:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VJT37-0005J6-Rb for qemu-devel@nongnu.org; Tue, 10 Sep 2013 14:52:31 -0400 Received: from 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.d.1.0.0.b.8.0.1.0.0.2.ip6.arpa ([2001:8b0:1d0::1]:43712 helo=mnementh.archaic.org.uk) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VJT37-0005Dk-F5 for qemu-devel@nongnu.org; Tue, 10 Sep 2013 14:52:29 -0400 From: Peter Maydell Date: Tue, 10 Sep 2013 19:51:58 +0100 Message-Id: <1378839142-7726-5-git-send-email-peter.maydell@linaro.org> In-Reply-To: <1378839142-7726-1-git-send-email-peter.maydell@linaro.org> References: <1378839142-7726-1-git-send-email-peter.maydell@linaro.org> Subject: [Qemu-devel] [PULL 04/28] target-arm: fix ARMv7M stack alignment on reset List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: qemu-devel@nongnu.org From: Sebastian Ottlik When the initial SP is loaded from the vector table on ARMv7M systems the two least significant bits are ignored as the stack is always aligned at a four byte boundary (see ARM DDI 0403C, B1.4.1 and B1.5.5). So far QEMU did not ignore these bits leading to a stack alignment inconsitent with real hardware for binaries that rely on this behaviour. This patch fixes this issue by masking the two least significant bits when loading the SP. Signed-off-by: Sebastian Ottlik Reviewed-by: Peter Maydell Message-id: 1378286595-27072-1-git-send-email-ottlik@fzi.de Signed-off-by: Peter Maydell --- target-arm/cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/target-arm/cpu.c b/target-arm/cpu.c index 827e28e..09206b5 100644 --- a/target-arm/cpu.c +++ b/target-arm/cpu.c @@ -108,7 +108,7 @@ static void arm_cpu_reset(CPUState *s) modified flash and reset itself. However images loaded via -kernel have not been copied yet, so load the values directly from there. */ - env->regs[13] = ldl_p(rom); + env->regs[13] = ldl_p(rom) & 0xFFFFFFFC; pc = ldl_p(rom + 4); env->thumb = pc & 1; env->regs[15] = pc & ~1; -- 1.7.9.5