From patchwork Wed Feb 20 21:46:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: David Woodhouse X-Patchwork-Id: 222153 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 8DE712C0040 for ; Thu, 21 Feb 2013 08:47:22 +1100 (EST) Received: from localhost ([::1]:50506 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8HVY-0007UI-Ot for incoming@patchwork.ozlabs.org; Wed, 20 Feb 2013 16:47:20 -0500 Received: from eggs.gnu.org ([208.118.235.92]:49790) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8HVG-0007LI-5A for qemu-devel@nongnu.org; Wed, 20 Feb 2013 16:47:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U8HV8-0008Gn-56 for qemu-devel@nongnu.org; Wed, 20 Feb 2013 16:47:01 -0500 Received: from bombadil.infradead.org ([2001:4830:2446:ff00:4687:fcff:fea6:5117]:37013) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U8HV7-0008Fv-Vz for qemu-devel@nongnu.org; Wed, 20 Feb 2013 16:46:54 -0500 Received: from shinybook.infradead.org ([2001:8b0:10b:1:e6ce:8fff:fe1f:f2c0]) by bombadil.infradead.org with esmtpsa (Exim 4.76 #1 (Red Hat Linux)) id 1U8HV5-000421-97 for qemu-devel@nongnu.org; Wed, 20 Feb 2013 21:46:51 +0000 Received: from dwmw2 by shinybook.infradead.org with local (Exim 4.80.1 #2 (Red Hat Linux)) id 1U8HV3-0003O2-Mq for qemu-devel@nongnu.org; Wed, 20 Feb 2013 21:46:49 +0000 From: David Woodhouse To: qemu-devel@nongnu.org Date: Wed, 20 Feb 2013 21:46:49 +0000 Message-Id: <1361396809-12973-4-git-send-email-dwmw2@infradead.org> X-Mailer: git-send-email 1.8.1.2 In-Reply-To: <1361396809-12973-1-git-send-email-dwmw2@infradead.org> References: <1361396809-12973-1-git-send-email-dwmw2@infradead.org> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org See http://www.infradead.org/rpr.html X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 2001:4830:2446:ff00:4687:fcff:fea6:5117 Subject: [Qemu-devel] [PATCH 4/4] piix_pci: Implement reset for i440FX PAM configuration X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: David Woodhouse This implements reset functionality for the i440FX, resetting all the PAM registers to their power-on defaults of no RAM access and thus forwarding all access to the 0xc0000-0xfffff range to PCI address space (i.e. to the actual ROM) instead of RAM. Fixing this is sufficient to work around a KVM bug which causes it to run 16-bit code at 0xffff0 instead of 0xfffffff0 on CPU reset. If reset was working correctly on the i440FX, that KVM bug wouldn't have *mattered* because the two addresses would have identical contents. There's been much discussion about the distinction between hard reset and soft reset, and the fact that many of our reset triggers (such as the keyboard controller and triple-fault handler) are actually doing a full system-wide hard reset when in fact they should be triggering something much more limited in scope. This patch exacerbates that existing problem only slightly, by causing the offending triggers to reset yet another piece of hardware that they shouldn't have been resetting. But the problem is largely theoretical anyway; mostly limited to 80286 protected mode software which needs to initiate a CPU reset to get back into real mode, but which *doesn't* want a full system reset. Such software is almost certainly already broken under Qemu anyway, because of all the *other* aspects of a full hard reset that are already happening. So this patch can be applied separately from any longer-term fixes to make the 'soft' reset actually do the right thing. Signed-off-by: David Woodhouse Tested-by: Laszlo Ersek Reviewed-by: Laszlo Ersek Reviewed-by: Andreas Färber --- hw/piix_pci.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/hw/piix_pci.c b/hw/piix_pci.c index 2eeb739..9e6eca0 100644 --- a/hw/piix_pci.c +++ b/hw/piix_pci.c @@ -175,6 +175,24 @@ static int i440fx_load_old(QEMUFile* f, void *opaque, int version_id) return 0; } +static void i440fx_reset(DeviceState *ds) +{ + PCIDevice *dev = PCI_DEVICE(ds); + PCII440FXState *d = I440FX_PCI_DEVICE(dev); + uint8_t *pci_conf = dev->config; + + pci_conf[0x59] = 0x00; /* Reset PAM setup */ + pci_conf[0x5a] = 0x00; + pci_conf[0x5b] = 0x00; + pci_conf[0x5c] = 0x00; + pci_conf[0x5d] = 0x00; + pci_conf[0x5e] = 0x00; + pci_conf[0x5f] = 0x00; + pci_conf[0x72] = 0x02; /* And SMM */ + + i440fx_update_memory_mappings(d); +} + static int i440fx_post_load(void *opaque, int version_id) { PCII440FXState *d = opaque; @@ -621,6 +639,7 @@ static void i440fx_class_init(ObjectClass *klass, void *data) dc->desc = "Host bridge"; dc->no_user = 1; dc->vmsd = &vmstate_i440fx; + dc->reset = i440fx_reset; } static const TypeInfo i440fx_info = {