From patchwork Mon Sep 11 04:41:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9946647 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 E55E66035D for ; Mon, 11 Sep 2017 04:43:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DB5C128ABB for ; Mon, 11 Sep 2017 04:43:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D039928AD7; Mon, 11 Sep 2017 04:43:59 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 72F6028ABB for ; Mon, 11 Sep 2017 04:43:59 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drGYH-0006N2-Ss; Mon, 11 Sep 2017 04:42:29 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drGYH-0006Ew-Ej for xen-devel@lists.xen.org; Mon, 11 Sep 2017 04:42:29 +0000 Received: from [85.158.137.68] by server-1.bemta-3.messagelabs.com id 28/C8-02048-53416B95; Mon, 11 Sep 2017 04:42:29 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRWlGSWpSXmKPExsXS1tYhr2sisi3 S4MRseYslHxezODB6HN39mymAMYo1My8pvyKBNePO9ZnMBVslK469e8DcwPhGuIuRk0NIoFKi f8dhRhBbQoBX4siyGawQdoDErN4VbF2MXEA1vYwSz0/cZQdJsAnoS6x4fBCoiINDRMBYou2mM 0gNs8AGJokPe5eDNQsLJEm82L0BrJ5FQFXi6M/PTCA2r4CtxMlPDSwQC+QldrVdBKvnFLCT6G t5zwxxkK3E2pUPWCYw8i5gZFjFqFGcWlSWWqRrZKaXVJSZnlGSm5iZo2toYKyXm1pcnJiempO YVKyXnJ+7iREYDvUMDIw7GBv2+h1ilORgUhLlfXd8S6QQX1J+SmVGYnFGfFFpTmrxIUYZDg4l Cd67QtsihQSLUtNTK9Iyc4CBCZOW4OBREuGNAknzFhck5hZnpkOkTjHqcnTcvPuHSYglLz8vV UqcdzpIkQBIUUZpHtwIWJRcYpSVEuZlZGBgEOIpSC3KzSxBlX/FKM7BqCTMexFkCk9mXgncpl dARzABHcFzaQvIESWJCCmpBkYx4YaNRwOfzLMSMbNbsadA8NGOnekftLfyXpuw8lvw7RLtnqj NTi8qGHYwP3x1WFZ2/55/jB7Lv5qo+13Mvd138/u7eiuPe/pfXs261KFrc5dxV8yFxB8iyucT D1+Kz/18xjf3S8xOwyTXaZ3z/v47cvvPzKdiB3/+UJZ6U18RJye+leWRDRuDEktxRqKhFnNRc SIAeiEHM40CAAA= X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-8.tower-31.messagelabs.com!1505104925!114186094!9 X-Originating-IP: [134.134.136.31] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33840 invoked from network); 11 Sep 2017 04:42:28 -0000 Received: from mga06.intel.com (HELO mga06.intel.com) (134.134.136.31) by server-8.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 11 Sep 2017 04:42:28 -0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP; 10 Sep 2017 21:42:28 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.42,376,1500966000"; d="scan'208"; a="1217079161" 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:25 -0700 From: Haozhong Zhang To: qemu-devel@nongnu.org, xen-devel@lists.xen.org Date: Mon, 11 Sep 2017 12:41:55 +0800 Message-Id: <20170911044157.15403-9-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> Cc: Haozhong Zhang , Xiao Guangrong , "Michael S. Tsirkin" , Igor Mammedov , Chao Peng , Dan Williams Subject: [Xen-devel] [RFC QEMU PATCH v3 08/10] nvdimm acpi: copy ACPI namespace device of vNVDIMM to Xen guest X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Xen relies on QEMU to build the ACPI namespace device of vNVDIMM for Xen guest. Signed-off-by: Haozhong Zhang --- Cc: "Michael S. Tsirkin" Cc: Igor Mammedov Cc: Xiao Guangrong --- hw/acpi/nvdimm.c | 55 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 17 deletions(-) diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c index d9cdc5a531..bf887512ad 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -1226,22 +1226,8 @@ static void nvdimm_build_nvdimm_devices(Aml *root_dev, uint32_t ram_slots) } } -static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data, - BIOSLinker *linker, GArray *dsm_dma_arrea, - uint32_t ram_slots) +static void nvdimm_build_ssdt_device(Aml *dev, uint32_t ram_slots) { - Aml *ssdt, *sb_scope, *dev; - 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"); - - dev = aml_device("NVDR"); - /* * ACPI 6.0: 9.20 NVDIMM Devices: * @@ -1262,6 +1248,25 @@ static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data, nvdimm_build_fit(dev); nvdimm_build_nvdimm_devices(dev, ram_slots); +} + +static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data, + BIOSLinker *linker, GArray *dsm_dma_arrea, + uint32_t ram_slots) +{ + Aml *ssdt, *sb_scope, *dev; + 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"); + + dev = aml_device("NVDR"); + + nvdimm_build_ssdt_device(dev, ram_slots); aml_append(sb_scope, dev); aml_append(ssdt, sb_scope); @@ -1285,6 +1290,18 @@ static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data, free_aml_allocator(); } +static void nvdimm_build_xen_ssdt(uint32_t ram_slots) +{ + Aml *dev = init_aml_allocator(); + + nvdimm_build_ssdt_device(dev, ram_slots); + build_append_named_dword(dev->buf, NVDIMM_ACPI_MEM_ADDR); + xen_acpi_copy_to_guest("NVDR", dev->buf->data, dev->buf->len, + XEN_DM_ACPI_BLOB_TYPE_NSDEV); + + free_aml_allocator(); +} + void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data, BIOSLinker *linker, AcpiNVDIMMState *state, uint32_t ram_slots) @@ -1296,8 +1313,12 @@ void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data, return; } - nvdimm_build_ssdt(table_offsets, table_data, linker, state->dsm_mem, - ram_slots); + if (!xen_enabled()) { + nvdimm_build_ssdt(table_offsets, table_data, linker, state->dsm_mem, + ram_slots); + } else { + nvdimm_build_xen_ssdt(ram_slots); + } device_list = nvdimm_get_device_list(); /* no NVDIMM device is plugged. */