From patchwork Tue May 31 04:43:36 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 68873 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1727961qge; Mon, 30 May 2016 21:51:10 -0700 (PDT) X-Received: by 10.55.146.71 with SMTP id u68mr29507095qkd.30.1464670270614; Mon, 30 May 2016 21:51:10 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id s6si29824750qkd.268.2016.05.30.21.51.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 21:51:10 -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 1b7bcw-0000RF-TD; Tue, 31 May 2016 04:50:02 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b7bcv-0000Lc-M9 for xen-devel@lists.xen.org; Tue, 31 May 2016 04:50:01 +0000 Received: from [85.158.139.211] by server-17.bemta-5.messagelabs.com id E4/9D-28468-8F71D475; Tue, 31 May 2016 04:50:00 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVSPpHPSfeHuG+ 4wevzkhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8b7rpqC35IV64+uYG1gPCHcxcjFISRwhlGi 6/9EVghnD6PEh//f2boYOTnYBHQlPm6cwg5iiwjISqzumsMOUsQssIlRou3LRRaQhLBAgMTcR 9PBGlgEVCX2TLnDCmLzCnhKvHi7DiwuIaAhsbJ3Alg9J1D8/MSXzCC2kICHxL5lpxkh6gUlTs 58AlbDLCAhcfDFC2aIXkWJtvUnoeZIShxccYMF5AgJgVOMEqcuPWOFSJhK7O/rYZ/AKDgLyax ZSGYtYGRaxahenFpUllqka6aXVJSZnlGSm5iZo2toYKqXm1pcnJiempOYVKyXnJ+7iREYoAxA sINxaoPzIUZJDiYlUV6r3z7hQnxJ+SmVGYnFGfFFpTmpxYcYZTg4lCR4b4r5hgsJFqWmp1akZ eYAYwUmLcHBoyTCawGS5i0uSMwtzkyHSJ1iVJQS510AkhAASWSU5sG1weLzEqOslDAvI9AhQj wFqUW5mSWo8q8YxTkYlYR5t4JM4cnMK4Gb/gpoMRPQ4vgMH5DFJYkIKakGRudpm2+9v/Nt5XR GjUatu87vmL4+3Cjds8dKeX6L0oTy5+GshXtmWLSwO7rfEUqfWJQWtjRHek/Tx+2//O6fnOe3 LUrt/92CoB8v/Kc1elum+3x3KY5nuG0Q+/pYxHvWoBh5ifda3tMOS+WFWyrvNzGb1uV3WiZe1 Jwr+sE9lYtLyspO14UvU2Ipzkg01GIuKk4EANtIXpTKAgAA X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1464670196!42088224!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 54127 invoked from network); 31 May 2016 04:49:59 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-6.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 31 May 2016 04:49:59 -0000 Received: from 172.24.1.137 (EHLO szxeml428-hub.china.huawei.com) ([172.24.1.137]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CCK66924; Tue, 31 May 2016 12:44:53 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml428-hub.china.huawei.com (10.82.67.183) with Microsoft SMTP Server id 14.3.235.1; Tue, 31 May 2016 12:44:42 +0800 From: Shannon Zhao To: Date: Tue, 31 May 2016 12:43:36 +0800 Message-ID: <1464669816-11476-15-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1464669816-11476-1-git-send-email-zhaoshenglong@huawei.com> References: <1464669816-11476-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.0A020201.574D1718.001D, 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: 00f1d86ec0e3c52862430d26397fde88 Cc: sstabellini@kernel.org, ian.jackson@eu.citrix.com, peter.huangpeng@huawei.com, julien.grall@arm.com, shannon.zhao@linaro.org, wei.liu2@citrix.comg Subject: [Xen-devel] [PATCH 14/14] libxc/xc_dom_core: Copy ACPI tables to guest memory 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 memory space and also initialize the address of the tables. Signed-off-by: Shannon Zhao --- tools/libxc/xc_dom_core.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/tools/libxc/xc_dom_core.c b/tools/libxc/xc_dom_core.c index 55c779d..6d91a46 100644 --- a/tools/libxc/xc_dom_core.c +++ b/tools/libxc/xc_dom_core.c @@ -33,6 +33,7 @@ #include "xg_private.h" #include "xc_dom.h" +#include "acpi_defs.h" /* ------------------------------------------------------------------------ */ /* debugging */ @@ -1096,6 +1097,64 @@ 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 ) + { + void *acpitablemap; + uint64_t start = dom->acpi_seg.vstart; + struct acpi_xsdt_descriptor *xsdt; + struct acpi_rsdp_descriptor *rsdp; + struct acpi_fadt_descriptor *fadt; + + if ( xc_dom_alloc_segment(dom, &dom->acpi_seg, "acpitable", + start, dom->acpitable_size) != 0 ) + goto err; + + acpitablemap = xc_dom_seg_to_ptr(dom, &dom->acpi_seg); + if ( acpitablemap == NULL ) + { + DOMPRINTF("%s: xc_dom_seg_to_ptr(dom, &dom->acpi_seg) => NULL", + __FUNCTION__); + goto err; + } + + rsdp = (struct acpi_rsdp_descriptor *)acpitablemap; + memcpy(acpitablemap, dom->acpitable_blob->rsdp.table, + dom->acpitable_blob->rsdp.size); + start += dom->acpitable_blob->rsdp.size; + acpitablemap += dom->acpitable_blob->rsdp.size; + + xsdt = (struct acpi_xsdt_descriptor *)acpitablemap; + memcpy(acpitablemap, dom->acpitable_blob->xsdt.table, + dom->acpitable_blob->xsdt.size); + rsdp->xsdt_physical_address = start; + start += dom->acpitable_blob->xsdt.size; + acpitablemap += dom->acpitable_blob->xsdt.size; + + memcpy(acpitablemap, dom->acpitable_blob->madt.table, + dom->acpitable_blob->madt.size); + xsdt->entry[0] = start; + start += dom->acpitable_blob->madt.size; + acpitablemap += dom->acpitable_blob->madt.size; + + memcpy(acpitablemap, dom->acpitable_blob->gtdt.table, + dom->acpitable_blob->gtdt.size); + xsdt->entry[1] = start; + start += dom->acpitable_blob->gtdt.size; + acpitablemap += dom->acpitable_blob->gtdt.size; + + fadt = (struct acpi_fadt_descriptor *)acpitablemap; + memcpy(acpitablemap, dom->acpitable_blob->fadt.table, + dom->acpitable_blob->fadt.size); + xsdt->entry[2] = start; + start += dom->acpitable_blob->fadt.size; + acpitablemap += dom->acpitable_blob->fadt.size; + + memcpy(acpitablemap, dom->acpitable_blob->dsdt.table, + dom->acpitable_blob->dsdt.size); + fadt->dsdt = start; + } + /* allocate other pages */ if ( !dom->arch_hooks->p2m_base_supported || dom->parms.p2m_base >= dom->parms.virt_base ||