From patchwork Tue Jul 5 03:12:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 71379 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp91378qgy; Mon, 4 Jul 2016 20:17:27 -0700 (PDT) X-Received: by 10.36.83.9 with SMTP id n9mr11850564itb.34.1467688643138; Mon, 04 Jul 2016 20:17:23 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 65si1300810iow.43.2016.07.04.20.17.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jul 2016 20:17: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 1bKGpJ-0000Of-Hg; Tue, 05 Jul 2016 03:15:09 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKGpI-0000Mw-9k for xen-devel@lists.xen.org; Tue, 05 Jul 2016 03:15:08 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id 52/DC-20705-B362B775; Tue, 05 Jul 2016 03:15:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrKIsWRWlGSWpSXmKPExsVi9XuGg66VWnW 4we8N+hZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8a/ff9YCw4IVVyYbNjAeJq3i5GLQ0jgFKPE jmV9bF2MnEDObkaJhTN8QGw2AV2JjxunsIPYIgKyEqu75oDZzAIfGCVOzZYAsYUFfCRub97P2 sXIwcEioCLxsM8SJMwr4Cnx4+htZhBbQkBDYmXvBBYQmxMo/vUmhC0k4CHRf2A9K0S9oMTJmU 9YIMZLSBx88QKqV1Gibf1JNghbUuLgihssIDdLgNx8Ye8XRoiEqcTWo0uZJjAKzkIyaxaSWQs YmVYxahSnFpWlFukaWeglFWWmZ5TkJmbm6BoaGOvlphYXJ6an5iQmFesl5+duYgQGZz0DA+MO xvYTfocYJTmYlER5X/2rChfiS8pPqcxILM6ILyrNSS0+xCjDwaEkwbtWpTpcSLAoNT21Ii0zB xgnMGkJDh4lEV4lVaA0b3FBYm5xZjpE6hSjopQ47wKQPgGQREZpHlwbLDYvMcpKCfMyMjAwCP EUpBblZpagyr9iFOdgVBLmfQEyhSczrwRu+iugxUxAi1ljy0EWlyQipKQaGLtFLh7rnblqZv1 2bq2zxq5idvVz5V0Trq9OlnVdv27hYxtHV7vZS1+eNeOXc2pz+vr7yr7Kf/UhdRsyPtQnnbsv t0hpYcIFbqYPLELR9/MnpKU6aeSt/b7Y/8BrG5Zb6XxO/nbOuiXHn5ioafDclzw+J0XxzplX2 VX3n6w84j6ntlDWfo25rBJLcUaioRZzUXEiAJtUs3rIAgAA X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-2.tower-31.messagelabs.com!1467688501!48806051!1 X-Originating-IP: [58.251.152.64] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27931 invoked from network); 5 Jul 2016 03:15:05 -0000 Received: from szxga01-in.huawei.com (HELO szxga01-in.huawei.com) (58.251.152.64) by server-2.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 5 Jul 2016 03:15:05 -0000 Received: from 172.24.1.47 (EHLO SZXEML429-HUB.china.huawei.com) ([172.24.1.47]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DNG55423; Tue, 05 Jul 2016 11:14:20 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by SZXEML429-HUB.china.huawei.com (10.82.67.184) with Microsoft SMTP Server id 14.3.235.1; Tue, 5 Jul 2016 11:14:07 +0800 From: Shannon Zhao To: Date: Tue, 5 Jul 2016 11:12:46 +0800 Message-ID: <1467688367-17320-17-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1467688367-17320-1-git-send-email-zhaoshenglong@huawei.com> References: <1467688367-17320-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.0A020202.577B260E.00A8, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 181aad2bfcbb7f1390285ca896e3803a Cc: hangaohuai@huawei.com, 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 v3 16/17] libxc/xc_dom_core: 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_core.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c index ebada89..2fafa59 100644 --- a/tools/libxc/xc_dom_core.c +++ b/tools/libxc/xc_dom_core.c @@ -1040,6 +1040,50 @@ static int xc_dom_build_ramdisk(struct xc_dom_image *dom) return -1; } +static int xc_dom_load_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)); + if ( !p2m ) + return -1; + + 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; +} + int xc_dom_build_image(struct xc_dom_image *dom) { unsigned int page_size; @@ -1097,6 +1141,13 @@ int xc_dom_build_image(struct xc_dom_image *dom) memcpy(devicetreemap, dom->devicetree_blob, dom->devicetree_size); } + /* load ACPI tables */ + if ( dom->acpitable_blob && dom->acpitable_size > 0 ) + { + if ( xc_dom_load_acpi(dom) != 0 ) + goto err; + } + /* allocate other pages */ if ( !dom->arch_hooks->p2m_base_supported || dom->parms.p2m_base >= dom->parms.virt_base ||