From nobody Fri May 3 11:16:34 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) 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=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512642054115216.27640312844005; Thu, 7 Dec 2017 02:20:54 -0800 (PST) Received: from localhost ([::1]:59827 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtID-0006N0-4S for importer@patchew.org; Thu, 07 Dec 2017 05:20:37 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtGC-0005FX-4w for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eMtG8-00034h-7I for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:32 -0500 Received: from mga06.intel.com ([134.134.136.31]:34560) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eMtG7-00033x-V3 for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:28 -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:26 -0800 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:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,372,1508828400"; d="scan'208";a="795662" From: Haozhong Zhang To: qemu-devel@nongnu.org, xen-devel@lists.xenproject.org Date: Thu, 7 Dec 2017 18:18:03 +0800 Message-Id: <20171207101812.23602-2-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 01/10] xen-hvm: remove a trailing space 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_6 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Signed-off-by: Haozhong Zhang --- Cc: Stefano Stabellini Cc: Anthony Perard Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: "Michael S. Tsirkin" --- hw/i386/xen/xen-hvm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 8028bed6fd..02d92fd268 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -248,7 +248,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 --=20 2.15.1 From nobody Fri May 3 11:16:34 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512642056327879.6305504299486; Thu, 7 Dec 2017 02:20:56 -0800 (PST) Received: from localhost ([::1]:59831 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtIK-0006RT-8p for importer@patchew.org; Thu, 07 Dec 2017 05:20:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52017) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtGB-0005FW-QN for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eMtGA-00035X-DP for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:31 -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 1eMtGA-000355-1Y for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:30 -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:29 -0800 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:26 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,372,1508828400"; d="scan'208";a="795672" From: Haozhong Zhang To: qemu-devel@nongnu.org, xen-devel@lists.xenproject.org Date: Thu, 7 Dec 2017 18:18:04 +0800 Message-Id: <20171207101812.23602-3-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 02/10] xen-hvm: create the hotplug memory region 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 , Eduardo Habkost , Konrad Rzeszutek Wilk , "Michael S. Tsirkin" , Paolo Bonzini , 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" The guest physical address of vNVDIMM is allocated from the hotplug memory region, which is not created when QEMU is used as Xen device model. In order to use vNVDIMM for Xen HVM domains, this commit reuses the code for pc machine type to create the hotplug memory region for Xen HVM domains. Signed-off-by: Haozhong Zhang --- Cc: "Michael S. Tsirkin" Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: Stefano Stabellini Cc: Anthony Perard --- hw/i386/pc.c | 86 ++++++++++++++++++++++++++++-------------------= ---- hw/i386/xen/xen-hvm.c | 2 ++ include/hw/i386/pc.h | 1 + 3 files changed, 51 insertions(+), 38 deletions(-) diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 186545d2a4..9f46c8df79 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -1315,6 +1315,53 @@ void xen_load_linux(PCMachineState *pcms) pcms->fw_cfg =3D fw_cfg; } =20 +void pc_memory_hotplug_init(PCMachineState *pcms, MemoryRegion *system_mem= ory) +{ + MachineState *machine =3D MACHINE(pcms); + PCMachineClass *pcmc =3D PC_MACHINE_GET_CLASS(pcms); + ram_addr_t hotplug_mem_size =3D machine->maxram_size - machine->ram_si= ze; + + if (!pcmc->has_reserved_memory || machine->ram_size >=3D machine->maxr= am_size) + return; + + if (memory_region_size(&pcms->hotplug_memory.mr)) { + error_report("hotplug memory region has been initialized"); + exit(EXIT_FAILURE); + } + + if (machine->ram_slots > ACPI_MAX_RAM_SLOTS) { + error_report("unsupported amount of memory slots: %"PRIu64, + machine->ram_slots); + exit(EXIT_FAILURE); + } + + if (QEMU_ALIGN_UP(machine->maxram_size, + TARGET_PAGE_SIZE) !=3D machine->maxram_size) { + error_report("maximum memory size must by aligned to multiple of " + "%d bytes", TARGET_PAGE_SIZE); + exit(EXIT_FAILURE); + } + + pcms->hotplug_memory.base =3D + ROUND_UP(0x100000000ULL + pcms->above_4g_mem_size, 1ULL << 30); + + if (pcmc->enforce_aligned_dimm) { + /* size hotplug region assuming 1G page max alignment per slot */ + hotplug_mem_size +=3D (1ULL << 30) * machine->ram_slots; + } + + if ((pcms->hotplug_memory.base + hotplug_mem_size) < hotplug_mem_size)= { + error_report("unsupported amount of maximum memory: " RAM_ADDR_FMT, + machine->maxram_size); + exit(EXIT_FAILURE); + } + + memory_region_init(&pcms->hotplug_memory.mr, OBJECT(pcms), + "hotplug-memory", hotplug_mem_size); + memory_region_add_subregion(system_memory, pcms->hotplug_memory.base, + &pcms->hotplug_memory.mr); +} + void pc_memory_init(PCMachineState *pcms, MemoryRegion *system_memory, MemoryRegion *rom_memory, @@ -1366,44 +1413,7 @@ void pc_memory_init(PCMachineState *pcms, } =20 /* initialize hotplug memory address space */ - if (pcmc->has_reserved_memory && - (machine->ram_size < machine->maxram_size)) { - ram_addr_t hotplug_mem_size =3D - machine->maxram_size - machine->ram_size; - - if (machine->ram_slots > ACPI_MAX_RAM_SLOTS) { - error_report("unsupported amount of memory slots: %"PRIu64, - machine->ram_slots); - exit(EXIT_FAILURE); - } - - if (QEMU_ALIGN_UP(machine->maxram_size, - TARGET_PAGE_SIZE) !=3D machine->maxram_size) { - error_report("maximum memory size must by aligned to multiple = of " - "%d bytes", TARGET_PAGE_SIZE); - exit(EXIT_FAILURE); - } - - pcms->hotplug_memory.base =3D - ROUND_UP(0x100000000ULL + pcms->above_4g_mem_size, 1ULL << 30); - - if (pcmc->enforce_aligned_dimm) { - /* size hotplug region assuming 1G page max alignment per slot= */ - hotplug_mem_size +=3D (1ULL << 30) * machine->ram_slots; - } - - if ((pcms->hotplug_memory.base + hotplug_mem_size) < - hotplug_mem_size) { - error_report("unsupported amount of maximum memory: " RAM_ADDR= _FMT, - machine->maxram_size); - exit(EXIT_FAILURE); - } - - memory_region_init(&pcms->hotplug_memory.mr, OBJECT(pcms), - "hotplug-memory", hotplug_mem_size); - memory_region_add_subregion(system_memory, pcms->hotplug_memory.ba= se, - &pcms->hotplug_memory.mr); - } + pc_memory_hotplug_init(pcms, system_memory); =20 /* Initialize PC system firmware */ pc_system_firmware_init(rom_memory, !pcmc->pci_enabled); diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 02d92fd268..fe01b7a025 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -235,6 +235,8 @@ static void xen_ram_init(PCMachineState *pcms, pcms->above_4g_mem_size); memory_region_add_subregion(sysmem, 0x100000000ULL, &ram_hi); } + + pc_memory_hotplug_init(pcms, sysmem); } =20 void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size, MemoryRegion *mr, diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index ef438bd765..86e375b616 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -249,6 +249,7 @@ void pc_memory_init(PCMachineState *pcms, MemoryRegion *rom_memory, MemoryRegion **ram_memory); uint64_t pc_pci_hole64_start(void); +void pc_memory_hotplug_init(PCMachineState *pcms, MemoryRegion *system_mem= ory); qemu_irq pc_allocate_cpu_irq(void); DeviceState *pc_vga_init(ISABus *isa_bus, PCIBus *pci_bus); void pc_basic_device_init(ISABus *isa_bus, qemu_irq *gsi, --=20 2.15.1 From nobody Fri May 3 11:16:34 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512642218894452.1513967022189; Thu, 7 Dec 2017 02:23:38 -0800 (PST) Received: from localhost ([::1]:59848 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtL3-0001Vw-93 for importer@patchew.org; Thu, 07 Dec 2017 05:23:33 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52067) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtGH-0005HI-Fw for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eMtGC-00037u-Jo for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:37 -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 1eMtGC-000355-7l for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:32 -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:32 -0800 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:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,372,1508828400"; d="scan'208";a="795682" From: Haozhong Zhang To: qemu-devel@nongnu.org, xen-devel@lists.xenproject.org Date: Thu, 7 Dec 2017 18:18:05 +0800 Message-Id: <20171207101812.23602-4-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 03/10] hostmem-xen: add a host memory backend for 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 , Eduardo Habkost , Konrad Rzeszutek Wilk , "Michael S. Tsirkin" , Igor Mammedov , Anthony Perard , Chao Peng , Dan Williams 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" vNVDIMM requires a host memory backend to allocate its backend resources to the guest. When QEMU is used as Xen device model, the backend resource allocation of vNVDIMM is managed out of QEMU. A new host memory backend 'memory-backend-xen' is introduced to represent the backend resource allocated by Xen. It simply creates a memory region of the specified size as a placeholder in the guest address space, which will be mapped by Xen to the actual backend resource. Following example QEMU options create a vNVDIMM device backed by a 4GB host PMEM region at host physical address 0x100000000: -object memory-backend-xen,id=3Dmem1,host-addr=3D0x100000000,size=3D4G -device nvdimm,id=3Dnvdimm1,memdev=3Dmem1 Signed-off-by: Haozhong Zhang --- Cc: Eduardo Habkost Cc: Igor Mammedov Cc: "Michael S. Tsirkin" --- backends/Makefile.objs | 1 + backends/hostmem-xen.c | 108 +++++++++++++++++++++++++++++++++++++++++++++= ++++ backends/hostmem.c | 9 +++++ hw/mem/pc-dimm.c | 6 ++- 4 files changed, 123 insertions(+), 1 deletion(-) create mode 100644 backends/hostmem-xen.c diff --git a/backends/Makefile.objs b/backends/Makefile.objs index 0400799efd..3096fde21f 100644 --- a/backends/Makefile.objs +++ b/backends/Makefile.objs @@ -5,6 +5,7 @@ common-obj-$(CONFIG_TPM) +=3D tpm.o =20 common-obj-y +=3D hostmem.o hostmem-ram.o common-obj-$(CONFIG_LINUX) +=3D hostmem-file.o +common-obj-${CONFIG_XEN_BACKEND} +=3D hostmem-xen.o =20 common-obj-y +=3D cryptodev.o common-obj-y +=3D cryptodev-builtin.o diff --git a/backends/hostmem-xen.c b/backends/hostmem-xen.c new file mode 100644 index 0000000000..99211efd81 --- /dev/null +++ b/backends/hostmem-xen.c @@ -0,0 +1,108 @@ +/* + * QEMU Host Memory Backend for Xen + * + * Copyright(C) 2017 Intel Corporation. + * + * Author: + * Haozhong Zhang + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, see + */ + +#include "qemu/osdep.h" +#include "sysemu/hostmem.h" +#include "qapi/error.h" +#include "qom/object_interfaces.h" + +#define TYPE_MEMORY_BACKEND_XEN "memory-backend-xen" + +#define MEMORY_BACKEND_XEN(obj) \ + OBJECT_CHECK(HostMemoryBackendXen, (obj), TYPE_MEMORY_BACKEND_XEN) + +typedef struct HostMemoryBackendXen HostMemoryBackendXen; + +struct HostMemoryBackendXen { + HostMemoryBackend parent_obj; + + uint64_t host_addr; +}; + +static void xen_backend_get_host_addr(Object *obj, Visitor *v, const char = *name, + void *opaque, Error **errp) +{ + HostMemoryBackendXen *backend =3D MEMORY_BACKEND_XEN(obj); + uint64_t value =3D backend->host_addr; + + visit_type_size(v, name, &value, errp); +} + +static void xen_backend_set_host_addr(Object *obj, Visitor *v, const char = *name, + void *opaque, Error **errp) +{ + HostMemoryBackend *backend =3D MEMORY_BACKEND(obj); + HostMemoryBackendXen *xb =3D MEMORY_BACKEND_XEN(obj); + Error *local_err =3D NULL; + uint64_t value; + + if (memory_region_size(&backend->mr)) { + error_setg(&local_err, "cannot change property value"); + goto out; + } + + visit_type_size(v, name, &value, &local_err); + if (local_err) { + goto out; + } + xb->host_addr =3D value; + + out: + error_propagate(errp, local_err); +} + +static void xen_backend_alloc(HostMemoryBackend *backend, Error **errp) +{ + if (!backend->size) { + error_setg(errp, "can't create backend with size 0"); + return; + } + memory_region_init(&backend->mr, OBJECT(backend), "hostmem-xen", + backend->size); + backend->mr.align =3D getpagesize(); +} + +static void xen_backend_class_init(ObjectClass *oc, void *data) +{ + HostMemoryBackendClass *bc =3D MEMORY_BACKEND_CLASS(oc); + + bc->alloc =3D xen_backend_alloc; + + object_class_property_add(oc, "host-addr", "int", + xen_backend_get_host_addr, + xen_backend_set_host_addr, + NULL, NULL, &error_abort); +} + +static const TypeInfo xen_backend_info =3D { + .name =3D TYPE_MEMORY_BACKEND_XEN, + .parent =3D TYPE_MEMORY_BACKEND, + .class_init =3D xen_backend_class_init, + .instance_size =3D sizeof(HostMemoryBackendXen), +}; + +static void register_types(void) +{ + type_register_static(&xen_backend_info); +} + +type_init(register_types); diff --git a/backends/hostmem.c b/backends/hostmem.c index ee2c2d5bfd..ba13a52994 100644 --- a/backends/hostmem.c +++ b/backends/hostmem.c @@ -12,6 +12,7 @@ #include "qemu/osdep.h" #include "sysemu/hostmem.h" #include "hw/boards.h" +#include "hw/xen/xen.h" #include "qapi/error.h" #include "qapi/visitor.h" #include "qapi-types.h" @@ -277,6 +278,14 @@ host_memory_backend_memory_complete(UserCreatable *uc,= Error **errp) goto out; } =20 + /* + * The backend storage of MEMORY_BACKEND_XEN is managed by Xen, + * so no further work in this function is needed. + */ + if (xen_enabled() && !backend->mr.ram_block) { + goto out; + } + ptr =3D memory_region_get_ram_ptr(&backend->mr); sz =3D memory_region_size(&backend->mr); =20 diff --git a/hw/mem/pc-dimm.c b/hw/mem/pc-dimm.c index 66eace5a5c..dcbfce33d5 100644 --- a/hw/mem/pc-dimm.c +++ b/hw/mem/pc-dimm.c @@ -28,6 +28,7 @@ #include "sysemu/kvm.h" #include "trace.h" #include "hw/virtio/vhost.h" +#include "hw/xen/xen.h" =20 typedef struct pc_dimms_capacity { uint64_t size; @@ -108,7 +109,10 @@ void pc_dimm_memory_plug(DeviceState *dev, MemoryHotpl= ugState *hpms, } =20 memory_region_add_subregion(&hpms->mr, addr - hpms->base, mr); - vmstate_register_ram(vmstate_mr, dev); + /* memory-backend-xen is not backed by RAM. */ + if (!xen_enabled()) { + vmstate_register_ram(vmstate_mr, dev); + } numa_set_mem_node_id(addr, memory_region_size(mr), dimm->node); =20 out: --=20 2.15.1 From nobody Fri May 3 11:16:34 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512642210852664.3652401087251; Thu, 7 Dec 2017 02:23:30 -0800 (PST) Received: from localhost ([::1]:59845 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtKu-0001NN-8o for importer@patchew.org; Thu, 07 Dec 2017 05:23:24 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52060) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtGG-0005HH-BJ for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eMtGF-0003AN-G6 for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:36 -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 1eMtGF-000355-6H for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:35 -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:34 -0800 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:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,372,1508828400"; d="scan'208";a="795694" From: Haozhong Zhang To: qemu-devel@nongnu.org, xen-devel@lists.xenproject.org Date: Thu, 7 Dec 2017 18:18:06 +0800 Message-Id: <20171207101812.23602-5-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 04/10] nvdimm: do not intiailize nvdimm->label_data if label size is zero 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 , Konrad Rzeszutek Wilk , "Michael S. Tsirkin" , Igor Mammedov , Anthony Perard , Chao Peng , Dan Williams 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" The memory region of vNVDIMM on Xen is a RAM memory region, so memory_region_get_ram_ptr() cannot be used in nvdimm_realize() to get a pointer to the label data area in that region. To be worse, it may abort QEMU. As Xen currently does not support labels (i.e. label size is 0) and every access in QEMU to labels is led by a label size check, let's not intiailize nvdimm->label_data if the label size is 0. Signed-off-by: Haozhong Zhang --- Cc: Xiao Guangrong Cc: "Michael S. Tsirkin" Cc: Igor Mammedov --- hw/mem/nvdimm.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/mem/nvdimm.c b/hw/mem/nvdimm.c index 952fce5ec8..3e58538b99 100644 --- a/hw/mem/nvdimm.c +++ b/hw/mem/nvdimm.c @@ -87,7 +87,15 @@ static void nvdimm_realize(PCDIMMDevice *dimm, Error **e= rrp) align =3D memory_region_get_alignment(mr); =20 pmem_size =3D size - nvdimm->label_size; - nvdimm->label_data =3D memory_region_get_ram_ptr(mr) + pmem_size; + /* + * The memory region of vNVDIMM on Xen is not a RAM memory region, + * so memory_region_get_ram_ptr() below will abort QEMU. In + * addition that Xen currently does not support vNVDIMM labels + * (i.e. label_size is zero here), let's not initialize of the + * pointer to label data if the label size is zero. + */ + if (nvdimm->label_size) + nvdimm->label_data =3D memory_region_get_ram_ptr(mr) + pmem_size; pmem_size =3D QEMU_ALIGN_DOWN(pmem_size, align); =20 if (size <=3D nvdimm->label_size || !pmem_size) { --=20 2.15.1 From nobody Fri May 3 11:16:34 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512642059485170.5226518645568; Thu, 7 Dec 2017 02:20:59 -0800 (PST) Received: from localhost ([::1]:59833 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtIN-0006VQ-PD for importer@patchew.org; Thu, 07 Dec 2017 05:20:47 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52080) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtGK-0005KM-NF for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eMtGI-0003FD-G6 for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:40 -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 1eMtGI-000355-6w for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:38 -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:37 -0800 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:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,372,1508828400"; d="scan'208";a="795698" From: Haozhong Zhang To: qemu-devel@nongnu.org, xen-devel@lists.xenproject.org Date: Thu, 7 Dec 2017 18:18:07 +0800 Message-Id: <20171207101812.23602-6-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 05/10] xen-hvm: initialize fw_cfg interface 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+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" Xen is going to reuse QEMU to build ACPI of some devices (e.g., NFIT and SSDT for NVDIMM) for HVM domains. The existing QEMU ACPI build code requires a fw_cfg interface which will also be used to pass QEMU built ACPI to Xen. Therefore, we need to initialize fw_cfg when any ACPI is going to be built by QEMU. 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/xen/xen-hvm.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index fe01b7a025..4b29f4052b 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -14,6 +14,7 @@ #include "hw/pci/pci.h" #include "hw/i386/pc.h" #include "hw/i386/apic-msidef.h" +#include "hw/loader.h" #include "hw/xen/xen_common.h" #include "hw/xen/xen_backend.h" #include "qmp-commands.h" @@ -1234,6 +1235,14 @@ static void xen_wakeup_notifier(Notifier *notifier, = void *data) xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 0); } =20 +static void xen_fw_cfg_init(PCMachineState *pcms) +{ + FWCfgState *fw_cfg =3D fw_cfg_init_io(FW_CFG_IO_BASE); + + rom_set_fw(fw_cfg); + pcms->fw_cfg =3D fw_cfg; +} + void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory) { int i, rc; @@ -1384,6 +1393,9 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion = **ram_memory) =20 /* Disable ACPI build because Xen handles it */ pcms->acpi_build_enabled =3D false; + if (pcms->acpi_build_enabled) { + xen_fw_cfg_init(pcms); + } =20 return; =20 --=20 2.15.1 From nobody Fri May 3 11:16:34 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512642211695921.7307777040501; Thu, 7 Dec 2017 02:23:31 -0800 (PST) Received: from localhost ([::1]:59846 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtKu-0001PD-RV for importer@patchew.org; Thu, 07 Dec 2017 05:23:24 -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 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 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,372,1508828400"; d="scan'208";a="795713" 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+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" 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" =20 #include "hw/acpi/ipmi.h" =20 @@ -2556,7 +2557,7 @@ build_amd_iommu(GArray *table_data, BIOSLinker *linke= r) "IVRS", table_data->len - iommu_start, 1, NULL, NULL); } =20 -static GArray * +GArray * build_rsdp(GArray *rsdp_table, BIOSLinker *linker, unsigned rsdt_tbl_offse= t) { AcpiRsdpDescriptor *rsdp =3D acpi_data_push(rsdp_table, sizeof *rsdp); @@ -2646,6 +2647,11 @@ void acpi_build(AcpiBuildTables *tables, MachineStat= e *machine) 64 /* Ensure FACS is aligned */, false /* high memory */); =20 + 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) =20 acpi_align_size(tables->linker->cmd_blob, ACPI_BUILD_ALIGN_SIZE); =20 + 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" =20 #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 =3D PC_MACHINE(machine); + GArray *tables_blob =3D 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 =3D 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); =20 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 @@ =20 #include "qemu-common.h" #include "exec/cpu-common.h" +#include "hw/acpi/aml-build.h" #include "hw/irq.h" =20 /* xen-machine.c */ @@ -48,4 +49,7 @@ void xen_hvm_modified_memory(ram_addr_t start, ram_addr_t= length); =20 void xen_register_framebuffer(struct MemoryRegion *mr); =20 +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 **ra= m_memory) void qmp_xen_set_global_dirty_log(bool enable, Error **errp) { } + +void xen_acpi_build(AcpiBuildTables *tables, GArray *table_offsets, + MachineState *machine) +{ +} --=20 2.15.1 From nobody Fri May 3 11:16:34 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 1512642372025352.21889692818013; Thu, 7 Dec 2017 02:26:12 -0800 (PST) Received: from localhost ([::1]:59870 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtNW-0003sE-TN for importer@patchew.org; Thu, 07 Dec 2017 05:26:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52105) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtGP-0005PS-NS for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eMtGO-0003Qk-Iv for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:45 -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 1eMtGO-000355-9Y for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:44 -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:44 -0800 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:41 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,372,1508828400"; d="scan'208";a="795720" From: Haozhong Zhang To: qemu-devel@nongnu.org, xen-devel@lists.xenproject.org Date: Thu, 7 Dec 2017 18:18:09 +0800 Message-Id: <20171207101812.23602-8-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 07/10] xen-hvm: add functions to copy data from/to HVM memory 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+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" Signed-off-by: Haozhong Zhang --- Cc: Stefano Stabellini Cc: Anthony Perard Cc: Paolo Bonzini Cc: Richard Henderson Cc: Eduardo Habkost Cc: "Michael S. Tsirkin" --- hw/i386/xen/xen-hvm.c | 55 +++++++++++++++++++++++++++++++++++++++++++++++= ++++ include/hw/xen/xen.h | 3 +++ stubs/xen-hvm.c | 10 ++++++++++ 3 files changed, 68 insertions(+) diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index 3df20ff282..a7e99bd438 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -1494,3 +1494,58 @@ void xen_acpi_build(AcpiBuildTables *tables, GArray = *table_offsets, build_rsdt(tables_blob, tables->linker, table_offsets, 0, 0); build_rsdp(tables->rsdp, tables->linker, rsdt); } + +static size_t xen_rw_guest(ram_addr_t gpa, + void *buf, size_t length, bool is_write) +{ + size_t copied =3D 0, size; + ram_addr_t s, e, offset, cur =3D gpa; + xen_pfn_t cur_pfn; + void *page; + int prot =3D is_write ? PROT_WRITE : PROT_READ; + + if (!buf || !length) { + return 0; + } + + s =3D gpa & TARGET_PAGE_MASK; + e =3D gpa + length; + if (e < s) { + return 0; + } + + while (cur < e) { + cur_pfn =3D cur >> TARGET_PAGE_BITS; + offset =3D cur - (cur_pfn << TARGET_PAGE_BITS); + size =3D MIN(length, TARGET_PAGE_SIZE - offset); + + page =3D xenforeignmemory_map(xen_fmem, xen_domid, prot, 1, &cur_p= fn, NULL); + if (!page) { + break; + } + + if (is_write) { + memcpy(page + offset, buf, size); + } else { + memcpy(buf, page + offset, size); + } + xenforeignmemory_unmap(xen_fmem, page, 1); + + copied +=3D size; + buf +=3D size; + cur +=3D size; + length -=3D size; + } + + return copied; +} + +size_t xen_copy_to_guest(ram_addr_t gpa, void *buf, size_t length) +{ + return xen_rw_guest(gpa, buf, length, true); +} + +size_t xen_copy_from_guest(ram_addr_t gpa, void *buf, size_t length) +{ + return xen_rw_guest(gpa, buf, length, false); +} diff --git a/include/hw/xen/xen.h b/include/hw/xen/xen.h index 2785b8fd35..cc40d45aeb 100644 --- a/include/hw/xen/xen.h +++ b/include/hw/xen/xen.h @@ -52,4 +52,7 @@ void xen_register_framebuffer(struct MemoryRegion *mr); void xen_acpi_build(AcpiBuildTables *tables, GArray *table_offsets, MachineState *machine); =20 +size_t xen_copy_to_guest(ram_addr_t gpa, void *buf, size_t length); +size_t xen_copy_from_guest(ram_addr_t gpa, void *buf, size_t length); + #endif /* QEMU_HW_XEN_H */ diff --git a/stubs/xen-hvm.c b/stubs/xen-hvm.c index 58017c1457..5de02842a3 100644 --- a/stubs/xen-hvm.c +++ b/stubs/xen-hvm.c @@ -66,3 +66,13 @@ void xen_acpi_build(AcpiBuildTables *tables, GArray *tab= le_offsets, MachineState *machine) { } + +size_t xen_copy_to_guest(ram_addr_t gpa, void *buf, size_t length) +{ + return 0; +} + +size_t xen_copy_from_guest(ram_addr_t gpa, void *buf, size_t length) +{ + return 0; +} --=20 2.15.1 From nobody Fri May 3 11:16:34 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512642535588845.565827468769; Thu, 7 Dec 2017 02:28:55 -0800 (PST) Received: from localhost ([::1]:59884 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtQ4-0006H8-4t for importer@patchew.org; Thu, 07 Dec 2017 05:28:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtGU-0005Re-OM for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eMtGR-0003WJ-Iw for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:50 -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 1eMtGR-000355-9u for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:47 -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:47 -0800 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:44 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,372,1508828400"; d="scan'208";a="795734" From: Haozhong Zhang To: qemu-devel@nongnu.org, xen-devel@lists.xenproject.org Date: Thu, 7 Dec 2017 18:18:10 +0800 Message-Id: <20171207101812.23602-9-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 08/10] nvdimm acpi: add functions to access DSM memory 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 , Konrad Rzeszutek Wilk , "Michael S. Tsirkin" , Igor Mammedov , Anthony Perard , Chao Peng , Dan Williams 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" Xen hvmloader can load QEMU-built NVDIMM ACPI tables via the BIOSLinkerLoader interface, but it allocates memory in an area not covered by any memory regions in QEMU, i.e., the hvmloader memory cannot be accessed via the normal cpu_physical_memory_{read,write}(). If QEMU on Xen has to access the hvmloader memory in DSM emulation, it has to take a different path, i.e., xen_copy_{from,to}_guest(). Signed-off-by: Haozhong Zhang --- Cc: Xiao Guangrong Cc: "Michael S. Tsirkin" Cc: Igor Mammedov --- hw/acpi/nvdimm.c | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 6ceea196e7..7b3062e001 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" =20 static int nvdimm_device_list(Object *obj, void *opaque) { @@ -497,6 +498,35 @@ struct NvdimmFuncReadFITOut { typedef struct NvdimmFuncReadFITOut NvdimmFuncReadFITOut; QEMU_BUILD_BUG_ON(sizeof(NvdimmFuncReadFITOut) > NVDIMM_DSM_MEMORY_SIZE); =20 +/* + * Xen hvmloader can load QEMU-built NVDIMM ACPI tables via the + * BIOSLinkerLoader interface, but it allocates memory in an area not + * covered by any memory regions in QEMU, i.e., the hvmloader memory + * cannot be accessed via the normal cpu_physical_memory_{read,write}(). + * If QEMU on Xen has to access the hvmloader memory in DSM emulation, + * it has to take a different path, i.e., xen_copy_{from,to}_guest(). + */ + +static void +nvdimm_copy_from_dsm_mem(hwaddr dsm_mem_addr, void *dst, unsigned size) +{ + if (xen_enabled()) { + xen_copy_from_guest(dsm_mem_addr, dst, size); + } else { + cpu_physical_memory_read(dsm_mem_addr, dst, size); + } +} + +static void +nvdimm_copy_to_dsm_mem(hwaddr dsm_mem_addr, void *src, unsigned size) +{ + if (xen_enabled()) { + xen_copy_to_guest(dsm_mem_addr, src, size); + } else { + cpu_physical_memory_write(dsm_mem_addr, src, size); + } +} + static void nvdimm_dsm_function0(uint32_t supported_func, hwaddr dsm_mem_addr) { @@ -504,7 +534,7 @@ nvdimm_dsm_function0(uint32_t supported_func, hwaddr ds= m_mem_addr) .len =3D cpu_to_le32(sizeof(func0)), .supported_func =3D cpu_to_le32(supported_func), }; - cpu_physical_memory_write(dsm_mem_addr, &func0, sizeof(func0)); + nvdimm_copy_to_dsm_mem(dsm_mem_addr, &func0, sizeof(func0)); } =20 static void @@ -514,7 +544,7 @@ nvdimm_dsm_no_payload(uint32_t func_ret_status, hwaddr = dsm_mem_addr) .len =3D cpu_to_le32(sizeof(out)), .func_ret_status =3D cpu_to_le32(func_ret_status), }; - cpu_physical_memory_write(dsm_mem_addr, &out, sizeof(out)); + nvdimm_copy_to_dsm_mem(dsm_mem_addr, &out, sizeof(out)); } =20 #define NVDIMM_DSM_RET_STATUS_SUCCESS 0 /* Success */ @@ -569,7 +599,7 @@ exit: read_fit_out->func_ret_status =3D cpu_to_le32(func_ret_status); memcpy(read_fit_out->fit, fit->data + read_fit->offset, read_len); =20 - cpu_physical_memory_write(dsm_mem_addr, read_fit_out, size); + nvdimm_copy_to_dsm_mem(dsm_mem_addr, read_fit_out, size); =20 g_free(read_fit_out); } @@ -655,8 +685,8 @@ static void nvdimm_dsm_label_size(NVDIMMDevice *nvdimm,= hwaddr dsm_mem_addr) label_size_out.label_size =3D cpu_to_le32(label_size); label_size_out.max_xfer =3D cpu_to_le32(mxfer); =20 - cpu_physical_memory_write(dsm_mem_addr, &label_size_out, - sizeof(label_size_out)); + nvdimm_copy_to_dsm_mem(dsm_mem_addr, &label_size_out, + sizeof(label_size_out)); } =20 static uint32_t nvdimm_rw_label_data_check(NVDIMMDevice *nvdimm, @@ -721,7 +751,7 @@ static void nvdimm_dsm_get_label_data(NVDIMMDevice *nvd= imm, NvdimmDsmIn *in, nvc->read_label_data(nvdimm, get_label_data_out->out_buf, get_label_data->length, get_label_data->offset); =20 - cpu_physical_memory_write(dsm_mem_addr, get_label_data_out, size); + nvdimm_copy_to_dsm_mem(dsm_mem_addr, get_label_data_out, size); g_free(get_label_data_out); } =20 @@ -831,7 +861,7 @@ nvdimm_dsm_write(void *opaque, hwaddr addr, uint64_t va= l, unsigned size) * this by copying DSM memory to QEMU local memory. */ in =3D g_new(NvdimmDsmIn, 1); - cpu_physical_memory_read(dsm_mem_addr, in, sizeof(*in)); + nvdimm_copy_from_dsm_mem(dsm_mem_addr, in, sizeof(*in)); =20 le32_to_cpus(&in->revision); le32_to_cpus(&in->function); --=20 2.15.1 From nobody Fri May 3 11:16:34 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512642367048886.5804826878705; Thu, 7 Dec 2017 02:26:07 -0800 (PST) Received: from localhost ([::1]:59868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtNQ-0003l8-7f for importer@patchew.org; Thu, 07 Dec 2017 05:26:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtGV-0005Sh-V1 for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eMtGU-0003bF-Qc for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:51 -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 1eMtGU-000355-El for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:50 -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:50 -0800 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:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,372,1508828400"; d="scan'208";a="795746" From: Haozhong Zhang To: qemu-devel@nongnu.org, xen-devel@lists.xenproject.org Date: Thu, 7 Dec 2017 18:18:11 +0800 Message-Id: <20171207101812.23602-10-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 09/10] nvdimm acpi: add compatibility for 64-bit integer in ACPI 2.0 and later 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 , Konrad Rzeszutek Wilk , "Michael S. Tsirkin" , Igor Mammedov , Anthony Perard , Chao Peng , Dan Williams 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" When QEMU is used as Xen device model, the QEMU-built NVDIMM ACPI tables (NFIT and SSDT) may be passed to Xen and merged with Xen-built ACPI tables. However, different ACPI versions are used between QEMU (ACPI 1.0) and Xen (ACPI 2.0), and different integer widths are used between ACPI 1.0 (32 bits) and ACPI 2.0 (64 bits). Due to the implicit type conversion between ACPI buffer field object and ACPI integer object (ref. ACPI Spec 6.2, Sect 19.3.5.5, 19.3.5.7 & 19.3.5.8), the following AML in NVDIMM SSDT may behave differently in ACPI 1.0 and ACPI 2.0: Method (NCAL, 5, Serialized) { Local6 =3D MEMA /* \MEMA */ OperationRegion (NPIO, SystemIO, 0x0A18, 0x04) OperationRegion (NRAM, SystemMemory, Local6, 0x1000) Field (NPIO, DWordAcc, NoLock, Preserve) { NTFI, 32 } ... Field (NRAM, DWordAcc, NoLock, Preserve) { RLEN, 32, ODAT, 32736 } ... NTFI =3D Local6 Local1 =3D (RLEN - 0x04) Local1 =3D (Local1 << 0x03) CreateField (ODAT, Zero, Local1, OBUF) Concatenate (Buffer (Zero){}, OBUF, Local7) Return (Local7) } The C layout of the above ODAT is struct NvdimmFuncReadFitOut without the length field: struct { uint32_t func_ret_status; uint8_t fit[0]; } When no error happens and no FIT data is needed to return, nvdimm_dsm_func_read_fit() fills { .func_ret_status =3D 0 }, i.e., 4 bytes of 0's in ODAT. Because the length of ODAT is no larger than an integer, OBUF is implicitly converted into an ACPI integer object during the evaluation of CreateField. Later, when OBUF is concatenated to another buffer, it needs to be converted to an ACPI buffer object. It's converted to a 4 bytes buffer in ACPI 1.0, but it's converted to a 8 bytes buffer in ACPI 2.0. The extra 4 bytes in ACPI 2.0 actually corresponds to the apparently incorrect case that { .func_ret_status =3D 0, fit =3D { 0, 0, 0, 0 } } is filled in ODAT. In order to mitigate this issue, we add a 32-bit reserved field after func_ret_status and always fill it with 0. Therefore, the minimum length of ODAT in both ACPI 1.0 and ACPI 2.0 is always 8 bytes, so no extra bytes will be added accidentally by the implicit conversion. Signed-off-by: Haozhong Zhang --- Cc: Xiao Guangrong Cc: "Michael S. Tsirkin" Cc: Igor Mammedov --- hw/acpi/nvdimm.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 7b3062e001..bceb35e75a 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -493,6 +493,7 @@ struct NvdimmFuncReadFITOut { /* the size of buffer filled by QEMU. */ uint32_t len; uint32_t func_ret_status; /* return status code. */ + uint32_t reserved; uint8_t fit[0]; /* the FIT data. */ } QEMU_PACKED; typedef struct NvdimmFuncReadFITOut NvdimmFuncReadFITOut; @@ -597,6 +598,7 @@ exit: =20 read_fit_out->len =3D cpu_to_le32(size); read_fit_out->func_ret_status =3D cpu_to_le32(func_ret_status); + read_fit_out->reserved =3D 0; memcpy(read_fit_out->fit, fit->data + read_fit->offset, read_len); =20 nvdimm_copy_to_dsm_mem(dsm_mem_addr, read_fit_out, size); @@ -1168,7 +1170,8 @@ static void nvdimm_build_fit(Aml *dev) =20 aml_append(method, aml_store(aml_sizeof(buf), buf_size)); aml_append(method, aml_subtract(buf_size, - aml_int(4) /* the size of "STAU" */, + aml_int(8) /* the size of "STAU" and t= he + consequent reserved fiel= d */, buf_size)); =20 /* if we read the end of fit. */ @@ -1177,7 +1180,7 @@ static void nvdimm_build_fit(Aml *dev) aml_append(method, ifctx); =20 aml_append(method, aml_create_field(buf, - aml_int(4 * BITS_PER_BYTE), /* offset at byte = 4.*/ + aml_int(8 * BITS_PER_BYTE), /* offset at byte = 8. */ aml_shiftleft(buf_size, aml_int(3)), "BUFF")); aml_append(method, aml_return(aml_name("BUFF"))); aml_append(dev, method); --=20 2.15.1 From nobody Fri May 3 11:16:34 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1512642494732685.1208592219052; Thu, 7 Dec 2017 02:28:14 -0800 (PST) Received: from localhost ([::1]:59882 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtPL-0005ko-6z for importer@patchew.org; Thu, 07 Dec 2017 05:27:59 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52149) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eMtGY-0005VG-Nh for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eMtGX-0003ee-LU for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:54 -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 1eMtGX-000355-Bh for qemu-devel@nongnu.org; Thu, 07 Dec 2017 05:18:53 -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:53 -0800 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:50 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.45,372,1508828400"; d="scan'208";a="795753" From: Haozhong Zhang To: qemu-devel@nongnu.org, xen-devel@lists.xenproject.org Date: Thu, 7 Dec 2017 18:18:12 +0800 Message-Id: <20171207101812.23602-11-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 10/10] xen-hvm: enable building NFIT and SSDT of vNVDIMM for HVM domains 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+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" When QEMU is used the device model of Xen HVM domain and vNVDIMM devices are present, enable building ACPI tables related to vNVDIMM. 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/xen/xen-hvm.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c index a7e99bd438..33447fc482 100644 --- a/hw/i386/xen/xen-hvm.c +++ b/hw/i386/xen/xen-hvm.c @@ -1236,6 +1236,11 @@ static void xen_wakeup_notifier(Notifier *notifier, = void *data) xc_set_hvm_param(xen_xc, xen_domid, HVM_PARAM_ACPI_S_STATE, 0); } =20 +static bool xen_dm_acpi_build_enabled(PCMachineState *pcms) +{ + return pcms->acpi_nvdimm_state.is_enabled; +} + static void xen_fw_cfg_init(PCMachineState *pcms) { FWCfgState *fw_cfg =3D fw_cfg_init_io(FW_CFG_IO_BASE); @@ -1392,8 +1397,7 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion = **ram_memory) xen_be_register_common(); xen_read_physmap(state); =20 - /* Disable ACPI build because Xen handles it */ - pcms->acpi_build_enabled =3D false; + pcms->acpi_build_enabled =3D xen_dm_acpi_build_enabled(pcms);; if (pcms->acpi_build_enabled) { xen_fw_cfg_init(pcms); } @@ -1486,6 +1490,11 @@ void xen_acpi_build(AcpiBuildTables *tables, GArray = *table_offsets, return; } =20 + if (pcms->acpi_nvdimm_state.is_enabled) { + nvdimm_build_acpi(table_offsets, tables_blob, tables->linker, + &pcms->acpi_nvdimm_state, machine->ram_slots); + } + /* * QEMU RSDP and RSDT are only used by hvmloader to enumerate * QEMU-built tables. HVM domains still use Xen-built RSDP and RSDT. --=20 2.15.1