From patchwork Tue Aug 16 10:25:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 73999 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1919605qga; Tue, 16 Aug 2016 03:32:10 -0700 (PDT) X-Received: by 10.107.133.227 with SMTP id p96mr44661728ioi.71.1471343528850; Tue, 16 Aug 2016 03:32:08 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id d77si5335182ioj.122.2016.08.16.03.32.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Aug 2016 03:32:08 -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 1bZbdA-0002cG-Cp; Tue, 16 Aug 2016 10:30:00 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZbd8-0002aB-GG for xen-devel@lists.xen.org; Tue, 16 Aug 2016 10:29:58 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id 34/55-06162-52BE2B75; Tue, 16 Aug 2016 10:29:57 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVSPpHPSVf19aZ wg2+nOSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oxF3x8wFlwXrPjRsYaxgfEFbxcjF4eQwClG ief9x9ghnD2MEq3X/jJ2MXJysAnoSnzcOIUdxBYRkJVY3TUHrIhZ4DqjxJ3321hBEsICdhILr ncxgdgsAqoSl3+9YAaxeQU8JF7sXgwWlxDQkFjZO4Gli5GDg1PAU+LaFDaQsBBQyemZC1khyg UlTs58wgJiMwtISBx8ATFGQkBRom39STYIW1Li4IobLCA3SIBcffftGqgiU4lZJ7cyTmAUnIV k1iwksxYwMq1iVC9OLSpLLdI100sqykzPKMlNzMzRNTQw1stNLS5OTE/NSUwq1kvOz93ECAzQ egYGxh2MV9qcDzFKcjApifLOnLgxXIgvKT+lMiOxOCO+qDQntfgQowwHh5IEb9DLTeFCgkWp6 akVaZk5wFiBSUtw8CiJ8L4BSfMWFyTmFmemQ6ROMSpKifPKgSQEQBIZpXlwbbD4vMQoKyXMy8 jAwCDEU5BalJtZgir/ilGcg1FJGGI8T2ZeCdz0V0CLmYAW60tvAFlckoiQkmpgPDPryeltd1x XOj64Or06x51D/offkZaYbRK7fs/YwLQtU2dRXNkHjdXmOz6cvcKWoVKWffiKnvw55929a0/M 6tQzf3E85lwCR/LJIPMV3jNP3L2pWLA/b7KjNKvB1Dlbi5ivzXHlu9UkILPeMFjR0HS76+8Cx 2LON/t7r5xSmK70am+cVnTgISWW4oxEQy3mouJEAIo6/EDKAgAA X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-13.tower-31.messagelabs.com!1471343393!55197219!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.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 54108 invoked from network); 16 Aug 2016 10:29:56 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-13.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 16 Aug 2016 10:29:56 -0000 Received: from 172.24.1.47 (EHLO szxeml434-hub.china.huawei.com) ([172.24.1.47]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CGJ21736; Tue, 16 Aug 2016 18:26:20 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml434-hub.china.huawei.com (10.82.67.225) with Microsoft SMTP Server id 14.3.235.1; Tue, 16 Aug 2016 18:25:35 +0800 From: Shannon Zhao To: Date: Tue, 16 Aug 2016 18:25:02 +0800 Message-ID: <1471343113-10652-6-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1471343113-10652-1-git-send-email-zhaoshenglong@huawei.com> References: <1471343113-10652-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.57B2EA4D.00C8, 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: b21ad293ff5a1f627ba6a7d4bb72223f 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, boris.ostrovsky@oracle.com Subject: [Xen-devel] [PATCH v4 05/16] 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 | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c index 6be9eb0..9432e44 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, @@ -112,6 +115,37 @@ out: return rc; } +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 = (void *)dom->acpi_modules[0].data + 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, extended_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) @@ -137,6 +171,10 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, dom->acpi_modules[0].guest_addr_out = GUEST_ACPI_BASE; rc = libxl__estimate_acpi_size(gc, info, dom, xc_config, acpitables); + if (rc) + goto out; + + make_acpi_rsdp(gc, dom, acpitables); out: return rc;