From patchwork Mon Mar 20 00:12:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9632889 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 2CA996020B for ; Mon, 20 Mar 2017 00:16:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20C2427FBC for ; Mon, 20 Mar 2017 00:16:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F1032818B; Mon, 20 Mar 2017 00:16:01 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 777EA2807E for ; Mon, 20 Mar 2017 00:15:56 +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 1cpkwm-0006Vc-LU; Mon, 20 Mar 2017 00:13:16 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cpkwl-0006Rw-Rl for xen-devel@lists.xen.org; Mon, 20 Mar 2017 00:13:15 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 0A/5F-12861-B9E1FC85; Mon, 20 Mar 2017 00:13:15 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphkeJIrShJLcpLzFFi42I5YG5SrDtb7ny EwU0HiyUfF7M4MHoc3f2bKYAxijUzLym/IoE14+f/aWwFp6UqfuxoZmxgfCnSxcjJwSJwi0ni eDtfFyMXh5DAdEaJCa86GEESEgK8EkeWzWCFsP0kfrddYYYo6mWUeLl1IlgRm4C+xIrHB4GKO DhEBIwl2m46g9QwCzQzSRyc2soOUiMskC6xpAViEIuAqsTfjQvAbF4BW4mZPxuZIBbIS1y4eo oFZA6ngJ1Ex2w3kLAQUMmPVZNZJjDyLWBkWMWoXpxaVJZapGuhl1SUmZ5RkpuYmaNraGCsl5t aXJyYnpqTmFSsl5yfu4kRGCIMQLCD8UK78yFGSQ4mJVHek04nI4T4kvJTKjMSizPii0pzUosP McpwcChJ8KY7A+UEi1LTUyvSMnOAwQqTluDgURLhvQDSyltckJhbnJkOkTrFqMsxZ/buN0xCL Hn5ealS4rw6IDMEQIoySvPgRsAi5xKjrJQwLyPQUUI8BalFuZklqPKvGMU5GJWEeaeBTOHJzC uB2/QK6AgmoCPefjgBckRJIkJKqoGxfa1mVlfvwqXvOz/w+C9/fkREujBIol177Ulp4dMTrYO Z+uUFn7h8ucW6YdOBx9P5HxS0GNYfnOtwSIpxxjt3f9Nty8xi9mmfXVPxRtxj3vYyv+tVOpkl 23XnB9cIMMz1e3t077yEdtvJP7erxP6bNilnF8uppCjWW1I7rzVN9+rj5TkVwnlTiaU4I9FQi 7moOBEA6KIAn5cCAAA= X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-3.tower-31.messagelabs.com!1489968792!90971302!1 X-Originating-IP: [192.55.52.115] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 24595 invoked from network); 20 Mar 2017 00:13:14 -0000 Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by server-3.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 20 Mar 2017 00:13:14 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489968794; x=1521504794; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=LV922hLxxKprVQNCvZFxFs3j57neoFTLdDo+RxT8VnM=; b=D0VM7Z7g8QiRECZ5FFM2lAUwhoPYlOXT0swPfMqD8LBxKNjHrcmZA+3D Po6cN23cKhgUfLK291g6TptLSUhA1g==; Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Mar 2017 17:13:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,191,1486454400"; d="scan'208";a="78799183" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.153]) by fmsmga006.fm.intel.com with ESMTP; 19 Mar 2017 17:13:10 -0700 From: Haozhong Zhang To: qemu-devel@nongnu.org, xen-devel@lists.xen.org Date: Mon, 20 Mar 2017 08:12:45 +0800 Message-Id: <20170320001249.25521-7-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170320001249.25521-1-haozhong.zhang@intel.com> References: <20170320001249.25521-1-haozhong.zhang@intel.com> Cc: Haozhong Zhang , Xiao Guangrong , "Michael S. Tsirkin" , Igor Mammedov , Konrad Rzeszutek Wilk , Dan Williams Subject: [Xen-devel] [RFC QEMU PATCH v2 06/10] nvdimm acpi: build and copy NVDIMM namespace devices to guest on Xen 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 Build and copy NVDIMM namespace devices to guest when QEMU is used as Xen device model. Only the body of each AML device is built and copied. Xen hvmloader will complete other parts of namespace devices and put in SSDT. 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 2509561729..1e077eca25 100644 --- a/hw/acpi/nvdimm.c +++ b/hw/acpi/nvdimm.c @@ -1222,22 +1222,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_devices(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: * @@ -1258,6 +1244,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_devices(dev, ram_slots); aml_append(sb_scope, dev); aml_append(ssdt, sb_scope); @@ -1281,6 +1286,18 @@ static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data, free_aml_allocator(); } +static void nvdimm_build_xen_nvdimm_devices(uint32_t ram_slots) +{ + Aml *dev = init_aml_allocator(); + + nvdimm_build_devices(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) @@ -1292,8 +1309,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_nvdimm_devices(ram_slots); + } device_list = nvdimm_get_device_list(); /* no NVDIMM device is plugged. */