From patchwork Thu Sep 29 01:18:51 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 77111 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp79909qgf; Wed, 28 Sep 2016 18:22:19 -0700 (PDT) X-Received: by 10.107.201.139 with SMTP id z133mr185587iof.156.1475112139544; Wed, 28 Sep 2016 18:22:19 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id u185si12567901itc.12.2016.09.28.18.22.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Sep 2016 18:22:19 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org; 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; dmarc=fail (p=NONE dis=NONE) header.from=linaro.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 1bpQ0l-0001MK-E4; Thu, 29 Sep 2016 01:19:43 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpQ0j-0001Ly-VV for xen-devel@lists.xen.org; Thu, 29 Sep 2016 01:19:42 +0000 Received: from [85.158.139.211] by server-7.bemta-5.messagelabs.com id E3/1C-05127-D2C6CE75; Thu, 29 Sep 2016 01:19:41 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrOIsWRWlGSWpSXmKPExsVyMfTAWl3tnDf hBsv2q1os+biYxYHR4+ju30wBjFGsmXlJ+RUJrBkfv29hL7gqWLFv1WvGBsZ/vF2MXBxCAhMZ JXrvP2LqYuTkYBGYxyyxbqUGSEJCoJ9V4tv0n4wgCQmBGInPXU9ZIOwqiWNX25lBbCEBNYllh xcyQ0xqYpJ4vmoNK0iCTUBH4sWknWwgtoiAtMS1z5cZQYqYBY4wStyafxKsW1jATmLxv3ZGiN WqElvnfQNr4BWwlrg/bQETxDZNiemzXoPVcwrYSHxo+QW12Vpi2bfNLBMYBRYwMqxi1ChOLSp LLdI1MtFLKspMzyjJTczM0TU0MNXLTS0uTkxPzUlMKtZLzs/dxAgMrnoGBsYdjDcn+x1ilORg UhLl5fR5Ey7El5SfUpmRWJwRX1Sak1p8iFGGg0NJgvdKFlBOsCg1PbUiLTMHGOYwaQkOHiUR3 lcgad7igsTc4sx0iNQpRmOOLb+vrWXi2Db13lomIZa8/LxUKXHeBJBSAZDSjNI8uEGw+LvEKC slzMvIwMAgxFOQWpSbWYIq/4pRnINRSZj3NcgUnsy8Erh9r4BOYQI6ZemJFyCnlCQipKQaGAM XTFvY/Zjx2uT7svfvnrt4yY47vyDb8I091y53ca5I9TP3lt3af0gv75v596CZa283xbo//pGy R3fG7PsqWkvMctyiF91lLyi8+NNgqk7FodrY239ZrvAZpT8rF7sb+sT0rkL+1It/E3Yt+Wr06 0cI72vnJw9sgr8VfBP55bJBedsbHp5LZiJKLMUZiYZazEXFiQDelIgZugIAAA== X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-3.tower-206.messagelabs.com!1475111978!58491924!1 X-Originating-IP: [209.85.192.173] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 64452 invoked from network); 29 Sep 2016 01:19:39 -0000 Received: from mail-pf0-f173.google.com (HELO mail-pf0-f173.google.com) (209.85.192.173) by server-3.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 29 Sep 2016 01:19:39 -0000 Received: by mail-pf0-f173.google.com with SMTP id q2so22842663pfj.3 for ; Wed, 28 Sep 2016 18:19:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=QnIqXSDg2Cdk8q+f7lMLydkJ6xIIIp+SKUFfFOlzVes=; b=hR0pcUaf7wUyRejjM7JksntfzLOXZsg2ahYBeIR/v2Y4nrg7C6TI1QdmpLUmG3wCbA iiArgbmRcbKrNIDa6pxWkYWX9h951Fy0OmqtYNgVmdyMtuDZG1lcLiRXmMWhcA9vMhTt us0bpl9snVmn8E6mGLs8ffyZiO9aLJvWtj2ws= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=QnIqXSDg2Cdk8q+f7lMLydkJ6xIIIp+SKUFfFOlzVes=; b=a1qakuW7+/q8D8sy8qvXLNnA4mZs4MpISI/5qAEC8Z5HKU19MOG6UWKF+WLFdFipEz AG7dv/cCDKfPAvi5KTS6SET0m8DeOBuL3G+9hziXtlLt0zVEkkZwqM07gTW+Al6ul0X5 R/aUFE8AcWgRqUy+GNhecqnqfregEP7+6Wo1QV6XRHcHmGTVTx7Bzy5xps3nOfr3gEn2 E1yaRms2nxotc3CgsjN8AkGZoI/+PdAR4WRpVBdaD6CSQNGpM6gXVXSXiW38Jnx7AMJU 0do8fvSzh4kDsYC8n9cnSJHLtIC270yfzePMyGUzeYYQo8+SW1WbMDG6kjz4jRlRnsCY nU6g== X-Gm-Message-State: AE9vXwOg0D3Q/0BJtHYZLLLVfCZ9Nl7gkdkje1fbJrnxC0ti3ryVcZgv19LOw1HsCeYNbcse X-Received: by 10.98.223.218 with SMTP id d87mr62970264pfl.48.1475111977879; Wed, 28 Sep 2016 18:19:37 -0700 (PDT) Received: from HZA160860128-A.china.huawei.com ([67.238.99.186]) by smtp.gmail.com with ESMTPSA id wd7sm15228744pab.2.2016.09.28.18.19.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Sep 2016 18:19:37 -0700 (PDT) From: Shannon Zhao To: xen-devel@lists.xen.org Date: Wed, 28 Sep 2016 18:18:51 -0700 Message-Id: <20160929011902.7784-6-shannon.zhao@linaro.org> X-Mailer: git-send-email 2.10.0.windows.1 In-Reply-To: <20160929011902.7784-1-shannon.zhao@linaro.org> References: <20160929011902.7784-1-shannon.zhao@linaro.org> Cc: sstabellini@kernel.org, wei.liu2@citrix.com, ian.jackson@eu.citrix.com, julien.grall@arm.com, Shannon Zhao , zhaoshenglong@huawei.com, boris.ostrovsky@oracle.com Subject: [Xen-devel] [PATCH v8 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" Construct ACPI RSDP table and add a helper to calculate the ACPI table checksum. Signed-off-by: Shannon Zhao Acked-by: Julien Grall Acked-by: Wei Liu --- 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 bc9ab84..0512630 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, struct xc_dom_image *dom) { @@ -147,6 +182,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__allocate_acpi_tables(gc, info, dom, acpitables); + if (rc) + goto out; + + make_acpi_rsdp(gc, dom, acpitables); out: return rc;