From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51020) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btOYi-00068I-DC for qemu-devel@nongnu.org; Sun, 09 Oct 2016 20:35:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1btOYe-0003HQ-56 for qemu-devel@nongnu.org; Sun, 09 Oct 2016 20:35:11 -0400 Received: from mga02.intel.com ([134.134.136.20]:27981) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1btOYd-0003GZ-Pf for qemu-devel@nongnu.org; Sun, 09 Oct 2016 20:35:08 -0400 From: Haozhong Zhang Date: Mon, 10 Oct 2016 08:34:20 +0800 Message-Id: <20161010003423.4333-6-haozhong.zhang@intel.com> In-Reply-To: <20161010003423.4333-1-haozhong.zhang@intel.com> References: <20161010003423.4333-1-haozhong.zhang@intel.com> Subject: [Qemu-devel] [RFC QEMU PATCH 5/8] nvdimm acpi: build and copy NVDIMM namespace devices to guest on Xen List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, xen-devel@lists.xensource.com Cc: Xiao Guangrong , Konrad Rzeszutek Wilk , Haozhong Zhang , "Michael S. Tsirkin" , Igor Mammedov Build and copy NVDIMM namespace devices to guest when QEMU is used as the device model of Xen. Only the body of each AML device is built and copied, Xen hvmloader will build the complete namespace devices from them and put in SSDT tables. Signed-off-by: Haozhong Zhang --- Cc: "Michael S. Tsirkin" Cc: Igor Mammedov Cc: Xiao Guangrong --- hw/acpi/aml-build.c | 2 +- hw/acpi/nvdimm.c | 58 +++++++++++++++++++++++++++------------------ include/hw/acpi/aml-build.h | 2 ++ 3 files changed, 38 insertions(+), 24 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index a749b62..eda999f 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -287,7 +287,7 @@ build_append_named_dword(GArray *array, const char *name_format, ...) static GPtrArray *alloc_list; -static Aml *aml_alloc(void) +Aml *aml_alloc(void) { Aml *var = g_new0(typeof(*var), 1); diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index 6de2301..4cfb94d 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -925,17 +925,22 @@ static void nvdimm_build_ssdt(GSList *device_list, GArray *table_offsets, GArray *table_data, BIOSLinker *linker, GArray *dsm_dma_arrea) { - Aml *ssdt, *sb_scope, *dev, *field; + Aml *ssdt, *sb_scope = NULL, *dev, *field; int mem_addr_offset, nvdimm_ssdt; acpi_add_table(table_offsets, table_data); ssdt = init_aml_allocator(); - acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader)); - sb_scope = aml_scope("\\_SB"); + if (xen_enabled()) { + dev = aml_alloc(); + } else { + acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader)); + + sb_scope = aml_scope("\\_SB"); - dev = aml_device("NVDR"); + dev = aml_device("NVDR"); + } /* * ACPI 6.0: 9.20 NVDIMM Devices: @@ -1014,25 +1019,32 @@ static void nvdimm_build_ssdt(GSList *device_list, GArray *table_offsets, nvdimm_build_nvdimm_devices(device_list, dev); - aml_append(sb_scope, dev); - aml_append(ssdt, sb_scope); - - nvdimm_ssdt = table_data->len; - - /* copy AML table into ACPI tables blob and patch header there */ - g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len); - mem_addr_offset = build_append_named_dword(table_data, - NVDIMM_ACPI_MEM_ADDR); - - bios_linker_loader_alloc(linker, - NVDIMM_DSM_MEM_FILE, dsm_dma_arrea, - sizeof(NvdimmDsmIn), false /* high memory */); - bios_linker_loader_add_pointer(linker, - ACPI_BUILD_TABLE_FILE, mem_addr_offset, sizeof(uint32_t), - NVDIMM_DSM_MEM_FILE, 0); - build_header(linker, table_data, - (void *)(table_data->data + nvdimm_ssdt), - "SSDT", table_data->len - nvdimm_ssdt, 1, NULL, "NVDIMM"); + if (xen_enabled()) { + build_append_named_dword(dev->buf, NVDIMM_ACPI_MEM_ADDR); + xen_acpi_copy_to_guest("NVDR", dev->buf->data, dev->buf->len, + XEN_ACPI_NSDEV); + } else { + aml_append(sb_scope, dev); + aml_append(ssdt, sb_scope); + + nvdimm_ssdt = table_data->len; + + /* copy AML table into ACPI tables blob and patch header there */ + g_array_append_vals(table_data, ssdt->buf->data, ssdt->buf->len); + mem_addr_offset = build_append_named_dword(table_data, + NVDIMM_ACPI_MEM_ADDR); + + bios_linker_loader_alloc(linker, + NVDIMM_DSM_MEM_FILE, dsm_dma_arrea, + sizeof(NvdimmDsmIn), false /* high memory */); + bios_linker_loader_add_pointer(linker, + ACPI_BUILD_TABLE_FILE, mem_addr_offset, + sizeof(uint32_t), + NVDIMM_DSM_MEM_FILE, 0); + build_header(linker, table_data, + (void *)(table_data->data + nvdimm_ssdt), + "SSDT", table_data->len - nvdimm_ssdt, 1, NULL, "NVDIMM"); + } free_aml_allocator(); } diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 559326c..bf02f91 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -232,6 +232,8 @@ Aml *init_aml_allocator(void); */ void free_aml_allocator(void); +Aml *aml_alloc(void); + /** * aml_append: * @parent_ctx: context to which @child element is added -- 2.10.1