From patchwork Mon Oct 10 00:34:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9368837 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 6C0766048F for ; Mon, 10 Oct 2016 00:39:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 588C528B40 for ; Mon, 10 Oct 2016 00:39:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D4F728B4C; Mon, 10 Oct 2016 00:39:45 +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 AEC0928B40 for ; Mon, 10 Oct 2016 00:39:44 +0000 (UTC) Received: from localhost ([::1]:46611 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btOd5-00017O-Ez for patchwork-qemu-devel@patchwork.kernel.org; Sun, 09 Oct 2016 20:39:43 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51006) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btOYd-00061r-RA for qemu-devel@nongnu.org; Sun, 09 Oct 2016 20:35:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btOYa-0003D8-IY for qemu-devel@nongnu.org; Sun, 09 Oct 2016 20:35:07 -0400 Received: from mga01.intel.com ([192.55.52.88]:44519) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btOYa-0003Cj-81 for qemu-devel@nongnu.org; Sun, 09 Oct 2016 20:35:04 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 09 Oct 2016 17:35:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,469,1473145200"; d="scan'208";a="888337196" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.148]) by orsmga003.jf.intel.com with ESMTP; 09 Oct 2016 17:35:02 -0700 From: Haozhong Zhang To: qemu-devel@nongnu.org, xen-devel@lists.xensource.com Date: Mon, 10 Oct 2016 08:34:19 +0800 Message-Id: <20161010003423.4333-5-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20161010003423.4333-1-haozhong.zhang@intel.com> References: <20161010003423.4333-1-haozhong.zhang@intel.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.88 Subject: [Qemu-devel] [RFC QEMU PATCH 4/8] nvdimm acpi: build and copy NFIT to guest 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: Haozhong Zhang , Stefano Stabellini , Xiao Guangrong , Eduardo Habkost , "Michael S. Tsirkin" , Konrad Rzeszutek Wilk , Paolo Bonzini , Anthony Perard , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Build and copy NFIT to guest when QEMU is used as the device model of Xen. The checksum of NFIT is left blank and will be filled by Xen hvmloader. Signed-off-by: Haozhong Zhang --- Cc: "Michael S. Tsirkin" Cc: Igor Mammedov Cc: Xiao Guangrong Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: Stefano Stabellini Cc: Anthony Perard Cc: xen-devel@lists.xensource.com --- hw/acpi/aml-build.c | 9 ++++++--- hw/acpi/nvdimm.c | 8 ++++++++ hw/i386/pc.c | 12 ++++++++---- include/hw/xen/xen.h | 2 ++ xen-hvm.c | 21 ++++++++++++++++++++- 5 files changed, 44 insertions(+), 8 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index b2a1e40..a749b62 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1530,9 +1530,12 @@ build_header(BIOSLinker *linker, GArray *table_data, h->oem_revision = cpu_to_le32(1); memcpy(h->asl_compiler_id, ACPI_BUILD_APPNAME4, 4); h->asl_compiler_revision = cpu_to_le32(1); - /* Checksum to be filled in by Guest linker */ - bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE, - tbl_offset, len, checksum_offset); + /* No linker is provided when running on Xen */ + if (linker) { + /* Checksum to be filled in by Guest linker */ + bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE, + tbl_offset, len, checksum_offset); + } } void *acpi_data_push(GArray *table_data, unsigned size) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index c9c2a84..6de2301 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -32,6 +32,7 @@ #include "hw/acpi/bios-linker-loader.h" #include "hw/nvram/fw_cfg.h" #include "hw/mem/nvdimm.h" +#include "hw/xen/xen.h" static int nvdimm_plugged_device_list(Object *obj, void *opaque) { @@ -389,6 +390,13 @@ static void nvdimm_build_nfit(GSList *device_list, GArray *table_offsets, build_header(linker, table_data, (void *)(table_data->data + header), "NFIT", sizeof(NvdimmNfitHeader) + structures->len, 1, NULL, NULL); + + if (xen_enabled()) { + xen_acpi_copy_to_guest("NFIT", table_data->data + header, + sizeof(NvdimmNfitHeader) + structures->len, + XEN_ACPI_TABLE); + } + g_array_free(structures, true); } diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 2d6d792..33be032 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1269,10 +1269,14 @@ void pc_machine_done(Notifier *notifier, void *data) } } - acpi_setup(); - if (pcms->fw_cfg) { - pc_build_smbios(pcms->fw_cfg); - pc_build_feature_control_file(pcms); + if (xen_enabled()) { + xen_acpi_setup(pcms); + } else { + acpi_setup(); + if (pcms->fw_cfg) { + pc_build_smbios(pcms->fw_cfg); + pc_build_feature_control_file(pcms); + } } } diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index 79273da..60344f9 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -47,6 +47,8 @@ void xen_modified_memory(ram_addr_t start, ram_addr_t length); void xen_register_framebuffer(struct MemoryRegion *mr); +void xen_acpi_setup(PCMachineState *pcms); + #define XEN_ACPI_TABLE 0 #define XEN_ACPI_NSDEV 1 diff --git a/xen-hvm.c b/xen-hvm.c index 168a9ec..768c4c2 100644 --- a/xen-hvm.c +++ b/xen-hvm.c @@ -1244,7 +1244,7 @@ static ram_addr_t guest_acpi_buf_alloc(size_t length) static int xen_acpi_needed(PCMachineState *pcms) { - return 0; + return pcms->acpi_nvdimm_state.is_enabled; } static int xen_acpi_init(PCMachineState *pcms, XenIOState *state) @@ -1256,6 +1256,25 @@ static int xen_acpi_init(PCMachineState *pcms, XenIOState *state) return guest_acpi_buf_init(state); } +static void xen_acpi_nvdimm_setup(PCMachineState *pcms) +{ + GArray *table_offsets = g_array_new(false, true /* clear */, + sizeof(uint32_t)); + GArray *table_data = g_array_new(false, true /* clear */, 1); + + nvdimm_build_acpi(table_offsets, table_data, + NULL, pcms->acpi_nvdimm_state.dsm_mem); + g_array_free(table_offsets, true); + g_array_free(table_data, true); +} + +void xen_acpi_setup(PCMachineState *pcms) +{ + if (pcms->acpi_nvdimm_state.is_enabled) { + xen_acpi_nvdimm_setup(pcms); + } +} + void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) { int i, rc;