qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [RFC PATCH] PIIX: reset the VM when the Reset Control Register's RCPU bit gets set
@ 2013-01-08 21:44 Laszlo Ersek
  2013-01-09 21:01 ` Blue Swirl
  0 siblings, 1 reply; 8+ messages in thread
From: Laszlo Ersek @ 2013-01-08 21:44 UTC (permalink / raw)
  To: qemu-devel, akong, lersek

>From <http://mjg59.dreamwidth.org/3561.html>:

  Traditional PCI config space access is achieved by writing a 32 bit
  value to io port 0xcf8 to identify the bus, device, function and config
  register. Port 0xcfc then contains the register in question. But if you
  write the appropriate pair of magic values to 0xcf9, the machine will
  reboot. Spectacular! And not standardised in any way (certainly not part
  of the PCI spec), so different chipsets may have different requirements.
  Booo.

In the PIIX4 spec, IO port 0xcf9 is specified as the Reset Control
Register. Therefore let's handle single byte writes to offset 1 in the
[0xcf8, 0xcfb] range separately, and interpret the RCPU bit in the value.
(Based on "docs/memory.txt", overlapping regions seem to serve a different
purpose.)

The SRST bit alone could be stateful. However we don't distinguish between
soft & hard reset, hence the SRST bit is neither checked nor saved.

RHBZ reference: 890459

Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 hw/piix_pci.c |   22 +++++++++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)

diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 3d79c73..89d694c 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -31,6 +31,7 @@
 #include "qemu/range.h"
 #include "xen.h"
 #include "pam.h"
+#include "sysemu/sysemu.h"
 
 /*
  * I440FX chipset data sheet.
@@ -180,11 +181,30 @@ static const VMStateDescription vmstate_i440fx = {
     }
 };
 
+static void i440fx_host_config_write(void *opaque, hwaddr addr,
+                                     uint64_t val, unsigned len)
+{
+    if (addr == 1 && len == 1) {
+        if (val & 4) {
+            qemu_system_reset_request();
+        }
+        return;
+    }
+    pci_host_conf_le_ops.write(opaque, addr, val, len);
+}
+
+static MemoryRegionOps i440fx_host_conf_ops = {
+    .read       = NULL,
+    .write      = i440fx_host_config_write,
+    .endianness = DEVICE_LITTLE_ENDIAN
+};
+
 static int i440fx_pcihost_initfn(SysBusDevice *dev)
 {
     PCIHostState *s = PCI_HOST_BRIDGE(dev);
 
-    memory_region_init_io(&s->conf_mem, &pci_host_conf_le_ops, s,
+    i440fx_host_conf_ops.read = pci_host_conf_le_ops.read;
+    memory_region_init_io(&s->conf_mem, &i440fx_host_conf_ops, s,
                           "pci-conf-idx", 4);
     sysbus_add_io(dev, 0xcf8, &s->conf_mem);
     sysbus_init_ioports(&s->busdev, 0xcf8, 4);
-- 
1.7.1

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

end of thread, other threads:[~2013-01-14 17:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-08 21:44 [Qemu-devel] [RFC PATCH] PIIX: reset the VM when the Reset Control Register's RCPU bit gets set Laszlo Ersek
2013-01-09 21:01 ` Blue Swirl
2013-01-11  9:30   ` Laszlo Ersek
2013-01-11 12:10     ` Andreas Färber
2013-01-11 12:20   ` Laszlo Ersek
2013-01-12 12:13     ` Blue Swirl
2013-01-14 17:05       ` Laszlo Ersek
2013-01-14 17:54         ` Laszlo Ersek

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).