From patchwork Mon Mar 20 00:09:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9632911 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 C6DF26020B for ; Mon, 20 Mar 2017 00:16:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BAF2327F60 for ; Mon, 20 Mar 2017 00:16:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AFCAC27FBC; Mon, 20 Mar 2017 00:16:12 +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 0A0B227F60 for ; Mon, 20 Mar 2017 00:16:12 +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 1cpkwp-0006XX-Cu; Mon, 20 Mar 2017 00:13:19 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cpkwo-0006Vu-DQ for xen-devel@lists.xen.org; Mon, 20 Mar 2017 00:13:18 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id 68/C1-00609-D9E1FC85; Mon, 20 Mar 2017 00:13:17 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDLMWRWlGSWpSXmKPExsVywNykWHeu3Pk Ig8uzmS2WfFzM4sDocXT3b6YAxijWzLyk/IoE1oz2+bPYC1oVKg5M+cTewDhBsouRi4NF4BaT xOervawgjpDAdEaJxsN/WboYOTkkBHgljiybwQph+0lMPdTGDFHUyyjx5MNHdpAEm4C+xIrHB 8GKRASkJa59vswIUsQscJZRYvqaVrAiYYEIiX/TNoLZLAKqEktO9jKC2LwCthINuw4yQ2yQl7 hw9RTYZk4BO4k1l26D1QsB1ey/NY1tAiPfAkaGVYzqxalFZalFuhZ6SUWZ6RkluYmZObqGBsZ 6uanFxYnpqTmJScV6yfm5mxiBocIABDsYL7Q7H2KU5GBSEuU96XQyQogvKT+lMiOxOCO+qDQn tfgQowwHh5IEb7ozUE6wKDU9tSItMwcYtDBpCQ4eJRHeCyCtvMUFibnFmekQqVOMilLivDogf QIgiYzSPLg2WKRcYpSVEuZlBDpEiKcgtSg3swRV/hWjOAejkjDvNJApPJl5JXDTXwEtZgJa/P bDCZDFJYkIKakGRsHnKtwXFdNtbJ9F/BFj3b58RoLRHyk2lfisYysXzmDvYnpYvWO6pqHa34D eQwG7r6/am2Ko62B+9v6Fw96e03dzxOtY5Pi7HFT99iHv1Rp9zjznDRlKz84laDKlPazdrGZ2 Y6L1zux9luEfGzVn/pU8t9/i1eyUWumTTNNZ1/n42Zx0vPbioxJLcUaioRZzUXEiAP9gcI6PA gAA X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-3.tower-31.messagelabs.com!1489968792!90971302!3 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 26273 invoked from network); 20 Mar 2017 00:13:16 -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:16 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1489968796; x=1521504796; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=1KfxCvekMsVj5BbRfAwFglBuk1sX+HoNKszRqsxIdjQ=; b=lvFtf5k4/AynLRZsxBmZWjJxLTWLHA0xyl+lkFh/MDAifRh/pMpMlvZ5 7SW6//+zwux1ed9HsMs1hUs4iE8w2w==; 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:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,191,1486454400"; d="scan'208";a="78799190" 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:13 -0700 From: Haozhong Zhang To: xen-devel@lists.xen.org Date: Mon, 20 Mar 2017 08:09:40 +0800 Message-Id: <20170320000949.24675-7-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170320000949.24675-1-haozhong.zhang@intel.com> References: <20170320000949.24675-1-haozhong.zhang@intel.com> Cc: Konrad Rzeszutek Wilk , Dan Williams , Ian Jackson , Wei Liu , Haozhong Zhang Subject: [Xen-devel] [RFC XEN PATCH v2 06/15] tools: reserve guest memory for ACPI from device model 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 Some virtual devices (e.g. NVDIMM) require complex ACPI tables and definition blocks (in AML), which a device model (e.g. QEMU) has already been able to construct. Instead of introducing the similar implementation to Xen, we would like to reuse the device model to provide those ACPI stuffs. This commit reserves an area in the guest memory for the device model to pass its ACPI tables and definition blocks to guest, which will be loaded by hvmloader. The base guest physical address and the size of the reserved area are passed to the device model via XenStore keys hvmloader/dm-acpi/{address, length}. Signed-off-by: Haozhong Zhang --- Cc: Ian Jackson Cc: Wei Liu --- tools/libxc/include/xc_dom.h | 1 + tools/libxc/xc_dom_x86.c | 7 +++++++ tools/libxl/libxl_dom.c | 22 ++++++++++++++++++++++ xen/include/public/hvm/hvm_xs_strings.h | 11 +++++++++++ 4 files changed, 41 insertions(+) diff --git a/tools/libxc/include/xc_dom.h b/tools/libxc/include/xc_dom.h index 608cbc2ad6..19d65cda1e 100644 --- a/tools/libxc/include/xc_dom.h +++ b/tools/libxc/include/xc_dom.h @@ -98,6 +98,7 @@ struct xc_dom_image { xen_pfn_t xenstore_pfn; xen_pfn_t shared_info_pfn; xen_pfn_t bootstack_pfn; + xen_pfn_t dm_acpi_pfn; xen_pfn_t pfn_alloc_end; xen_vaddr_t virt_alloc_end; xen_vaddr_t bsd_symtab_start; diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c index 6495e7fc30..917fb51abf 100644 --- a/tools/libxc/xc_dom_x86.c +++ b/tools/libxc/xc_dom_x86.c @@ -674,6 +674,13 @@ static int alloc_magic_pages_hvm(struct xc_dom_image *dom) ioreq_server_pfn(0)); xc_hvm_param_set(xch, domid, HVM_PARAM_NR_IOREQ_SERVER_PAGES, NR_IOREQ_SERVER_PAGES); + + dom->dm_acpi_pfn = xc_dom_alloc_page(dom, "DM ACPI"); + if ( dom->dm_acpi_pfn == INVALID_PFN ) + { + DOMPRINTF("Could not allocate page for device model ACPI."); + goto error_out; + } } rc = xc_dom_alloc_segment(dom, &dom->start_info_seg, diff --git a/tools/libxl/libxl_dom.c b/tools/libxl/libxl_dom.c index d519c8d440..5f621466d5 100644 --- a/tools/libxl/libxl_dom.c +++ b/tools/libxl/libxl_dom.c @@ -865,6 +865,28 @@ static int hvm_build_set_xs_values(libxl__gc *gc, goto err; } + if (dom->dm_acpi_pfn) { + uint64_t guest_addr_out = dom->dm_acpi_pfn * XC_DOM_PAGE_SIZE(dom); + + if (guest_addr_out >= 0x100000000ULL) { + LOG(ERROR, + "Guest address of DM ACPI is 0x%"PRIx64", but expected below 4G", + guest_addr_out); + goto err; + } + + path = GCSPRINTF("/local/domain/%d/"HVM_XS_DM_ACPI_ADDRESS, domid); + ret = libxl__xs_printf(gc, XBT_NULL, path, "0x%"PRIx64, guest_addr_out); + if (ret) + goto err; + + path = GCSPRINTF("/local/domain/%d/"HVM_XS_DM_ACPI_LENGTH, domid); + ret = libxl__xs_printf(gc, XBT_NULL, path, "0x%"PRIx64, + (uint64_t)XC_DOM_PAGE_SIZE(dom)); + if (ret) + goto err; + } + return 0; err: diff --git a/xen/include/public/hvm/hvm_xs_strings.h b/xen/include/public/hvm/hvm_xs_strings.h index 146b0b0582..f9b82dbbc0 100644 --- a/xen/include/public/hvm/hvm_xs_strings.h +++ b/xen/include/public/hvm/hvm_xs_strings.h @@ -79,4 +79,15 @@ */ #define HVM_XS_OEM_STRINGS "bios-strings/oem-%d" +/* Follows are XenStore keys for DM ACPI (ACPI built by device model, + * e.g. QEMU). + * + * A reserved area of guest physical memory is used to pass DM + * ACPI. Values of following two keys specify the base physical + * address and length (in bytes) of the reserved area. + */ +#define HVM_XS_DM_ACPI_ROOT "hvmloader/dm-acpi" +#define HVM_XS_DM_ACPI_ADDRESS HVM_XS_DM_ACPI_ROOT"/address" +#define HVM_XS_DM_ACPI_LENGTH HVM_XS_DM_ACPI_ROOT"/length" + #endif /* __XEN_PUBLIC_HVM_HVM_XS_STRINGS_H__ */