From bb5819cbbc558aa4d36e5d8fa8b3877afbdf5312 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Fri, 2 Mar 2018 13:56:32 -0500 Subject: [PATCH] armv7m: R14 should reset to 0xffffffff For M profile (unlike A profile) the reset value of R14 is specified as 0xffffffff. (The rationale is that this is an illegal exception return value, so if guest code tries to return to it it will result in a helpful exception.) Registers r0 to r12 and the flags are architecturally UNKNOWN on reset, so we leave those at zero. Backports commit 056f43df9168413f304500b69c33158d66efb7cf from qemu --- qemu/target/arm/cpu.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qemu/target/arm/cpu.c b/qemu/target/arm/cpu.c index a18c34b9..a74503bf 100644 --- a/qemu/target/arm/cpu.c +++ b/qemu/target/arm/cpu.c @@ -192,6 +192,9 @@ static void arm_cpu_reset(CPUState *s) * it dependent on CPU model. */ env->v7m.ccr = R_V7M_CCR_STKALIGN_MASK; + + /* Unlike A/R profile, M profile defines the reset LR value */ + env->regs[14] = 0xffffffff; #if 0 /* Load the initial SP and PC from the vector table at address 0 */ uint8_t *rom;