From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52934) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUrMf-0002hb-Pz for qemu-devel@nongnu.org; Wed, 03 Aug 2016 04:17:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bUrMa-0004LH-Pk for qemu-devel@nongnu.org; Wed, 03 Aug 2016 04:17:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58664) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bUrMa-0004LB-HV for qemu-devel@nongnu.org; Wed, 03 Aug 2016 04:17:16 -0400 References: <1470211497-116801-1-git-send-email-imammedo@redhat.com> From: Marcel Apfelbaum Message-ID: <49831bf2-565c-88ef-9ab2-ce6bf7974ac7@redhat.com> Date: Wed, 3 Aug 2016 11:17:11 +0300 MIME-Version: 1.0 In-Reply-To: <1470211497-116801-1-git-send-email-imammedo@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH] pc: pcihp: avoid adding ACPI_PCIHP_PROP_BSEL twice List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Igor Mammedov , qemu-devel@nongnu.org Cc: marcandre.lureau@redhat.com, "Michael S. Tsirkin" , Paolo Bonzini , Richard Henderson , Eduardo Habkost On 08/03/2016 11:04 AM, Igor Mammedov wrote: > PCI hotplug for bridges was introduced only since 2.0 however > acpi_set_bsel()->object_property_add_uint32_ptr(bus, ACPI_PCIHP_PROP_= BSEL) > didn't take in account that for legacy mode (1.7) when > PCI hotplug for bridges is unavailable and ACPI_PCIHP_PROP_BSEL propert= y > the only bus "PCI.0' has been created earlier at acpi_pcihp_init() time= . > > We managed to live with it only because of error rised by adding > a duplicate property in acpi_set_bsel() has been ignored which > resulted in useless leaking of just allocated (int)bus_bsel. > > Issue affects only 1.7 machine type as ACPI tables supported by > QEMU were introduced at that time, but there wasn't PCI hotplug > for bridges till the next release (2.0). > > Fix it by removing duplicate ACPI_PCIHP_PROP_BSEL intialization > in acpi_pcihp_init() and doing it only in one place acpi_set_pci_info()= . > > PS: > do not ignore error returned by object_property_add_uint32_ptr() > and abort QEMU since it's programming error which should be fixed > instead of being ignored. > > Signed-off-by: Igor Mammedov > Reported-by: Marc-Andr=C3=A9 Lureau > --- > hw/acpi/pcihp.c | 10 ---------- > hw/i386/acpi-build.c | 4 ++-- > 2 files changed, 2 insertions(+), 12 deletions(-) > > diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c > index d957d1e..3298d94 100644 > --- a/hw/acpi/pcihp.c > +++ b/hw/acpi/pcihp.c > @@ -302,16 +302,6 @@ void acpi_pcihp_init(Object *owner, AcpiPciHpState= *s, PCIBus *root_bus, > s->root=3D root_bus; > s->legacy_piix =3D !bridges_enabled; > > - if (s->legacy_piix) { > - unsigned *bus_bsel =3D g_malloc(sizeof *bus_bsel); > - > - s->io_len =3D ACPI_PCIHP_LEGACY_SIZE; > - > - *bus_bsel =3D ACPI_PCIHP_BSEL_DEFAULT; > - object_property_add_uint32_ptr(OBJECT(root_bus), ACPI_PCIHP_PR= OP_BSEL, > - bus_bsel, NULL); > - } > - > memory_region_init_io(&s->io, owner, &acpi_pcihp_io_ops, s, > "acpi-pci-hotplug", s->io_len); > memory_region_add_subregion(address_space_io, s->io_base, &s->io); > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c > index a26a4bb..7174933 100644 > --- a/hw/i386/acpi-build.c > +++ b/hw/i386/acpi-build.c > @@ -438,7 +438,7 @@ static void *acpi_set_bsel(PCIBus *bus, void *opaqu= e) > > *bus_bsel =3D (*bsel_alloc)++; > object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BS= EL, > - bus_bsel, NULL); > + bus_bsel, &error_abort); Hi Igor, I think the above hunk should be in a separate patch, but since the patch itself is small enough I am OK with it. > } > > return bsel_alloc; > @@ -447,7 +447,7 @@ static void *acpi_set_bsel(PCIBus *bus, void *opaqu= e) > static void acpi_set_pci_info(void) > { > PCIBus *bus =3D find_i440fx(); /* TODO: Q35 support */ > - unsigned bsel_alloc =3D 0; > + unsigned bsel_alloc =3D ACPI_PCIHP_BSEL_DEFAULT; > > if (bus) { > /* Scan all PCI buses. Set property to enable acpi based hotpl= ug. */ > Reviewed-by: Marcel Apfelbaum Thanks, Marcel