From patchwork Thu Dec 7 10:18:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 10098275 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3FE2460329 for ; Thu, 7 Dec 2017 10:22:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F80D2A1E6 for ; Thu, 7 Dec 2017 10:22:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 246872A1E8; Thu, 7 Dec 2017 10:22:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 7DEA42A1E6 for ; Thu, 7 Dec 2017 10:22:56 +0000 (UTC) Received: from localhost ([::1]:59846 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtKR-0001PD-MN for patchwork-qemu-devel@patchwork.kernel.org; Thu, 07 Dec 2017 05:22:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52092) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtGM-0005Mc-Sz for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eMtGL-0003Kb-JO for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:42 -0500 Received: from mga06.intel.com ([134.134.136.31]:34562) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eMtGL-000355-8r for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:41 -0500 Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 07 Dec 2017 02:18:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,372,1508828400"; d="scan'208";a="795713" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.142]) by orsmga007.jf.intel.com with ESMTP; 07 Dec 2017 02:18:38 -0800 From: Haozhong Zhang To: qemu-devel@nongnu.org, xen-devel@lists.xenproject.org Date: Thu, 7 Dec 2017 18:18:08 +0800 Message-Id: <20171207101812.23602-7-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171207101812.23602-1-haozhong.zhang@intel.com> References: <20171207101812.23602-1-haozhong.zhang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.31 Subject: [Qemu-devel] [RFC QEMU PATCH v4 06/10] hw/acpi-build, xen-hvm: introduce a Xen-specific ACPI builder 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: Haozhong Zhang , Stefano Stabellini , Eduardo Habkost , Konrad Rzeszutek Wilk , "Michael S. Tsirkin" , Paolo Bonzini , Anthony Perard , Chao Peng , Dan Williams , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP QEMU on KVM/TCG and Xen requires different sets of guest ACPI tables. When QEMU builds ACPI for Xen HVM domains, the new Xen-specific ACPI build function xen_acpi_build() is called instead of the existing path from acpi_build(). Signed-off-by: Haozhong Zhang --- Cc: Stefano Stabellini Cc: Anthony Perard Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost --- hw/i386/acpi-build.c | 9 ++++++++- hw/i386/xen/xen-hvm.c | 21 +++++++++++++++++++++ include/hw/acpi/aml-build.h | 4 ++++ include/hw/xen/xen.h | 4 ++++ stubs/xen-hvm.c | 5 +++++ 5 files changed, 42 insertions(+), 1 deletion(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 73519ab3ac..9007ecdaed 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -60,6 +60,7 @@ #include "qom/qom-qobject.h" #include "hw/i386/amd_iommu.h" #include "hw/i386/intel_iommu.h" +#include "hw/xen/xen.h" #include "hw/acpi/ipmi.h" @@ -2556,7 +2557,7 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linker) "IVRS", table_data->len - iommu_start, 1, NULL, NULL); } -static GArray * +GArray * build_rsdp(GArray *rsdp_table, BIOSLinker *linker, unsigned rsdt_tbl_offset) { AcpiRsdpDescriptor *rsdp = acpi_data_push(rsdp_table, sizeof *rsdp); @@ -2646,6 +2647,11 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine) 64 /* Ensure FACS is aligned */, false /* high memory */); + if (xen_enabled()) { + xen_acpi_build(tables, table_offsets, machine); + goto done; + } + /* * FACS is pointed to by FADT. * We place it first since it's the only table that has alignment @@ -2788,6 +2794,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine) acpi_align_size(tables->linker->cmd_blob, ACPI_BUILD_ALIGN_SIZE); + done: /* Cleanup memory that's no longer used. */ g_array_free(table_offsets, true); } diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 4b29f4052b..3df20ff282 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -11,6 +11,7 @@ #include "qemu/osdep.h" #include "cpu.h" +#include "hw/acpi/aml-build.h" #include "hw/pci/pci.h" #include "hw/i386/pc.h" #include "hw/i386/apic-msidef.h" @@ -1473,3 +1474,23 @@ void qmp_xen_set_global_dirty_log(bool enable, Error **errp) memory_global_dirty_log_stop(); } } + +void xen_acpi_build(AcpiBuildTables *tables, GArray *table_offsets, + MachineState *machine) +{ + PCMachineState *pcms = PC_MACHINE(machine); + GArray *tables_blob = tables->table_data; + unsigned int rsdt; + + if (!pcms->acpi_build_enabled) { + return; + } + + /* + * QEMU RSDP and RSDT are only used by hvmloader to enumerate + * QEMU-built tables. HVM domains still use Xen-built RSDP and RSDT. + */ + rsdt = tables_blob->len; + build_rsdt(tables_blob, tables->linker, table_offsets, 0, 0); + build_rsdp(tables->rsdp, tables->linker, rsdt); +} diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 88d0738d76..03369bb7ea 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -393,4 +393,8 @@ void build_srat_memory(AcpiSratMemoryAffinity *numamem, uint64_t base, uint64_t len, int node, MemoryAffinityFlags flags); void build_slit(GArray *table_data, BIOSLinker *linker); + +GArray *build_rsdp(GArray *rsdp_table, BIOSLinker *linker, + unsigned rsdt_tbl_offset); + #endif diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index 7efcdaa8fe..2785b8fd35 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -10,6 +10,7 @@ #include "qemu-common.h" #include "exec/cpu-common.h" +#include "hw/acpi/aml-build.h" #include "hw/irq.h" /* xen-machine.c */ @@ -48,4 +49,7 @@ void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t length); void xen_register_framebuffer(struct MemoryRegion *mr); +void xen_acpi_build(AcpiBuildTables *tables, GArray *table_offsets, + MachineState *machine); + #endif /* QEMU_HW_XEN_H */ diff --git a/stubs/xen-hvm.c b/stubs/xen-hvm.c index 3ca6c51b21..58017c1457 100644 --- a/stubs/xen-hvm.c +++ b/stubs/xen-hvm.c @@ -61,3 +61,8 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) void qmp_xen_set_global_dirty_log(bool enable, Error **errp) { } + +void xen_acpi_build(AcpiBuildTables *tables, GArray *table_offsets, + MachineState *machine) +{ +}