From patchwork Tue Jul 5 03:12:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 71381 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp91493qgy; Mon, 4 Jul 2016 20:17:58 -0700 (PDT) X-Received: by 10.36.103.4 with SMTP id u4mr11577299itc.88.1467688677963; Mon, 04 Jul 2016 20:17:57 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 139si441947itx.73.2016.07.04.20.17.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Jul 2016 20:17:57 -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 1bKGpq-0000jx-0K; Tue, 05 Jul 2016 03:15:42 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKGpp-0000jJ-3O for xen-devel@lists.xen.org; Tue, 05 Jul 2016 03:15:41 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id F8/2D-20705-C562B775; Tue, 05 Jul 2016 03:15:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGIsWRWlGSWpSXmKPExsVSPpHPUTdarTr coOOEtcWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmnH25myWghMCFV/uTWdsYGzg7WLk4hASOMUo sX/iCkYIZzejRMe0pUAOJwebgK7Ex41T2EFsEQFZidVdc8BsZoEPjBKnZkuA2MICdhJPv7Sxg tgsAioSk44fYe5i5ODgFfCQeDEpHSQsIaAhsbJ3AguIzSngKfH1JoQtBFTSf2A9WCuvgKDEyZ lPWCDGS0gcfPGCGaJXUaJt/Uk2CFtS4uCKGywQNtDRH5e6QdimEgc332KawCg4C8moWUhGLWB kWsWoUZxaVJZapGtkqZdUlJmeUZKbmJmja2hgrJebWlycmJ6ak5hUrJecn7uJERie9QwMjDsY m/b6HWKU5GBSEuV99a8qXIgvKT+lMiOxOCO+qDQntfgQowwHh5IE71qV6nAhwaLU9NSKtMwcY KTApCU4eJREeJ+BpHmLCxJzizPTIVKnGBWlxHkXgCQEQBIZpXlwbbDovMQoKyXMy8jAwCDEU5 BalJtZgir/ilGcg1FJmPcFyBSezLwSuOmvgBYzAS1mjS0HWVySiJCSamCc2PZHRSL2oPbMW2I PXsSeW1YV8DGN5Wxm0a5/j53f/hCxvcBqUXzpQ1tZsYv6fZPkLMdAxRPuL/ZIyrxteaTKZ6Cp 9F8lWTjq1fe3VzPKY+rqn9UV5vgs27rrAPfnsG0iTLPOx6zhu/15IrP0VH3n4/VVG46GrfrWo /V9VYZzRR7Dk3zzRepKLMUZiYZazEXFiQDuiUT6yQIAAA== X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-7.tower-31.messagelabs.com!1467688532!41293642!1 X-Originating-IP: [119.145.14.65] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NSA9PiA3NzQ2Mw==\n X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 31014 invoked from network); 5 Jul 2016 03:15:39 -0000 Received: from unknown (HELO szxga02-in.huawei.com) (119.145.14.65) by server-7.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 5 Jul 2016 03:15:39 -0000 Received: from 172.24.1.47 (EHLO SZXEML429-HUB.china.huawei.com) ([172.24.1.47]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DJT71993; Tue, 05 Jul 2016 11:14:08 +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:13:59 +0800 From: Shannon Zhao To: Date: Tue, 5 Jul 2016 11:12:37 +0800 Message-ID: <1467688367-17320-8-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.0A020205.577B2600.0092, 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: 5f6b5bfab036035700baca9de9897f55 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 07/17] libxl/arm: Construct ACPI RSDP table 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 Construct ACPI RSDP table and add a helper to calculate the ACPI table checksum. Signed-off-by: Shannon Zhao --- tools/libxl/libxl_arm_acpi.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c index 7a59126..9df1573 100644 --- a/tools/libxl/libxl_arm_acpi.c +++ b/tools/libxl/libxl_arm_acpi.c @@ -33,6 +33,9 @@ extern const unsigned char dsdt_anycpu_arm[]; _hidden extern const int dsdt_anycpu_arm_len; +#define ACPI_BUILD_APPNAME6 "XenARM" +#define ACPI_BUILD_APPNAME4 "Xen " + enum { RSDP, XSDT, @@ -109,6 +112,36 @@ static int libxl__estimate_acpi_size(libxl__gc *gc, return 0; } +static void calculate_checksum(void *table, uint32_t checksum_offset, + uint32_t length) +{ + uint8_t *p, sum = 0; + + p = table; + p[checksum_offset] = 0; + + while ( length-- ) + sum = sum + *p++; + + p = table; + p[checksum_offset] = -sum; +} + +static void make_acpi_rsdp(libxl__gc *gc, struct xc_dom_image *dom, + struct acpitable acpitables[]) +{ + uint64_t offset = acpitables[RSDP].addr - GUEST_ACPI_BASE; + struct acpi_table_rsdp *rsdp = dom->acpitable_blob + offset; + + memcpy(rsdp->signature, "RSD PTR ", sizeof(rsdp->signature)); + memcpy(rsdp->oem_id, ACPI_BUILD_APPNAME6, sizeof(rsdp->oem_id)); + rsdp->length = acpitables[RSDP].size; + rsdp->revision = 0x02; + rsdp->xsdt_physical_address = acpitables[XSDT].addr; + calculate_checksum(rsdp, offsetof(struct acpi_table_rsdp, checksum), + acpitables[RSDP].size); +} + int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, libxl__domain_build_state *state, struct xc_dom_image *dom) @@ -134,6 +167,8 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, if (rc) return rc; + make_acpi_rsdp(gc, dom, acpitables); + return 0; }