From nobody Thu Nov 6 14:32:30 2025 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; dmarc=fail(p=none dis=none) header.from=linux.intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 154138311398268.94820265686008; Sun, 4 Nov 2018 17:58:33 -0800 (PST) Received: from localhost ([::1]:60942 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJU9w-0006vj-R3 for importer@patchew.org; Sun, 04 Nov 2018 20:58:32 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47421) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gJTvc-0000rZ-H3 for qemu-devel@nongnu.org; Sun, 04 Nov 2018 20:43:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gJTvb-0003mG-4Q for qemu-devel@nongnu.org; Sun, 04 Nov 2018 20:43:44 -0500 Received: from mga18.intel.com ([134.134.136.126]:8029) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gJTvW-0003Xz-P7; Sun, 04 Nov 2018 20:43:40 -0500 Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Nov 2018 17:43:30 -0800 Received: from emurphy1-mobl1.ger.corp.intel.com (HELO localhost.localdomain) ([10.252.26.250]) by fmsmga005.fm.intel.com with ESMTP; 04 Nov 2018 17:43:25 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,466,1534834800"; d="scan'208";a="277074522" From: Samuel Ortiz To: qemu-devel@nongnu.org Date: Mon, 5 Nov 2018 02:40:44 +0100 Message-Id: <20181105014047.26447-22-sameo@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181105014047.26447-1-sameo@linux.intel.com> References: <20181105014047.26447-1-sameo@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.126 Subject: [Qemu-devel] [PATCH v5 21/24] hw: i386: Implement the ACPI builder interface for PC 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: Peter Maydell , Stefano Stabellini , Eduardo Habkost , "Michael S. Tsirkin" , Shannon Zhao , Igor Mammedov , qemu-arm@nongnu.org, Paolo Bonzini , Anthony Perard , xen-devel@lists.xenproject.org, Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" All PC machine type derivatives will use the same ACPI table build methods. But with that change in place, any new x86 machine type will be able to re-use the acpi-build API and customize part of it by defining its own ACPI table build methods. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Tested-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Samuel Ortiz --- hw/i386/acpi-build.c | 14 +++++++++----- hw/i386/pc.c | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 4b1d8fbe3f..93d89b96f1 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -34,6 +34,7 @@ #include "hw/acpi/acpi-defs.h" #include "hw/acpi/acpi.h" #include "hw/acpi/cpu.h" +#include "hw/acpi/builder.h" #include "hw/nvram/fw_cfg.h" #include "hw/loader.h" #include "hw/isa/isa.h" @@ -1683,6 +1684,7 @@ void acpi_build(AcpiBuildTables *tables, GArray *tables_blob =3D tables->table_data; AcpiSlicOem slic_oem =3D { .id =3D NULL, .table_id =3D NULL }; Object *vmgenid_dev; + AcpiBuilder *ab =3D ACPI_BUILDER(machine); =20 acpi_get_pm_info(&pm); acpi_get_misc_info(&misc); @@ -1732,7 +1734,8 @@ void acpi_build(AcpiBuildTables *tables, aml_len +=3D tables_blob->len - fadt; =20 acpi_add_table(table_offsets, tables_blob); - build_madt(tables_blob, tables->linker, machine, acpi_conf); + acpi_builder_madt(ab, tables_blob, tables->linker, + machine, acpi_conf); =20 vmgenid_dev =3D find_vmgenid_dev(); if (vmgenid_dev) { @@ -1756,15 +1759,16 @@ void acpi_build(AcpiBuildTables *tables, } if (acpi_conf->numa_nodes) { acpi_add_table(table_offsets, tables_blob); - build_srat(tables_blob, tables->linker, machine, acpi_conf); + acpi_builder_srat(ab, tables_blob, tables->linker, + machine, acpi_conf); if (have_numa_distance) { acpi_add_table(table_offsets, tables_blob); - build_slit(tables_blob, tables->linker); + acpi_builder_slit(ab, tables_blob, tables->linker); } } if (acpi_get_mcfg(&mcfg)) { acpi_add_table(table_offsets, tables_blob); - build_mcfg(tables_blob, tables->linker, &mcfg); + acpi_builder_mcfg(ab, tables_blob, tables->linker, &mcfg); } if (x86_iommu_get_default()) { IommuType IOMMUType =3D x86_iommu_get_type(); @@ -1795,7 +1799,7 @@ void acpi_build(AcpiBuildTables *tables, slic_oem.id, slic_oem.table_id); =20 /* RSDP is in FSEG memory, so allocate it separately */ - build_rsdp_rsdt(tables->rsdp, tables->linker, rsdt); + acpi_builder_rsdp(ab, tables->rsdp, tables->linker, rsdt); =20 /* We'll expose it all to Guest so we want to reduce * chance of size changes. diff --git a/hw/i386/pc.c b/hw/i386/pc.c index c9ffc8cff6..53a3036066 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -64,6 +64,7 @@ #include "qemu/option.h" #include "hw/acpi/acpi.h" #include "hw/acpi/cpu_hotplug.h" +#include "hw/acpi/builder.h" #include "hw/boards.h" #include "acpi-build.h" #include "hw/mem/pc-dimm.h" @@ -75,6 +76,7 @@ #include "hw/nmi.h" #include "hw/i386/intel_iommu.h" #include "hw/net/ne2000-isa.h" +#include "hw/i386/acpi.h" =20 /* debug PC/ISA interrupts */ //#define DEBUG_IRQ @@ -2404,12 +2406,20 @@ static void x86_nmi(NMIState *n, int cpu_index, Err= or **errp) } } =20 +static AcpiConfiguration *pc_acpi_configuration(AcpiBuilder *builder) +{ + PCMachineState *pcms =3D PC_MACHINE(builder); + + return &pcms->acpi_configuration; +} + static void pc_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); PCMachineClass *pcmc =3D PC_MACHINE_CLASS(oc); HotplugHandlerClass *hc =3D HOTPLUG_HANDLER_CLASS(oc); NMIClass *nc =3D NMI_CLASS(oc); + AcpiBuilderMethods *abm =3D ACPI_BUILDER_METHODS(oc); =20 pcmc->pci_enabled =3D true; pcmc->has_acpi_build =3D true; @@ -2444,6 +2454,14 @@ static void pc_machine_class_init(ObjectClass *oc, v= oid *data) nc->nmi_monitor_handler =3D x86_nmi; mc->default_cpu_type =3D TARGET_DEFAULT_CPU_TYPE; =20 + /* ACPI building methods */ + abm->madt =3D build_madt; + abm->rsdp =3D build_rsdp_rsdt; + abm->mcfg =3D build_mcfg; + abm->srat =3D build_srat; + abm->slit =3D build_slit; + abm->configuration =3D pc_acpi_configuration; + object_class_property_add(oc, MEMORY_DEVICE_REGION_SIZE, "int", pc_machine_get_device_memory_region_size, NULL, NULL, NULL, &error_abort); @@ -2495,6 +2513,7 @@ static const TypeInfo pc_machine_info =3D { .interfaces =3D (InterfaceInfo[]) { { TYPE_HOTPLUG_HANDLER }, { TYPE_NMI }, + { TYPE_ACPI_BUILDER }, { } }, }; --=20 2.19.1