Skip to contentSkip to conversation

isapc: Fix segfault during initialization

PATCH In review Jan Kiszka 3 participants 7 messages Jan 14, 2012 – Jan 15, 2012

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 isapc: Fix segfault during initialization

From: Jan Kiszka <[email protected]>

Linking the RTC device state to the PIIX does not belong into the common path that is shared with the isapc. QEMU crashes otherwise.

---
 hw/pc_piix.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)
hw/pc_piix.c +11 -11
index b70431f..3aea3cc 100644
@@ -201,6 +201,17 @@ static void pc_init1(MemoryRegion *system_memory,
         }
         idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
         idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
+
+        /* FIXME there's some major spaghetti here.  Somehow we create the
+         * devices on the PIIX before we actually create it.  We create the
+         * PIIX3 deep in the recess of the i440fx creation too and then lose
+         * the DeviceState.
+         *
+         * For now, let's "fix" this by making judicious use of paths.  This
+         * is not generally the right way to do this.
+         */
+        qdev_property_add_child(qdev_resolve_path("/i440fx/piix3", NULL),
+                                "rtc", (DeviceState *)rtc_state, NULL);
     } else {
         for(i = 0; i < MAX_IDE_BUS; i++) {
             ISADevice *dev;
@@ -211,17 +222,6 @@ static void pc_init1(MemoryRegion *system_memory,
         }
     }
 
-    /* FIXME there's some major spaghetti here.  Somehow we create the devices
-     * on the PIIX before we actually create it.  We create the PIIX3 deep in
-     * the recess of the i440fx creation too and then lose the DeviceState.
-     *
-     * For now, let's "fix" this by making judicious use of paths.  This is not
-     * generally the right way to do this.
-     */
-
-    qdev_property_add_child(qdev_resolve_path("/i440fx/piix3", NULL),
-                            "rtc", (DeviceState *)rtc_state, NULL);
-
     audio_init(isa_bus, pci_enabled ? pci_bus : NULL);
 
     pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
Signature · 1 line
1.7.3.4
#1 lore raw

Am 14.01.2012 14:12, schrieb Jan Kiszka:

Quoted 4 lines

From: Jan Kiszka <[email protected]>

Linking the RTC device state to the PIIX does not belong into the common path that is shared with the isapc. QEMU crashes otherwise.

Doesn't that indicate a missing NULL-check or something in qdev_property_add_child() that should be fixed, too?

Andreas

Quoted 46 lines
---
 hw/pc_piix.c |   22 +++++++++++-----------
 1 files changed, 11 insertions(+), 11 deletions(-)
hw/pc_piix.c +11 -11
index b70431f..3aea3cc 100644
@@ -201,6 +201,17 @@ static void pc_init1(MemoryRegion *system_memory,
         }
         idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
         idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
+
+        /* FIXME there's some major spaghetti here.  Somehow we create the
+         * devices on the PIIX before we actually create it.  We create the
+         * PIIX3 deep in the recess of the i440fx creation too and then lose
+         * the DeviceState.
+         *
+         * For now, let's "fix" this by making judicious use of paths.  This
+         * is not generally the right way to do this.
+         */
+        qdev_property_add_child(qdev_resolve_path("/i440fx/piix3", NULL),
+                                "rtc", (DeviceState *)rtc_state, NULL);
     } else {
         for(i = 0; i < MAX_IDE_BUS; i++) {
             ISADevice *dev;
@@ -211,17 +222,6 @@ static void pc_init1(MemoryRegion *system_memory,
         }
     }
 
-    /* FIXME there's some major spaghetti here.  Somehow we create the devices
-     * on the PIIX before we actually create it.  We create the PIIX3 deep in
-     * the recess of the i440fx creation too and then lose the DeviceState.
-     *
-     * For now, let's "fix" this by making judicious use of paths.  This is not
-     * generally the right way to do this.
-     */
-
-    qdev_property_add_child(qdev_resolve_path("/i440fx/piix3", NULL),
-                            "rtc", (DeviceState *)rtc_state, NULL);
-
     audio_init(isa_bus, pci_enabled ? pci_bus : NULL);
 
     pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#2 lore raw
In reply to Jan Kiszka
Quoted 6 lines · Jan Kiszka

From: Jan Kiszka<[email protected]>

Linking the RTC device state to the PIIX does not belong into the common path that is shared with the isapc. QEMU crashes otherwise.

Does isapc actually work for you? I tried to write a qemu-test test case (attached below) to help prevent future regressions. I can reproduce your SEGV but with your patch applied, I get no output (not even the BIOS runs).

Here's the command line. Even a simple 'qemu-system-x86_64 -M isapc' reproduces it:

/home/anthony/build/qemu/x86_64-softmmu/qemu-system-x86_64 -kernel bin/vmlinuz-3.0 -initrd .tmp-3510/initramfs-3510.img.gz -append console=ttyS0 seed=24689 -M isapc -pidfile .tmp-3510/pidfile-3510.pid -qmp unix:.tmp-3510/qmpsock-3510.sock,server,nowait

Regards,

Anthony Liguori

Quoted 44 lines
---
  hw/pc_piix.c |   22 +++++++++++-----------
  1 files changed, 11 insertions(+), 11 deletions(-)
hw/pc_piix.c +11 -11
index b70431f..3aea3cc 100644
@@ -201,6 +201,17 @@ static void pc_init1(MemoryRegion *system_memory,
          }
          idebus[0] = qdev_get_child_bus(&dev->qdev, "ide.0");
          idebus[1] = qdev_get_child_bus(&dev->qdev, "ide.1");
+
+        /* FIXME there's some major spaghetti here.  Somehow we create the
+         * devices on the PIIX before we actually create it.  We create the
+         * PIIX3 deep in the recess of the i440fx creation too and then lose
+         * the DeviceState.
+         *
+         * For now, let's "fix" this by making judicious use of paths.  This
+         * is not generally the right way to do this.
+         */
+        qdev_property_add_child(qdev_resolve_path("/i440fx/piix3", NULL),
+                                "rtc", (DeviceState *)rtc_state, NULL);
      } else {
          for(i = 0; i<  MAX_IDE_BUS; i++) {
              ISADevice *dev;
@@ -211,17 +222,6 @@ static void pc_init1(MemoryRegion *system_memory,
          }
      }
 
-    /* FIXME there's some major spaghetti here.  Somehow we create the devices
-     * on the PIIX before we actually create it.  We create the PIIX3 deep in
-     * the recess of the i440fx creation too and then lose the DeviceState.
-     *
-     * For now, let's "fix" this by making judicious use of paths.  This is not
-     * generally the right way to do this.
-     */
-
-    qdev_property_add_child(qdev_resolve_path("/i440fx/piix3", NULL),
-                            "rtc", (DeviceState *)rtc_state, NULL);
-
      audio_init(isa_bus, pci_enabled ? pci_bus : NULL);
 
      pc_cmos_init(below_4g_mem_size, above_4g_mem_size, boot_device,
author
#3 lore raw
Quoted 13 lines · Anthony Liguori
Quoted 6 lines · Jan Kiszka

From: Jan Kiszka<[email protected]>

Linking the RTC device state to the PIIX does not belong into the common path that is shared with the isapc. QEMU crashes otherwise.

Does isapc actually work for you? I tried to write a qemu-test test case (attached below) to help prevent future regressions. I can reproduce your SEGV but with your patch applied, I get no output (not even the BIOS runs).

Quoted 7 lines

Here's the command line. Even a simple 'qemu-system-x86_64 -M isapc' reproduces it:

/home/anthony/build/qemu/x86_64-softmmu/qemu-system-x86_64 -kernel bin/vmlinuz-3.0 -initrd .tmp-3510/initramfs-3510.img.gz -append console=ttyS0 seed=24689 -M isapc -pidfile .tmp-3510/pidfile-3510.pid -qmp unix:.tmp-3510/qmpsock-3510.sock,server,nowait

You need to update seabios to the last release at least (should have been done much earlier), and it only works for KVM (as that mode ignores some ROM write protections where seabios obviously has some troubles with).

Jan

#4 lore raw
Quoted 17 lines · Jan Kiszka
Quoted 16 lines · Anthony Liguori
Quoted 6 lines · Jan Kiszka

From: Jan Kiszka<[email protected]>

Linking the RTC device state to the PIIX does not belong into the common path that is shared with the isapc. QEMU crashes otherwise.

Does isapc actually work for you? I tried to write a qemu-test test case (attached below) to help prevent future regressions. I can reproduce your SEGV but with your patch applied, I get no output (not even the BIOS runs).

Here's the command line. Even a simple 'qemu-system-x86_64 -M isapc' reproduces it:

Quoted 8 lines
Quoted 4 lines

/home/anthony/build/qemu/x86_64-softmmu/qemu-system-x86_64 -kernel bin/vmlinuz-3.0 -initrd .tmp-3510/initramfs-3510.img.gz -append console=ttyS0 seed=24689 -M isapc -pidfile .tmp-3510/pidfile-3510.pid -qmp unix:.tmp-3510/qmpsock-3510.sock,server,nowait

You need to update seabios to the last release at least (should have been done much earlier), and it only works for KVM (as that mode ignores some ROM write protections where seabios obviously has some troubles with).

Can you send a pull request? SeaBIOS no longer builds on my laptop...

Regards,

Anthony Liguori

Quoted 3 lines

Jan

author
#5 lore raw
Quoted 23 lines · Anthony Liguori
Quoted 22 lines · Jan Kiszka
Quoted 20 lines · Anthony Liguori
Quoted 6 lines · Jan Kiszka

From: Jan Kiszka<[email protected]>

Linking the RTC device state to the PIIX does not belong into the common path that is shared with the isapc. QEMU crashes otherwise.

Does isapc actually work for you? I tried to write a qemu-test test case (attached below) to help prevent future regressions. I can reproduce your SEGV but with your patch applied, I get no output (not even the BIOS runs).

Here's the command line. Even a simple 'qemu-system-x86_64 -M isapc' reproduces it:

/home/anthony/build/qemu/x86_64-softmmu/qemu-system-x86_64 -kernel bin/vmlinuz-3.0 -initrd .tmp-3510/initramfs-3510.img.gz -append console=ttyS0 seed=24689 -M isapc -pidfile .tmp-3510/pidfile-3510.pid -qmp unix:.tmp-3510/qmpsock-3510.sock,server,nowait

Quoted 6 lines
Quoted 4 lines

You need to update seabios to the last release at least (should have been done much earlier), and it only works for KVM (as that mode ignores some ROM write protections where seabios obviously has some troubles with).

Can you send a pull request? SeaBIOS no longer builds on my laptop...

Will do. Last release of current master preferred?

Jan

#6 lore raw
Quoted 24 lines · Jan Kiszka
Quoted 23 lines · Anthony Liguori
Quoted 22 lines · Jan Kiszka
Quoted 20 lines · Anthony Liguori
Quoted 6 lines · Jan Kiszka

From: Jan Kiszka<[email protected]>

Linking the RTC device state to the PIIX does not belong into the common path that is shared with the isapc. QEMU crashes otherwise.

Does isapc actually work for you? I tried to write a qemu-test test case (attached below) to help prevent future regressions. I can reproduce your SEGV but with your patch applied, I get no output (not even the BIOS runs).

Here's the command line. Even a simple 'qemu-system-x86_64 -M isapc' reproduces it:

/home/anthony/build/qemu/x86_64-softmmu/qemu-system-x86_64 -kernel bin/vmlinuz-3.0 -initrd .tmp-3510/initramfs-3510.img.gz -append console=ttyS0 seed=24689 -M isapc -pidfile .tmp-3510/pidfile-3510.pid -qmp unix:.tmp-3510/qmpsock-3510.sock,server,nowait

Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

You need to update seabios to the last release at least (should have been done much earlier), and it only works for KVM (as that mode ignores some ROM write protections where seabios obviously has some troubles with).

Can you send a pull request? SeaBIOS no longer builds on my laptop...

Will do. Last release of current master preferred?

Yes.

Regards,

Anthony Liguori

Quoted 3 lines

Jan