From patchwork Tue May 31 05:03:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 68887 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1732678qge; Mon, 30 May 2016 22:05:43 -0700 (PDT) X-Received: by 10.237.58.39 with SMTP id n36mr11586008qte.37.1464671143812; Mon, 30 May 2016 22:05:43 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id v123si12054289qhe.4.2016.05.30.22.05.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 22:05:43 -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 1b7bqz-0003hq-Or; Tue, 31 May 2016 05:04:33 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b7bqy-0003h5-KN for xen-devel@lists.xen.org; Tue, 31 May 2016 05:04:32 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id C5/FB-06230-06B1D475; Tue, 31 May 2016 05:04:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVSPpHPSTde2jf cYPkBLYslHxezODB6HN39mymAMYo1My8pvyKBNePO5V7Ggq1yFf8O/WBtYDwu1sXIySEkcIpR YmKbXxcjF5C9h1Hi0sQf7CAJNgFdiY8bp4DZIgKyEqu75rCDFDELbGSUePL2KxtIQlggWOL4n CdMIDaLgKpEz6prLCA2r4CnxIX3F1hBbAkBDYmVvRPA4pxA8SMfn7NAbPaQaG3cwQhRLyhxcu YTsDizgITEwRcvmCF6FSXa1p9kg7AlJQ6uuMECcoQEyNW/dy5mh0iYSnw69ZF1AqPgLCSzZiG ZtYCRaRWjenFqUVlqka6xXlJRZnpGSW5iZo6uoYGZXm5qcXFiempOYlKxXnJ+7iZGYIAyAMEO xo5/TocYJTmYlER5rX77hAvxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4NWV8g0XEixKTU+tSMvMA cYKTFqCg0dJhPenJFCat7ggMbc4Mx0idYpRUUqcNx6kTwAkkVGaB9cGi89LjLJSwryMQIcI8R SkFuVmlqDKv2IU52BUEuY9BzKeJzOvBG76K6DFTECL4zN8QBaXJCKkpBoYHY0Lo42nL92z+bP 1V5Hcc7KZF05d+mmQU2X1x7i9rlm2L80yl+H31l13LxoaSxZ3yzxaeyrN8sSiibyRCTzX/XR3 P/SddOeAMPNcs4ff1gU9ua54RuKh99ul7Vz/XzAeqpusFp6ruW//uwMTXfJvnz63xZxJWPOwd 9OsQ+EfVi1b5eJY5+d2UImlOCPRUIu5qDgRAPXr8ZXKAgAA X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-3.tower-21.messagelabs.com!1464671058!16072553!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 21932 invoked from network); 31 May 2016 05:04:30 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-3.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 31 May 2016 05:04:30 -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 CCK68374; Tue, 31 May 2016 13:03:42 +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:33 +0800 From: Shannon Zhao To: Date: Tue, 31 May 2016 13:03:05 +0800 Message-ID: <1464670986-10256-14-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.0A020203.574D1B2F.0026, 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: f7ce12a6311b89ad7e5589de078c14a3 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 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;