From patchwork Thu Jun 23 03:17:03 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 70710 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp217245qgy; Wed, 22 Jun 2016 20:20:27 -0700 (PDT) X-Received: by 10.107.135.137 with SMTP id r9mr47092242ioi.133.1466652023418; Wed, 22 Jun 2016 20:20:23 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id f11si2996212itb.95.2016.06.22.20.20.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jun 2016 20:20:23 -0700 (PDT) Received-SPF: neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=neutral (google.com: 192.237.175.120 is neither permitted nor denied by best guess record for domain of xen-devel-bounces@lists.xen.org) smtp.mailfrom=xen-devel-bounces@lists.xen.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFv9o-0000K7-M3; Thu, 23 Jun 2016 03:18:20 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFv9m-0000HK-Tt for xen-devel@lists.xen.org; Thu, 23 Jun 2016 03:18:19 +0000 Received: from [193.109.254.147] by server-4.bemta-14.messagelabs.com id 17/EF-30629-AF45B675; Thu, 23 Jun 2016 03:18:18 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJIsWRWlGSWpSXmKPExsVSPpHPSfdnSHa 4wf5NOhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8af3ZMYCzYJVaxYvJe9gXEfbxcjF4eQwBlG iXPb3rFAOHsYJZr7W5i6GDk52AR0JT5unMIOYosIyEqs7prDDlLELHCdUeLO+22sIAlhAW+Jr SfamEFsFgFViRsHV4I18wp4SJx4PBGsRkJAQ2Jl7wQWEJsTKH5y1hOweiEBd4k5a/ayQNQLSp yc+QTMZhaQkDj44gUzRK+iRNv6k2wQtqTEwRU3wC6VEDjFKNE58xYTRMJUYtupo4wTGAVnIZk 1C8msBYxMqxg1ilOLylKLdA1N9ZKKMtMzSnITM3N0DQ1N9HJTi4sT01NzEpOK9ZLzczcxAoO0 noGBcQfj39OehxglOZiURHmtHLLDhfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwhgUC5QSLUtNTK 9Iyc4DxApOW4OBREuG1AEnzFhck5hZnpkOkTjEqSonzxoAkBEASGaV5cG2wGL3EKCslzMvIwM AgxFOQWpSbWYIq/4pRnINRSZi3E2QKT2ZeCdz0V0CLmYAWL+tPB1lckoiQkmpgPPvv44lZ7HM X/nxQIq29ZOqmtAYl2U36D+8u5J/596N5TPWct3vvTHozsyRUNvbQ/jUbLtzX5719pqWKz+bd wrVbG8QWvHtbuTJwM2Oc8tO4+ZsD71U4OBVP6t57z7NaZPKrDZ8m1R/V684RYrq/ZO2fF9EHA 9pMBOdPi5H57p8+jXPCeaPY1W+VWIozEg21mIuKEwESAPPqzAIAAA== X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-16.tower-27.messagelabs.com!1466651882!49345303!1 X-Originating-IP: [119.145.14.66] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NiA9PiA4NTI3\n X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 37817 invoked from network); 23 Jun 2016 03:18:17 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-16.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 23 Jun 2016 03:18:17 -0000 Received: from 172.24.1.136 (EHLO szxeml430-hub.china.huawei.com) ([172.24.1.136]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CDT13197; Thu, 23 Jun 2016 11:17:47 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml430-hub.china.huawei.com (10.82.67.185) with Microsoft SMTP Server id 14.3.235.1; Thu, 23 Jun 2016 11:17:37 +0800 From: Shannon Zhao To: Date: Thu, 23 Jun 2016 11:17:03 +0800 Message-ID: <1466651824-6964-17-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1466651824-6964-1-git-send-email-zhaoshenglong@huawei.com> References: <1466651824-6964-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.576B54DF.0095, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 0cc758cb691cd7c185b7a4ff42e27711 Cc: sstabellini@kernel.org, wei.liu2@citrix.com, ian.jackson@eu.citrix.com, peter.huangpeng@huawei.com, julien.grall@arm.com, shannon.zhao@linaro.org, boris.ostrovsky@oracle.com Subject: [Xen-devel] [PATCH v2 16/17] libxc/xc_dom_arm: Copy ACPI tables to guest space 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" From: Shannon Zhao Copy all the ACPI tables to guest space so that UEFI or guest could access them. Signed-off-by: Shannon Zhao --- tools/libxc/xc_dom_arm.c | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c index 64a8b67..6a0a5b7 100644 --- a/tools/libxc/xc_dom_arm.c +++ b/tools/libxc/xc_dom_arm.c @@ -63,6 +63,47 @@ static int setup_pgtables_arm(struct xc_dom_image *dom) /* ------------------------------------------------------------------------ */ +static int xc_dom_copy_acpi(struct xc_dom_image *dom) +{ + int rc, i; + uint32_t pages_num = ROUNDUP(dom->acpitable_size, XC_PAGE_SHIFT) >> + XC_PAGE_SHIFT; + const xen_pfn_t base = GUEST_ACPI_BASE >> XC_PAGE_SHIFT; + xen_pfn_t *p2m; + void *acpi_pages; + + p2m = malloc(pages_num * sizeof(*p2m)); + for (i = 0; i < pages_num; i++) + p2m[i] = base + i; + + rc = xc_domain_populate_physmap_exact(dom->xch, dom->guest_domid, + pages_num, 0, 0, p2m); + if ( rc ) + { + DOMPRINTF("%s: xc_domain_populate_physmap_exact failed with %d", + __FUNCTION__, rc); + goto out; + } + + acpi_pages = xc_map_foreign_range(dom->xch, dom->guest_domid, + PAGE_SIZE * pages_num, + PROT_READ | PROT_WRITE, base); + if ( !acpi_pages ) + { + DOMPRINTF("%s Can't map acpi_pages", __FUNCTION__); + rc = -1; + goto out; + } + + memcpy(acpi_pages, dom->acpitable_blob, dom->acpitable_size); + +out: + munmap(acpi_pages, pages_num * PAGE_SIZE); + free(p2m); + + return rc; +} + static int alloc_magic_pages(struct xc_dom_image *dom) { int rc, i; @@ -100,6 +141,16 @@ static int alloc_magic_pages(struct xc_dom_image *dom) xc_hvm_param_set(dom->xch, dom->guest_domid, HVM_PARAM_STORE_EVTCHN, dom->xenstore_evtchn); + if ( dom->acpitable_blob && dom->acpitable_size > 0 ) + { + rc = xc_dom_copy_acpi(dom); + if ( rc != 0 ) + { + DOMPRINTF("Unable to copy ACPI tables"); + return rc; + } + } + return 0; }