From nobody Tue Feb 10 01:34:51 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.zoho.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 1489969106448333.3077318632171; Sun, 19 Mar 2017 17:18:26 -0700 (PDT) Received: from localhost ([::1]:58657 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cpl1l-0000Ea-3t for importer@patchew.org; Sun, 19 Mar 2017 20:18:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58230) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cpkwl-000598-T3 for qemu-devel@nongnu.org; Sun, 19 Mar 2017 20:13:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cpkwi-0004wT-Nd for qemu-devel@nongnu.org; Sun, 19 Mar 2017 20:13:15 -0400 Received: from mga03.intel.com ([134.134.136.65]:51743) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cpkwi-0004uJ-Fv for qemu-devel@nongnu.org; Sun, 19 Mar 2017 20:13:12 -0400 Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 19 Mar 2017 17:13:12 -0700 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 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489968792; x=1521504792; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=LV922hLxxKprVQNCvZFxFs3j57neoFTLdDo+RxT8VnM=; b=bJx23ZXMtywoBa9fzAL9ss0JyxU978Yhjoww/nflHcZKP6Y2/g9A6gC1 NkobD93NJIZifM9lmkWHly5SIZzsNQ==; X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,191,1486454400"; d="scan'208";a="78799183" 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> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 134.134.136.65 Subject: [Qemu-devel] [RFC QEMU PATCH v2 06/10] nvdimm acpi: build and copy NVDIMM namespace devices to guest 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 , Xiao Guangrong , "Michael S. Tsirkin" , Igor Mammedov , Konrad Rzeszutek Wilk , 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" 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_de= v, uint32_t ram_slots) } } =20 -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 =3D init_aml_allocator(); - acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader)); - - sb_scope =3D aml_scope("\\_SB"); - - dev =3D 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); =20 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 =3D init_aml_allocator(); + acpi_data_push(ssdt->buf, sizeof(AcpiTableHeader)); + + sb_scope =3D aml_scope("\\_SB"); + + dev =3D aml_device("NVDR"); + + nvdimm_build_devices(dev, ram_slots); =20 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(); } =20 +static void nvdimm_build_xen_nvdimm_devices(uint32_t ram_slots) +{ + Aml *dev =3D 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; } =20 - 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_me= m, + ram_slots); + } else { + nvdimm_build_xen_nvdimm_devices(ram_slots); + } =20 device_list =3D nvdimm_get_device_list(); /* no NVDIMM device is plugged. */ --=20 2.12.0