cpu_reset() is called as a side-effect of realizing the CPU. arm_cpu_reset() calls rom_ptr(0), which expects to find the image mapped. This was happening way before load_*() and was worked around with a second call to cpu_reset(). Now wait to realize until after the image is mapped. --- hw/arm/armv7m.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c index fb805fe..41b9596 100644 --- a/hw/arm/armv7m.c +++ b/hw/arm/armv7m.c @@ -159,13 +159,6 @@ static void armv7m_bitband_init(void) /* Board init. */ -static void armv7m_reset(void *opaque) -{ - ARMCPU *cpu = opaque; - - cpu_reset(CPU(cpu)); -} - void armv7m_init(const char *cpu_model) { ARMCPU *cpu; @@ -206,9 +199,6 @@ void armv7m_realize(int mem_size, const char *kernel_filename) uint64_t lowaddr; int big_endian; - qdev_init_nofail(DEVICE(cpu)); - qdev_init_nofail(nvic); - #ifdef TARGET_WORDS_BIGENDIAN big_endian = 1; #else @@ -233,7 +223,11 @@ void armv7m_realize(int mem_size, const char *kernel_filename) } } - qemu_register_reset(armv7m_reset, cpu); + /* Realizing cpu calls cpu_reset(), which must have rom image + * already mapped to find the correct entry point. + */ + qdev_init_nofail(DEVICE(cpu)); + qdev_init_nofail(nvic); } static Property bitband_properties[] = { -- 2.1.4