From 1b400d38654787cd550e3da206a33b1fbc3a4d53 Mon Sep 17 00:00:00 2001
Message-Id: <1b400d38654787cd550e3da206a33b1fbc3a4d53.1346843178.git.minovotn@redhat.com>
In-Reply-To: <23a13cde0d81a8776ab4defcd30f9edef53b045f.1346843178.git.minovotn@redhat.com>
References: <23a13cde0d81a8776ab4defcd30f9edef53b045f.1346843178.git.minovotn@redhat.com>
From: Laszlo Ersek <lersek@redhat.com>
Date: Tue, 4 Sep 2012 15:32:49 +0200
Subject: [PATCH 5/5] reset PMBA and PMREGMISC PIIX4 registers

RH-Author: Laszlo Ersek <lersek@redhat.com>
Message-id: <1346772769-15961-1-git-send-email-lersek@redhat.com>
Patchwork-id: 41672
O-Subject: [RHEL-6.3 qemu-kvm PATCH] reset PMBA and PMREGMISC PIIX4 registers
Bugzilla: 854304
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Gleb Natapov <gleb@redhat.com>
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>

Bugzilla: 854304
Brew:     https://brewweb.devel.redhat.com/taskinfo?taskID=4830217
Upstream: 4d09d37c6aa9a02b44b1fdb6268820fab92499bd

The bug causes Windows + OVMF hang after reboot since OVMF checks
PMREGMISC to see if IO space is enabled and skip configuration if it is.

Dead code (TARGET_IA64) is left untouched.

Tested with Windows 8 Consumer Preview guest (Build 8250) plus "[edk2]
[PATCH v2 0/6] OvmfPkg: PMBA fixes" on top of edk2 svn rev 13698.

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 hw/acpi.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

Signed-off-by: Michal Novotny <minovotn@redhat.com>
---
 hw/acpi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/hw/acpi.c b/hw/acpi.c
index 8501f3e..cb2edde 100644
--- a/hw/acpi.c
+++ b/hw/acpi.c
@@ -628,6 +628,9 @@ static void piix4_reset(void *opaque)
     pci_conf[0x5a] = 0;
     pci_conf[0x5b] = 0;
 
+    pci_conf[0x40] = 0x01; /* PM io base read only bit */
+    pci_conf[0x80] = 0;
+
     if (kvm_enabled()) {
         /* Mark SMM as already inited (until KVM supports SMM). */
         pci_conf[0x5B] = 0x02;
@@ -679,8 +682,6 @@ static int piix4_pm_initfn(PCIDevice *dev)
     pci_conf[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; // header_type
     pci_conf[0x3d] = 0x01; // interrupt pin 1
 
-    pci_conf[0x40] = 0x01; /* PM io base read only bit */
-
 #if defined(TARGET_IA64)
     pci_conf[0x40] = 0x41; /* PM io base read only bit */
     pci_conf[0x41] = 0x1f;
-- 
1.7.11.4