Skip to contentSkip to conversation

x86: Fix powerdown for non-ACPI case

PATCH Applied Jan Kiszka 2 participants 2 messages Sep 1, 2008 – Sep 2, 2008

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

PATCH 1/1 x86: Fix powerdown for non-ACPI case

Trivial fix for a corner case: system_shutdown on isapc machines causes qemu to segfaults due to accessing the uninitialized pm_state. Issue a system shutdown instead.

---
 hw/acpi.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
hw/acpi.c +4 -2
Index: b/hw/acpi.c
===================================================================
@@ -72,7 +72,7 @@ typedef struct PIIX4PMState {
 #define SMBHSTDAT1 0x06
 #define SMBBLKDAT 0x07
 
-PIIX4PMState *pm_state;
+static PIIX4PMState *pm_state;
 
 static uint32_t get_pmtmr(PIIX4PMState *s)
 {
@@ -526,7 +526,9 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int
 #if defined(TARGET_I386)
 void qemu_system_powerdown(void)
 {
-    if(pm_state->pmen & PWRBTN_EN) {
+    if (!pm_state) {
+        qemu_system_shutdown_request();
+    } else if (pm_state->pmen & PWRBTN_EN) {
         pm_state->pmsts |= PWRBTN_EN;
 	pm_update_sci(pm_state);
     }
#1 lore raw
Quoted 3 lines · Jan Kiszka

Trivial fix for a corner case: system_shutdown on isapc machines causes qemu to segfaults due to accessing the uninitialized pm_state. Issue a system shutdown instead.

Applied, thanks.

Quoted 32 lines
---
 hw/acpi.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Index: b/hw/acpi.c
===================================================================

hw/acpi.c +4 -2
@@ -72,7 +72,7 @@ typedef struct PIIX4PMState {
 #define SMBHSTDAT1 0x06
 #define SMBBLKDAT 0x07
 
-PIIX4PMState *pm_state;
+static PIIX4PMState *pm_state;
 
 static uint32_t get_pmtmr(PIIX4PMState *s)
 {
@@ -526,7 +526,9 @@ i2c_bus *piix4_pm_init(PCIBus *bus, int
 #if defined(TARGET_I386)
 void qemu_system_powerdown(void)
 {
-    if(pm_state->pmen & PWRBTN_EN) {
+    if (!pm_state) {
+        qemu_system_shutdown_request();
+    } else if (pm_state->pmen & PWRBTN_EN) {
         pm_state->pmsts |= PWRBTN_EN;
 	pm_update_sci(pm_state);
     }
Signature · 4 lines
  .''`.  Aurelien Jarno	            | GPG: 1024D/F1BCDB73
 : :' :  Debian developer           | Electrical Engineer
 `. `'   [email protected]         | [email protected]
   `-    people.debian.org/~aurel32 | www.aurel32.net