From patchwork Wed Dec 10 17:13:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 419772 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3536714009B for ; Thu, 11 Dec 2014 04:14:39 +1100 (AEDT) Received: from localhost ([::1]:46964 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XykqT-0007Hg-BC for incoming@patchwork.ozlabs.org; Wed, 10 Dec 2014 12:14:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44204) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xykq6-0006zA-H8 for qemu-devel@nongnu.org; Wed, 10 Dec 2014 12:14:20 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xykq0-0007df-BA for qemu-devel@nongnu.org; Wed, 10 Dec 2014 12:14:14 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60015) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xykq0-0007dZ-3u for qemu-devel@nongnu.org; Wed, 10 Dec 2014 12:14:08 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBAHE66r023634 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 10 Dec 2014 12:14:07 -0500 Received: from redhat.com (ovpn-116-75.ams2.redhat.com [10.36.116.75]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id sBAHE1Nc009712; Wed, 10 Dec 2014 12:14:03 -0500 Date: Wed, 10 Dec 2014 19:13:59 +0200 From: "Michael S. Tsirkin" To: Igor Mammedov Message-ID: <20141210171359.GA3301@redhat.com> References: <1418227616-18149-1-git-send-email-imammedo@redhat.com> <1418227616-18149-3-git-send-email-imammedo@redhat.com> <20141210162424.GA3035@redhat.com> <20141210174558.4097ae85@nial.usersys.redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20141210174558.4097ae85@nial.usersys.redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, qemu-devel@nongnu.org, marcel.a@redhat.com Subject: Re: [Qemu-devel] [PATCH 2/2] pc: acpi-build: make linker & RSDP tables dynamic 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 On Wed, Dec 10, 2014 at 05:45:58PM +0100, Igor Mammedov wrote: > On Wed, 10 Dec 2014 18:24:24 +0200 > "Michael S. Tsirkin" wrote: > > > On Wed, Dec 10, 2014 at 04:06:56PM +0000, Igor Mammedov wrote: > > > linker and RSDP tables are build only once, so if later > > > during rebuild sizes of other ACPI tables change > > > pointers will be patched incorrectly due to wrong > > > offsets. > > > > > > To fix it rebuild linker and RSDP tables along with > > > the rest of ACPI tables so that they would have correct > > > offsets. > > > > > > Here is a simple reproducer: > > > 1: hotplug bridge using command: > > > device_add pci-bridge,chassis_nr=1 > > > 2: reset system from monitor: > > > system_reset > > > > > > As result pointers to ACPI tables are not correct > > > and guest can't read/parse ACPI tables. > > > Windows guests just refuse to boot and > > > Linux guests are more resilient and try to boot without > > > ACPI, sometimes successfully. > > > > > > PS: > > > keep brokenness in 2.2 and older machine types for the sake > > > of migration > > > > > > Signed-off-by: Igor Mammedov > > > > I'd like to fix 2.2 as well. > that's easy, > has_imutable_rsdp = true > should be moved into > pc_compat_2_1() > > > > > Why does adding bridge in this way cause tables to > > be resized? > > I think this is a root-cause that should be fixed. > That's because there wasn't any bridge described in tables > on startup, but after hotplug and reset tables are rebuild > which pickups hotplugged bridge and its secondary PCI bus. > > This behavior seems sane, I'd expect bare-metal behave > the same way. For a simple fix, we can skip bridges added by hotplug - treat them as regular devices. It defintely seems nicer - at least for old machine types - than "keep brokenness". I think the following should do the trcik, but it's completely untested. Could you pls try? diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index b37a397..039776d 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -844,7 +844,8 @@ static void build_pci_bus_end(PCIBus *bus, void *bus_state) * Skip bridge subtree creation if bridge hotplug is disabled * to make acpi tables compatible with legacy machine types. */ - if (!child->pcihp_bridge_en && bus->parent_dev) { + if (bus->parent_dev && (!child->pcihp_bridge_en || + !DEVICE(bus->parent_dev)->hotplugged)) { return; }