From patchwork Thu Sep 22 12:52:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 76777 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp14718qgf; Thu, 22 Sep 2016 05:55:18 -0700 (PDT) X-Received: by 10.107.159.138 with SMTP id i132mr2760893ioe.177.1474548918569; Thu, 22 Sep 2016 05:55:18 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id c21si1800311itb.71.2016.09.22.05.55.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Sep 2016 05:55:18 -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 1bn3VP-00044J-0V; Thu, 22 Sep 2016 12:53:35 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bn3VN-00042q-Gj for xen-devel@lists.xen.org; Thu, 22 Sep 2016 12:53:33 +0000 Received: from [85.158.137.68] by server-4.bemta-3.messagelabs.com id 7D/69-15788-C44D3E75; Thu, 22 Sep 2016 12:53:32 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrJIsWRWlGSWpSXmKPExsVSPpHPSdfnyuN wg5/rhSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1owncyewFUwSqvj34gB7A+N8vi5GLg4hgVOM EjsXtLJDOHsYJb6t6QJyODnYBLQkzk//AWaLCMhKrO6aA1bELHCdUeLO+22sIAlhATuJczc+M IHYLAKqEssOnmUGsXkFPCTu/HrPCGJLCGhIrOydwAJicwp4Skw4sh6sVwioZuWVhawQ9YISJ2 c+AathFpCQOPjiBTNEr6JE2/qTbBC2pMTBFTdYQI6QADl77fPtUAtMJSY17WCfwCg4C8msWUh mLWBkWsWoUZxaVJZapGtkoZdUlJmeUZKbmJmja2hgrJebWlycmJ6ak5hUrJecn7uJERik9QwM jDsY20/4HWKU5GBSEuW90P84XIgvKT+lMiOxOCO+qDQntfgQowwHh5IE7+NLQDnBotT01Iq0z BxgvMCkJTh4lER4iy8DpXmLCxJzizPTIVKnGBWlxHl/g/QJgCQySvPg2mAxeolRVkqYl5GBgU GIpyC1KDezBFX+FaM4B6OSMO9NkCk8mXklcNNfAS1mAlq85ecDkMUliQgpqQbGJQmlp450vpj q2P79l2lo5f+gcrefud9kIwIZCpat0tZSOxn/ZFvz0q2b9CVZu0wtJs5Zurf6Aqf+75/XfUT8 l8ofn1d3X6m0xib1z0KjRq0tDueXci/7a73n11S1zZv9WyeabsiXX3ahWp83bIPP5N74ZJOpP I6OXLFSN2olV5xTmFk1KyFJiaU4I9FQi7moOBEAezkrHswCAAA= X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-3.tower-31.messagelabs.com!1474548809!62117906!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 24242 invoked from network); 22 Sep 2016 12:53:31 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-3.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 22 Sep 2016 12:53:31 -0000 Received: from 172.24.1.47 (EHLO szxeml431-hub.china.huawei.com) ([172.24.1.47]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CIG48118; Thu, 22 Sep 2016 20:53:00 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml431-hub.china.huawei.com (10.82.67.208) with Microsoft SMTP Server id 14.3.235.1; Thu, 22 Sep 2016 20:52:52 +0800 From: z00226004 To: Date: Thu, 22 Sep 2016 20:52:22 +0800 Message-ID: <1474548753-12596-6-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1474548753-12596-1-git-send-email-zhaoshenglong@huawei.com> References: <1474548753-12596-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.57E3D42E.003D, 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: 839f2bd510c4a3f2c6a1a03497de03a8 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 v6 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 Acked-by: Julien Grall --- tools/libxl/libxl_arm_acpi.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c index 1dbd7e5..421128a 100644 --- a/tools/libxl/libxl_arm_acpi.c +++ b/tools/libxl/libxl_arm_acpi.c @@ -34,6 +34,10 @@ extern const unsigned char dsdt_anycpu_arm[]; _hidden extern const int dsdt_anycpu_arm_len; +#define ACPI_OEM_ID "Xen" +#define ACPI_OEM_TABLE_ID "ARM" +#define ACPI_ASL_COMPILER_ID "XL" + enum { RSDP, XSDT, @@ -126,6 +130,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_OEM_ID, 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) @@ -151,6 +186,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;