From patchwork Fri Sep 2 02:55:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 75275 Delivered-To: patch@linaro.org Received: by 10.140.29.8 with SMTP id a8csp623879qga; Thu, 1 Sep 2016 19:59:09 -0700 (PDT) X-Received: by 10.202.190.85 with SMTP id o82mr17621448oif.72.1472785135440; Thu, 01 Sep 2016 19:58:55 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id y5si10180265otb.6.2016.09.01.19.58.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Sep 2016 19:58:55 -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 1bfeen-0006pr-S8; Fri, 02 Sep 2016 02:56:41 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bfeen-0006pW-7a for xen-devel@lists.xen.org; Fri, 02 Sep 2016 02:56:41 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id E6/0F-05127-86AE8C75; Fri, 02 Sep 2016 02:56:40 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVi9XuGg276qxP hBp33dS2WfFzM4sDocXT3b6YAxijWzLyk/IoE1owtX6eyFDwRrNh7ejlbA+NX3i5GLg4hgVOM EkeOf2KDcHYzSjxsWQrkcHKwCehKfNw4hR3EFhGQlVjdNYcdpIhZ4DqjxJ3321hBEsICdhLbL 39i6WLk4GARUJHoe6gIEuYV8JDYOWURI4gtIaAhsbJ3AguIzSngKfF21SewmUJANY9fPWKCqB eUODnzCVgNs4CExMEXL5ghehUl2tafZIOwJSUOrrjBAmEDXd3WVQdhm0r0H3nPPIFRcBaSUbO QjFrAyLSKUaM4tagstUjXyFQvqSgzPaMkNzEzR9fQwFQvN7W4ODE9NScxqVgvOT93EyMwQOsZ GBh3MO5q9zvEKMnBpCTKm//kRLgQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCV6jl0A5waLU9NSKt MwcYKzApCU4eJREeM1A0rzFBYm5xZnpEKlTjIpS4rwvXgAlBEASGaV5cG2w+LzEKCslzMvIwM AgxFOQWpSbWYIq/4pRnINRSZg3AGQ8T2ZeCdz0V0CLmYAWl1w7DrK4JBEhJdXA6LnvvVb8bMG crWpnYl34jJdP26r0Zvf2No0jYo+tljWfzfe+oJKm1FR6pJ1TizntePAuNabJ+18u9wvrPTPP 9efcSafmPZrxge/kX8Y7Wbf+1Gadn95c6W+/IXDVvZX/mP+Kvlkpe2634bX/32z8ti58YxS+1 FXabfG3JcYzD3uXGMQdP/fHYr0SS3FGoqEWc1FxIgAc8FGNygIAAA== X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-8.tower-206.messagelabs.com!1472784995!57265341!1 X-Originating-IP: [58.251.152.64] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 49248 invoked from network); 2 Sep 2016 02:56:39 -0000 Received: from szxga01-in.huawei.com (HELO szxga01-in.huawei.com) (58.251.152.64) by server-8.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 2 Sep 2016 02:56:39 -0000 Received: from 172.24.1.60 (EHLO szxeml431-hub.china.huawei.com) ([172.24.1.60]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DQM36291; Fri, 02 Sep 2016 10:56:13 +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; Fri, 2 Sep 2016 10:56:02 +0800 From: Shannon Zhao To: Date: Fri, 2 Sep 2016 10:55:28 +0800 Message-ID: <1472784939-14404-6-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1472784939-14404-1-git-send-email-zhaoshenglong@huawei.com> References: <1472784939-14404-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.0A0B0207.57C8EA4E.00EA, 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: dace08acce0fedf31434d77e816904d8 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 v5 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 b91f3f6..83ad954 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;