From patchwork Tue May 31 05:03:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 68882 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1732567qge; Mon, 30 May 2016 22:05:24 -0700 (PDT) X-Received: by 10.31.9.195 with SMTP id 186mr16192238vkj.131.1464671116357; Mon, 30 May 2016 22:05:16 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 13si22899973vke.148.2016.05.30.22.05.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 22:05:16 -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 1b7bqc-0003PJ-23; Tue, 31 May 2016 05:04:10 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b7bqa-0003NO-In for xen-devel@lists.xen.org; Tue, 31 May 2016 05:04:08 +0000 Received: from [193.109.254.147] by server-11.bemta-14.messagelabs.com id AA/5A-23272-74B1D475; Tue, 31 May 2016 05:04:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVSPpHPSddd2jf c4OpWcYslHxezODB6HN39mymAMYo1My8pvyKBNeN9V03Bb8mK9UdXsDYwnhDuYuTiEBI4xSix 6dlDVghnD6NE/9azQA4nB5uArsTHjVPYQWwRAVmJ1V1z2EGKmAU2Mko8efuVDSQhLBAu8aR/F QuIzSKgKrF9+UNGEJtXwFPiaE8fE4gtIaAhsbJ3AlgNJ1D8yMfnYLaQgIdEa+MOqHpBiZMzn4 DFmQUkJA6+eMEM0aso0bb+JBuELSlxcMUNFpAjJEDOPt+wDegiDiDHVOL1NOkJjIKzkIyahWT UAkamVYwaxalFZalFuobGeklFmekZJbmJmTm6hoYmermpxcWJ6ak5iUnFesn5uZsYgQFaz8DA uINx13bPQ4ySHExKorxWv33ChfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwHpD0DRcSLEpNT61Iy 8wBxgpMWoKDR0mE9ydImre4IDG3ODMdInWKUVFKnPctSEIAJJFRmgfXBovPS4yyUsK8jAwMDE I8BalFuZklqPKvGMU5GJWEeTmkgKbwZOaVwE1/BbSYCWhxfIYPyOKSRISUVANjWj/nDYlvy5q WMu5WW/Zi6rRfoi9Z3qdKH3unGa3V7b9wbsWP0lkn08t+TUtqEs9RYpEOPh9/9BqfwrFl5l6p bTOuLnV6tZ9pWs6lx5MP2bDGx09j2a8wr3dyzuYf6lVHyviSsmwb2yNZy10avKZ8vJlnKOF7s /Nvb/j9I4/i1x1YnRTxWu6fEktxRqKhFnNRcSIApFaqwcoCAAA= X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-4.tower-27.messagelabs.com!1464671034!43930305!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 3664 invoked from network); 31 May 2016 05:04:02 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-4.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 31 May 2016 05:04:02 -0000 Received: from 172.24.1.60 (EHLO SZXEML429-HUB.china.huawei.com) ([172.24.1.60]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CCK68370; Tue, 31 May 2016 13:03:41 +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, 31 May 2016 13:03:34 +0800 From: Shannon Zhao To: Date: Tue, 31 May 2016 13:03:06 +0800 Message-ID: <1464670986-10256-15-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1464670986-10256-1-git-send-email-zhaoshenglong@huawei.com> References: <1464670986-10256-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.574D1B2E.0103, 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: 3c47fcc6226f73db1a30efc769fa03aa 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 Subject: [Xen-devel] [PATCH RESEND 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 ||