qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH v3] hw/arm/boot: register cpu reset handlers if using -bios
@ 2014-10-10 15:19 Ard Biesheuvel
  2014-10-10 16:08 ` Peter Maydell
  0 siblings, 1 reply; 2+ messages in thread
From: Ard Biesheuvel @ 2014-10-10 15:19 UTC (permalink / raw)
  To: peter.maydell; +Cc: Ard Biesheuvel, qemu-devel, greg.bellows

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 <ard.biesheuvel@linaro.org>
---

Changes since v2:
- split into two loops again, as the boot_info field must not be assigned in
  the -bios case
- add clarifying comment
- don't use the 'cpu' function parameter as an iterator inside the loop

Changes since v1:
- instead of duplicating part of the loop for the -bios case, move the loop to
  the beginning of the function

 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 c8dc34f0865b..bffbea5e0e73 100644
--- a/hw/arm/boot.c
+++ b/hw/arm/boot.c
@@ -478,7 +478,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;
@@ -488,6 +488,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) {
 
@@ -652,9 +661,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.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH v3] hw/arm/boot: register cpu reset handlers if using -bios
  2014-10-10 15:19 [Qemu-devel] [PATCH v3] hw/arm/boot: register cpu reset handlers if using -bios Ard Biesheuvel
@ 2014-10-10 16:08 ` Peter Maydell
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Maydell @ 2014-10-10 16:08 UTC (permalink / raw)
  To: Ard Biesheuvel; +Cc: QEMU Developers, Greg Bellows

On 10 October 2014 16:19, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
> 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 <ard.biesheuvel@linaro.org>
> ---



Applied to target-arm.next, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-10-10 16:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-10 15:19 [Qemu-devel] [PATCH v3] hw/arm/boot: register cpu reset handlers if using -bios Ard Biesheuvel
2014-10-10 16:08 ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).