From 99e589c293b702179a5e9e331995e7686170adc9 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Fri, 7 Nov 2014 12:59:12 -0500 Subject: [PATCH 09/10] hw/arm/boot: register cpu reset handlers if using -bios Message-id: <1415383153-28089-10-git-send-email-wei@redhat.com> Patchwork-id: 62223 O-Subject: [RHELSA qemu-kvm-rhev PATCH 09/10] hw/arm/boot: register cpu reset handlers if using -bios Bugzilla: 1160325 RH-Acked-by: Andrew Jones Move the registering of CPU reset handlers to before the point where we leave the function in the -bios (not -kernel) case, so CPU reset works correctly with -bios as well. Signed-off-by: Ard Biesheuvel Signed-off-by: Peter Maydell Signed-off-by: Wei Huang --- hw/arm/boot.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 8d0d297..fd760db 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -474,7 +474,7 @@ static void do_cpu_reset(void *opaque) void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) { - CPUState *cs = CPU(cpu); + CPUState *cs; int kernel_size; int initrd_size; int is_linux = 0; @@ -484,6 +484,15 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) int big_endian; static const ARMInsnFixup *primary_loader; + /* CPU objects (unlike devices) are not automatically reset on system + * reset, so we must always register a handler to do so. If we're + * actually loading a kernel, the handler is also responsible for + * arranging that we start it correctly. + */ + for (cs = CPU(cpu); cs; cs = CPU_NEXT(cs)) { + qemu_register_reset(do_cpu_reset, ARM_CPU(cs)); + } + /* Load the kernel. */ if (!info->kernel_filename) { @@ -641,9 +650,7 @@ void arm_load_kernel(ARMCPU *cpu, struct arm_boot_info *info) } info->is_linux = is_linux; - for (; cs; cs = CPU_NEXT(cs)) { - cpu = ARM_CPU(cs); - cpu->env.boot_info = info; - qemu_register_reset(do_cpu_reset, cpu); + for (cs = CPU(cpu); cs; cs = CPU_NEXT(cs)) { + ARM_CPU(cs)->env.boot_info = info; } } -- 1.8.3.1