From nobody Mon Feb 9 18:45:39 2026 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 1505105344374830.6139605502417; Sun, 10 Sep 2017 21:49:04 -0700 (PDT) Received: from localhost ([::1]:55379 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drGed-0006BJ-Kq for importer@patchew.org; Mon, 11 Sep 2017 00:49:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56380) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1drGYP-00015S-Rh for qemu-devel@nongnu.org; Mon, 11 Sep 2017 00:42:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1drGYL-0004ds-TT for qemu-devel@nongnu.org; Mon, 11 Sep 2017 00:42:37 -0400 Received: from mga04.intel.com ([192.55.52.120]:23374) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1drGYL-0004UV-Jt for qemu-devel@nongnu.org; Mon, 11 Sep 2017 00:42:33 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Sep 2017 21:42:33 -0700 Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.142]) by fmsmga002.fm.intel.com with ESMTP; 10 Sep 2017 21:42:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,376,1500966000"; d="scan'208";a="1217079183" From: Haozhong Zhang To: qemu-devel@nongnu.org, xen-devel@lists.xen.org Date: Mon, 11 Sep 2017 12:41:57 +0800 Message-Id: <20170911044157.15403-11-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170911044157.15403-1-haozhong.zhang@intel.com> References: <20170911044157.15403-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.120 Subject: [Qemu-devel] [RFC QEMU PATCH v3 10/10] hw/xen-hvm: enable building DM ACPI if vNVDIMM is enabled 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 , "Michael S. Tsirkin" , Konrad Rzeszutek Wilk , Paolo Bonzini , Igor Mammedov , Anthony Perard , Chao Peng , Dan Williams , 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 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" If the machine option 'nvdimm' is enabled and QEMU is used as Xen device model, construct the guest NFIT and ACPI namespace devices of vNVDIMM and copy them into guest memory. Signed-off-by: Haozhong Zhang --- Cc: "Michael S. Tsirkin" Cc: Igor Mammedov Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: Stefano Stabellini Cc: Anthony Perard --- hw/acpi/aml-build.c | 10 +++++++--- hw/i386/pc.c | 16 ++++++++++------ hw/i386/xen/xen-hvm.c | 25 +++++++++++++++++++++++-- include/hw/xen/xen.h | 7 +++++++ stubs/xen-hvm.c | 4 ++++ 5 files changed, 51 insertions(+), 11 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 36a6cc450e..5f57c1bef3 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -22,6 +22,7 @@ #include "qemu/osdep.h" #include #include "hw/acpi/aml-build.h" +#include "hw/xen/xen.h" #include "qemu/bswap.h" #include "qemu/bitops.h" #include "sysemu/numa.h" @@ -1531,9 +1532,12 @@ build_header(BIOSLinker *linker, GArray *table_data, h->oem_revision =3D cpu_to_le32(1); memcpy(h->asl_compiler_id, ACPI_BUILD_APPNAME4, 4); h->asl_compiler_revision =3D 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 used when QEMU is used as Xen device model. */ + if (!xen_enabled()) { + /* Checksum to be filled in by Guest linker */ + bios_linker_loader_add_checksum(linker, ACPI_BUILD_TABLE_FILE, + tbl_offset, len, checksum_offset); + } } =20 void *acpi_data_push(GArray *table_data, unsigned size) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 5cbdce61a7..7101d380a0 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1252,12 +1252,16 @@ void pc_machine_done(Notifier *notifier, void *data) } } =20 - acpi_setup(); - if (pcms->fw_cfg) { - pc_build_smbios(pcms); - pc_build_feature_control_file(pcms); - /* update FW_CFG_NB_CPUS to account for -device added CPUs */ - fw_cfg_modify_i16(pcms->fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpus); + if (!xen_enabled()) { + acpi_setup(); + if (pcms->fw_cfg) { + pc_build_smbios(pcms); + pc_build_feature_control_file(pcms); + /* update FW_CFG_NB_CPUS to account for -device added CPUs */ + fw_cfg_modify_i16(pcms->fw_cfg, FW_CFG_NB_CPUS, pcms->boot_cpu= s); + } + } else { + xen_dm_acpi_setup(pcms); } =20 if (pcms->apic_id_limit > 255) { diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index b74c4ffb9c..d81cc7dbbc 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -265,7 +265,7 @@ void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size= , MemoryRegion *mr, /* RAM already populated in Xen */ fprintf(stderr, "%s: do not alloc "RAM_ADDR_FMT " bytes of ram at "RAM_ADDR_FMT" when runstate is INMIGRAT= E\n", - __func__, size, ram_addr);=20 + __func__, size, ram_addr); return; } =20 @@ -1251,7 +1251,7 @@ static void xen_wakeup_notifier(Notifier *notifier, v= oid *data) =20 static int xen_dm_acpi_needed(PCMachineState *pcms) { - return 0; + return pcms->acpi_nvdimm_state.is_enabled; } =20 static int dm_acpi_buf_init(XenIOState *state) @@ -1309,6 +1309,20 @@ static int xen_dm_acpi_init(PCMachineState *pcms, Xe= nIOState *state) return dm_acpi_buf_init(state); } =20 +static void xen_dm_acpi_nvdimm_setup(PCMachineState *pcms) +{ + GArray *table_offsets =3D g_array_new(false, true /* clear */, + sizeof(uint32_t)); + GArray *table_data =3D g_array_new(false, true /* clear */, 1); + + nvdimm_build_acpi(table_offsets, table_data, + NULL, &pcms->acpi_nvdimm_state, + MACHINE(pcms)->ram_slots); + + g_array_free(table_offsets, true); + g_array_free(table_data, true); +} + static int xs_write_dm_acpi_blob_entry(const char *name, const char *entry, const char *valu= e) { @@ -1408,6 +1422,13 @@ int xen_acpi_copy_to_guest(const char *name, const v= oid *blob, size_t length, return 0; } =20 +void xen_dm_acpi_setup(PCMachineState *pcms) +{ + if (pcms->acpi_nvdimm_state.is_enabled) { + xen_dm_acpi_nvdimm_setup(pcms); + } +} + void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) { int i, rc; diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index 38dcd1a7d4..8c48195e12 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -66,4 +66,11 @@ void xen_register_framebuffer(struct MemoryRegion *mr); int xen_acpi_copy_to_guest(const char *name, const void *blob, size_t leng= th, int type); =20 +/* + * Build guest ACPI (i.e. DM ACPI, or ACPI built by device model) and + * copy them into guest memory. Xen hvmloader will load and merge DM + * ACPI with the guest ACPI built by itself. + */ +void xen_dm_acpi_setup(PCMachineState *pcms); + #endif /* QEMU_HW_XEN_H */ diff --git a/stubs/xen-hvm.c b/stubs/xen-hvm.c index 58889ae0fb..c1a6d21efa 100644 --- a/stubs/xen-hvm.c +++ b/stubs/xen-hvm.c @@ -67,3 +67,7 @@ int xen_acpi_copy_to_guest(const char *name, const void *= blob, size_t length, { return -1; } + +void xen_dm_acpi_setup(PCMachineState *pcms) +{ +} --=20 2.11.0