From patchwork Tue May 31 04:43:35 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 68871 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1727943qge; Mon, 30 May 2016 21:51:07 -0700 (PDT) X-Received: by 10.31.80.7 with SMTP id e7mr15704317vkb.124.1464670267394; Mon, 30 May 2016 21:51:07 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id i64si12672794uai.61.2016.05.30.21.51.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 21:51:07 -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 1b7bd1-0000cO-5Q; Tue, 31 May 2016 04:50:07 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b7bd0-0000Un-Hh for xen-devel@lists.xen.org; Tue, 31 May 2016 04:50:06 +0000 Received: from [85.158.137.68] by server-9.bemta-3.messagelabs.com id 1A/01-25578-DF71D475; Tue, 31 May 2016 04:50:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVSPpHPSfevuG+ 4wexpshZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8ady72MBVvlKv4d+sHawHhcrIuRi0NI4Ayj xP5Z39khnD2MEh/+f2frYuTkYBPQlfi4cQo7iC0iICuxumsOWBGzwCZGibYvF1lAEsICPhLHD 8xiArFZBFQl5k6dwQpi8wp4Sjw8dYARxJYQ0JBY2TsBrJ4TKH5+4ktmEFtIwENi37LTjBD1gh InZz4Bq2EWkJA4+OIFM0SvokTb+pNsELakxMEVN1hAjpAQOMUocXrqIaBmDiDHVOL+U9EJjIK zkIyahWTUAkamVYzqxalFZalFuqZ6SUWZ6RkluYmZObqGBsZ6uanFxYnpqTmJScV6yfm5mxiB AVrPwMC4g/HyV6dDjJIcTEqivFa/fcKF+JLyUyozEosz4otKc1KLDzHKcHAoSfDeFPMNFxIsS k1PrUjLzAHGCkxagoNHSYRXCRgvQrzFBYm5xZnpEKlTjIpS4rwLQPoEQBIZpXlwbbD4vMQoKy XMy8jAwCDEU5BalJtZgir/ilGcg1FJmPcryBSezLwSuOmvgBYzAS2Oz/ABWVySiJCSamB8/V7 V6EGhveQKUU2jpz1xbQ/v8hzU3r/ws0rAp6mf5XbHTuSadXVS3YanctaNH4QOzWvdWL46bmp4 /LWdV/19or2m6WxqPnVlf9q0X4Z337tI/eFvTPhrcYHp8zfjP29vHzrNMDFYfEUNw63qezs1E jbc3LZG6P3EJx4bv5nyH3jc+Np36pNjUkosxRmJhlrMRcWJABlHwYrKAgAA X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-14.tower-31.messagelabs.com!1464670201!42900185!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.34; banners=-,-,- X-VirusChecked: Checked Received: (qmail 4678 invoked from network); 31 May 2016 04:50:04 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-14.tower-31.messagelabs.com with SMTP; 31 May 2016 04:50:04 -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 CCK66923; 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:35 +0800 Message-ID: <1464669816-11476-14-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.574D1717.011C, 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: 6ccc419e7d7950137b90e25d0dc4dd75 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 13/14] libxl/arm: initialize memory information of ACPI blob 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 Assign the guest memory space for ACPI tables and replace the reg in DT with real values. Signed-off-by: Shannon Zhao --- tools/libxc/xc_dom_arm.c | 16 +++++++++++++++- tools/libxl/libxl_arm.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/tools/libxc/xc_dom_arm.c b/tools/libxc/xc_dom_arm.c index 64a8b67..e21e3e9 100644 --- a/tools/libxc/xc_dom_arm.c +++ b/tools/libxc/xc_dom_arm.c @@ -383,9 +383,11 @@ static int meminit(struct xc_dom_image *dom) const uint64_t kernsize = kernend - kernbase; const uint64_t dtb_size = dom->devicetree_blob ? ROUNDUP(dom->devicetree_size, XC_PAGE_SHIFT) : 0; + const uint64_t acpi_size = dom->acpitable_blob ? + ROUNDUP(dom->acpitable_size, XC_PAGE_SHIFT) : 0; const uint64_t ramdisk_size = dom->ramdisk_blob ? ROUNDUP(dom->ramdisk_size, XC_PAGE_SHIFT) : 0; - const uint64_t modsize = dtb_size + ramdisk_size; + const uint64_t modsize = dtb_size + acpi_size + ramdisk_size; const uint64_t ram128mb = bankbase[0] + (128<<20); xen_pfn_t p2m_size; @@ -500,6 +502,18 @@ static int meminit(struct xc_dom_image *dom) modbase += dtb_size; } + if ( acpi_size ) + { + dom->acpi_seg.vstart = modbase; + dom->acpi_seg.vend = modbase + acpi_size; + + DOMPRINTF("%s: acpi: 0x%" PRIx64 " -> 0x%" PRIx64 "", + __FUNCTION__, + dom->acpi_seg.vstart, dom->acpi_seg.vend); + + modbase += dtb_size; + } + return 0; } diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index e7cb578..bf1eeea 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -230,6 +230,27 @@ static int fdt_property_regs(libxl__gc *gc, void *fdt, return fdt_property(fdt, "reg", regs, sizeof(regs)); } +static int fdt_property_inplace_regs(void *fdt, int nodeoffset, + unsigned addr_cells, unsigned size_cells, + unsigned num_regs, ...) +{ + uint32_t regs[num_regs*(addr_cells+size_cells)]; + be32 *cells = ®s[0]; + int i; + va_list ap; + uint64_t base, size; + + va_start(ap, num_regs); + for (i = 0 ; i < num_regs; i++) { + base = addr_cells ? va_arg(ap, uint64_t) : 0; + size = size_cells ? va_arg(ap, uint64_t) : 0; + set_range(&cells, addr_cells, size_cells, base, size); + } + va_end(ap); + + return fdt_setprop_inplace(fdt, nodeoffset, "reg", regs, sizeof(regs)); +} + static int make_root_properties(libxl__gc *gc, const libxl_version_info *vers, void *fdt) @@ -1209,6 +1230,8 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc, const struct xc_dom_seg *ramdisk = dom->ramdisk_blob ? &dom->ramdisk_seg : NULL; + const struct xc_dom_seg *acpi = dom->acpitable_blob ? + &dom->acpi_seg : NULL; if (ramdisk) { int chosen, res; @@ -1238,6 +1261,23 @@ int libxl__arch_domain_finalise_hw_description(libxl__gc *gc, } + if (acpi) + { + int module, res; + + module = fdt_path_offset(fdt, "/chosen/modules/module@0"); + assert(module > 0); + + LOG(DEBUG, "/chosen/modules/module@0 updating acpi properties to cover " + "%"PRIx64"-%"PRIx64, + acpi->vstart, acpi->vend); + + res = fdt_property_inplace_regs(fdt, module, ROOT_ADDRESS_CELLS, + ROOT_SIZE_CELLS, 1, acpi->vstart, + acpi->vend - acpi->vstart + 1); + assert(!res); + } + for (i = 0; i < GUEST_RAM_BANKS; i++) { const uint64_t size = (uint64_t)dom->rambank_size[i] << XC_PAGE_SHIFT;