From nobody Sun Apr 28 09:39:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502987134747514.4825730227142; Thu, 17 Aug 2017 09:25:34 -0700 (PDT) Received: from localhost ([::1]:33677 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diNbx-0006iK-Jz for importer@patchew.org; Thu, 17 Aug 2017 12:25:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40690) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diNaZ-0005lN-Kp for qemu-devel@nongnu.org; Thu, 17 Aug 2017 12:24:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diNaW-0003Eq-H6 for qemu-devel@nongnu.org; Thu, 17 Aug 2017 12:24:07 -0400 Received: from smtp.citrix.com ([66.165.176.89]:18727) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1diNaW-0003Ee-9X for qemu-devel@nongnu.org; Thu, 17 Aug 2017 12:24:04 -0400 X-IronPort-AV: E=Sophos;i="5.41,388,1498521600"; d="scan'208";a="435915300" From: Anthony PERARD To: Date: Thu, 17 Aug 2017 17:23:45 +0100 Message-ID: <20170817162347.1590-2-anthony.perard@citrix.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170817162347.1590-1-anthony.perard@citrix.com> References: <20170817162347.1590-1-anthony.perard@citrix.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.89 Subject: [Qemu-devel] [PATCH for-2.10 v3 1/3] hw/acpi: Limit hotplug to root bus on legacy mode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anthony PERARD , xen-devel@lists.xenproject.org, Igor Mammedov , "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Signed-off-by: Anthony PERARD --- New patch in V3 --- hw/acpi/pcihp.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index c420a388ea..9db3c2eaf2 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -273,7 +273,7 @@ static void pci_write(void *opaque, hwaddr addr, uint64= _t data, addr, data); break; case PCI_SEL_BASE: - s->hotplug_select =3D data; + s->hotplug_select =3D s->legacy_piix ? ACPI_PCIHP_BSEL_DEFAULT : d= ata; ACPI_PCIHP_DPRINTF("pcisel write %" HWADDR_PRIx " <=3D=3D %" PRIu6= 4 "\n", addr, data); default: --=20 Anthony PERARD From nobody Sun Apr 28 09:39:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502987247496310.9512739906829; Thu, 17 Aug 2017 09:27:27 -0700 (PDT) Received: from localhost ([::1]:33733 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diNdm-0008Aj-8s for importer@patchew.org; Thu, 17 Aug 2017 12:27:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diNaZ-0005lM-Ko for qemu-devel@nongnu.org; Thu, 17 Aug 2017 12:24:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diNaW-0003Ey-Td for qemu-devel@nongnu.org; Thu, 17 Aug 2017 12:24:07 -0400 Received: from smtp.citrix.com ([66.165.176.89]:18727) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1diNaW-0003Ee-KY for qemu-devel@nongnu.org; Thu, 17 Aug 2017 12:24:04 -0400 X-IronPort-AV: E=Sophos;i="5.41,388,1498521600"; d="scan'208";a="435915303" From: Anthony PERARD To: Date: Thu, 17 Aug 2017 17:23:46 +0100 Message-ID: <20170817162347.1590-3-anthony.perard@citrix.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170817162347.1590-1-anthony.perard@citrix.com> References: <20170817162347.1590-1-anthony.perard@citrix.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.89 Subject: [Qemu-devel] [PATCH for-2.10 v3 2/3] hw/acpi: Move acpi_set_pci_info to pcihp X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Eduardo Habkost , "Michael S. Tsirkin" , Bruce Rogers , Paolo Bonzini , Igor Mammedov , Anthony PERARD , xen-devel@lists.xenproject.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This means that the function will be call and the property acpi-pcihp-bsel will be set even if ACPI build is disable. To do PCI passthrough with Xen, the property acpi-pcihp-bsel needs to be set, but this was done only when ACPI tables are built which is not needed for a Xen guest. The need for the property starts with commit "pc: pcihp: avoid adding ACPI_PCIHP_PROP_BSEL twice" (f0c9d64a68b776374ec4732424a3e27753ce37b6). Reported-by: Sander Eikelenboom Signed-off-by: Anthony PERARD --- Changes in V3: - move acpi_set_pci_info to pcihp instead Changes in V2: - check for acpi_enabled before calling acpi_set_pci_info. - set the property on the root bus only. This patch would be a canditade to backport to 2.9, along with "hw/acpi: Limit hotplug to root bus on legacy mode" CC: Stefano Stabellini CC: Bruce Rogers --- hw/acpi/pcihp.c | 31 +++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 32 -------------------------------- 2 files changed, 31 insertions(+), 32 deletions(-) diff --git a/hw/acpi/pcihp.c b/hw/acpi/pcihp.c index 9db3c2eaf2..44e8842db8 100644 --- a/hw/acpi/pcihp.c +++ b/hw/acpi/pcihp.c @@ -75,6 +75,36 @@ static int acpi_pcihp_get_bsel(PCIBus *bus) } } =20 +/* Assign BSEL property to all buses. In the future, this can be changed + * to only assign to buses that support hotplug. + */ +static void *acpi_set_bsel(PCIBus *bus, void *opaque) +{ + unsigned *bsel_alloc =3D opaque; + unsigned *bus_bsel; + + if (qbus_is_hotpluggable(BUS(bus))) { + bus_bsel =3D g_malloc(sizeof *bus_bsel); + + *bus_bsel =3D (*bsel_alloc)++; + object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, + bus_bsel, &error_abort); + } + + return bsel_alloc; +} + +static void acpi_set_pci_info(void) +{ + PCIBus *bus =3D find_i440fx(); /* TODO: Q35 support */ + unsigned bsel_alloc =3D ACPI_PCIHP_BSEL_DEFAULT; + + if (bus) { + /* Scan all PCI buses. Set property to enable acpi based hotplug. = */ + pci_for_each_bus_depth_first(bus, acpi_set_bsel, NULL, &bsel_alloc= ); + } +} + static void acpi_pcihp_test_hotplug_bus(PCIBus *bus, void *opaque) { AcpiPciHpFind *find =3D opaque; @@ -177,6 +207,7 @@ static void acpi_pcihp_update(AcpiPciHpState *s) =20 void acpi_pcihp_reset(AcpiPciHpState *s) { + acpi_set_pci_info(); acpi_pcihp_update(s); } =20 diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 98dd424678..4d19d91e1b 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -493,36 +493,6 @@ build_madt(GArray *table_data, BIOSLinker *linker, PCM= achineState *pcms) table_data->len - madt_start, 1, NULL, NULL); } =20 -/* Assign BSEL property to all buses. In the future, this can be changed - * to only assign to buses that support hotplug. - */ -static void *acpi_set_bsel(PCIBus *bus, void *opaque) -{ - unsigned *bsel_alloc =3D opaque; - unsigned *bus_bsel; - - if (qbus_is_hotpluggable(BUS(bus))) { - bus_bsel =3D g_malloc(sizeof *bus_bsel); - - *bus_bsel =3D (*bsel_alloc)++; - object_property_add_uint32_ptr(OBJECT(bus), ACPI_PCIHP_PROP_BSEL, - bus_bsel, &error_abort); - } - - return bsel_alloc; -} - -static void acpi_set_pci_info(void) -{ - PCIBus *bus =3D find_i440fx(); /* TODO: Q35 support */ - unsigned bsel_alloc =3D ACPI_PCIHP_BSEL_DEFAULT; - - if (bus) { - /* Scan all PCI buses. Set property to enable acpi based hotplug. = */ - pci_for_each_bus_depth_first(bus, acpi_set_bsel, NULL, &bsel_alloc= ); - } -} - static void build_append_pcihp_notify_entry(Aml *method, int slot) { Aml *if_ctx; @@ -2888,8 +2858,6 @@ void acpi_setup(void) =20 build_state =3D g_malloc0(sizeof *build_state); =20 - acpi_set_pci_info(); - acpi_build_tables_init(&tables); acpi_build(&tables, MACHINE(pcms)); =20 --=20 Anthony PERARD From nobody Sun Apr 28 09:39:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1502987225716821.7991401549713; Thu, 17 Aug 2017 09:27:05 -0700 (PDT) Received: from localhost ([::1]:33721 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diNdQ-0007vD-KA for importer@patchew.org; Thu, 17 Aug 2017 12:27:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40616) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1diNaM-0005cQ-2c for qemu-devel@nongnu.org; Thu, 17 Aug 2017 12:23:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1diNaJ-0003Bn-8v for qemu-devel@nongnu.org; Thu, 17 Aug 2017 12:23:54 -0400 Received: from smtp02.citrix.com ([66.165.176.63]:43939) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1diNaJ-0003Av-1x for qemu-devel@nongnu.org; Thu, 17 Aug 2017 12:23:51 -0400 X-IronPort-AV: E=Sophos;i="5.41,388,1498521600"; d="scan'208";a="444200053" From: Anthony PERARD To: Date: Thu, 17 Aug 2017 17:23:47 +0100 Message-ID: <20170817162347.1590-4-anthony.perard@citrix.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170817162347.1590-1-anthony.perard@citrix.com> References: <20170817162347.1590-1-anthony.perard@citrix.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 66.165.176.63 Subject: [Qemu-devel] [PATCH for-2.10 v3 3/3] Revert "ACPI: don't call acpi_pcihp_device_plug_cb on xen" X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , "Michael S. Tsirkin" , Bruce Rogers , Igor Mammedov , Anthony PERARD , xen-devel@lists.xenproject.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This reverts commit 153eba4726dfa1bdfc31d1fe973b2a61b9035492. This patch prevents PCI passthrough hotplug on Xen. Even if the Xen tool stack prepares its own ACPI tables, we still rely on QEMU for hotplug ACPI notifications. The original issue is fixed by the two previous patch: hw/acpi: Disallow change of hotplug_select on legacy_piix hw/acpi: Move acpi_set_pci_info to pcihp Signed-off-by: Anthony PERARD --- CC: Stefano Stabellini CC: Bruce Rogers --- hw/acpi/piix4.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index f276967365..f4fd5907b8 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -385,10 +385,7 @@ static void piix4_device_plug_cb(HotplugHandler *hotpl= ug_dev, dev, errp); } } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { - if (!xen_enabled()) { - acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, d= ev, - errp); - } + acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, = errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { if (s->cpu_hotplug_legacy) { legacy_acpi_cpu_plug_cb(hotplug_dev, &s->gpe_cpu, dev, errp); @@ -411,10 +408,8 @@ static void piix4_device_unplug_request_cb(HotplugHand= ler *hotplug_dev, acpi_memory_unplug_request_cb(hotplug_dev, &s->acpi_memory_hotplug, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { - if (!xen_enabled()) { - acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug,= dev, - errp); - } + acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, + errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) && !s->cpu_hotplug_legacy) { acpi_cpu_unplug_request_cb(hotplug_dev, &s->cpuhp_state, dev, errp= ); --=20 Anthony PERARD