From patchwork Thu Jun 23 03:17:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 70724 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp217574qgy; Wed, 22 Jun 2016 20:21:48 -0700 (PDT) X-Received: by 10.107.14.71 with SMTP id 68mr46602154ioo.47.1466652108910; Wed, 22 Jun 2016 20:21:48 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id 73si5352094ios.61.2016.06.22.20.21.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jun 2016 20:21:48 -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 1bFvBN-0001RY-Vj; Thu, 23 Jun 2016 03:19:57 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFvBM-0001QG-4L for xen-devel@lists.xen.org; Thu, 23 Jun 2016 03:19:56 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id 17/E4-03780-B555B675; Thu, 23 Jun 2016 03:19:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVi9XuGg25UaHa 4wbI+Q4slHxezODB6HN39mymAMYo1My8pvyKBNWPttSXsBesVK47+7WFtYLwv1cXIxSEkcIpR 4uSWlywQzh5GiX0n1jN2MXJysAnoSnzcOIUdxBYRkJVY3TWHHaSIWeA6o8Sd99tYQRLCAp4SL 59fYwKxWQRUJXoezQOL8wp4SOy/9ZANxJYQ0JBY2TuBBcTmBIqfnPWEGcQWEnCXmLNmLwtEva DEyZlPwGxmAQmJgy9eMEP0Kkq0rT8JNUdS4uCKGywQNtDZt97GQdimEn+PXWOdwCg4C8moWUh GLWBkWsWoXpxaVJZapGupl1SUmZ5RkpuYmaNraGCsl5taXJyYnpqTmFSsl5yfu4kRGKD1DAyM Oxhf/3Q6xCjJwaQkymvlkB0uxJeUn1KZkVicEV9UmpNafIhRhoNDSYJXIwQoJ1iUmp5akZaZA 4wVmLQEB4+SCK8zSJq3uCAxtzgzHSJ1ilFRSpz3UDBQQgAkkVGaB9cGi89LjLJSwryMDAwMQj wFqUW5mSWo8q8YxTkYlYR574FM4cnMK4Gb/gpoMRPQ4mX96SCLSxIRUlINjDO+rvHe+7vCXXN NQKO32SPHhgIu/4X/z+6xfDXr7p49zJHTzDKOzQqT4Hk2OfsT61rrbU5Pjtfecz3dxWY+/e4s vqzza7/cs3qj1iz/bNFq2w6J6ZYhjj+kxNOby5icdxc/2T7N3FDDf7nOua/brXoZFuhMtsjcO lHiRKPcgddLZfMkzR4aHVNiKc5INNRiLipOBACHZe6sygIAAA== X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-13.tower-31.messagelabs.com!1466651989!46137820!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.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8952 invoked from network); 23 Jun 2016 03:19:53 -0000 Received: from szxga01-in.huawei.com (HELO szxga01-in.huawei.com) (58.251.152.64) by server-13.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 23 Jun 2016 03:19:53 -0000 Received: from 172.24.1.36 (EHLO szxeml430-hub.china.huawei.com) ([172.24.1.36]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DMQ09541; Thu, 23 Jun 2016 11:17:44 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml430-hub.china.huawei.com (10.82.67.185) with Microsoft SMTP Server id 14.3.235.1; Thu, 23 Jun 2016 11:17:34 +0800 From: Shannon Zhao To: Date: Thu, 23 Jun 2016 11:17:00 +0800 Message-ID: <1466651824-6964-14-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1466651824-6964-1-git-send-email-zhaoshenglong@huawei.com> References: <1466651824-6964-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.0A020204.576B54D9.00E9, 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: 27977b97d06355b26de961b0e3a35270 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 v2 13/17] libxl/arm: Link all ACPI tables into one buffer 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 Link all ACPI tables into one buffer, fill in the addresses of tables and update checksum of each table. Reserve a memory map space for ACPI tables. Signed-off-by: Shannon Zhao --- tools/libxl/libxl_arm_acpi.c | 58 +++++++++++++++++++++++++++++++++++++++++++ xen/include/public/arch-arm.h | 4 +++ 2 files changed, 62 insertions(+) diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c index d8779af..263b5de 100644 --- a/tools/libxl/libxl_arm_acpi.c +++ b/tools/libxl/libxl_arm_acpi.c @@ -285,6 +285,63 @@ static void calculate_checksum(void *table, uint32_t checksum_offset, p[checksum_offset] = -sum; } +static void link_acpi_tables(libxl__gc *gc, struct xc_dom_image *dom) +{ + uint64_t offset = 0; + struct acpi_table_xsdt *xsdt; + struct acpi_table_rsdp *rsdp; + struct acpi_table_fadt *fadt; + + assert(dom->acpitable_size <= GUEST_ACPI_SIZE); + dom->acpitable_blob = libxl__zalloc(gc, dom->acpitable_size); + + rsdp = (struct acpi_table_rsdp *)(dom->acpitable_blob + offset); + memcpy(dom->acpitable_blob + offset, acpitables[RSDP].table, + acpitables[RSDP].size); + offset += ROUNDUP(acpitables[RSDP].size, 3); + + xsdt = (struct acpi_table_xsdt *)(dom->acpitable_blob + offset); + memcpy(dom->acpitable_blob + offset, acpitables[XSDT].table, + acpitables[XSDT].size); + rsdp->xsdt_physical_address = GUEST_ACPI_BASE + offset; + calculate_checksum(rsdp, offsetof(struct acpi_table_header, checksum), + acpitables[RSDP].size); + offset += ROUNDUP(acpitables[XSDT].size, 3); + + memcpy(dom->acpitable_blob + offset, acpitables[MADT].table, + acpitables[MADT].size); + calculate_checksum(dom->acpitable_blob + offset, + offsetof(struct acpi_table_header, checksum), + acpitables[MADT].size); + xsdt->table_offset_entry[0] = GUEST_ACPI_BASE + offset; + offset += ROUNDUP(acpitables[MADT].size, 3); + + memcpy(dom->acpitable_blob + offset, acpitables[GTDT].table, + acpitables[GTDT].size); + calculate_checksum(dom->acpitable_blob + offset, + offsetof(struct acpi_table_header, checksum), + acpitables[GTDT].size); + xsdt->table_offset_entry[1] = GUEST_ACPI_BASE + offset; + offset += ROUNDUP(acpitables[GTDT].size, 3); + + fadt = (struct acpi_table_fadt *)(dom->acpitable_blob + offset); + memcpy(dom->acpitable_blob + offset, acpitables[FADT].table, + acpitables[FADT].size); + xsdt->table_offset_entry[2] = GUEST_ACPI_BASE + offset; + calculate_checksum(xsdt, offsetof(struct acpi_table_header, checksum), + acpitables[XSDT].size); + offset += ROUNDUP(acpitables[FADT].size, 3); + + memcpy(dom->acpitable_blob + offset, acpitables[DSDT].table, + acpitables[DSDT].size); + calculate_checksum(dom->acpitable_blob + offset, + offsetof(struct acpi_table_header, checksum), + acpitables[DSDT].size); + fadt->dsdt = GUEST_ACPI_BASE + offset; + calculate_checksum(fadt, offsetof(struct acpi_table_header, checksum), + acpitables[FADT].size); +} + int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, libxl__domain_build_state *state, struct xc_dom_image *dom) @@ -314,6 +371,7 @@ int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, make_acpi_fadt(gc, dom); make_acpi_dsdt(gc, dom); + link_acpi_tables(gc, dom); return 0; } diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index 05e4a58..0911d16 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -407,6 +407,10 @@ typedef uint64_t xen_callback_t; #define GUEST_GICV3_GICR0_BASE 0x03020000ULL /* vCPU0 - vCPU127 */ #define GUEST_GICV3_GICR0_SIZE 0x01000000ULL +/* ACPI tables physical address */ +#define GUEST_ACPI_BASE 0x20000000ULL +#define GUEST_ACPI_SIZE 0x00200000ULL + /* * 16MB == 4096 pages reserved for guest to use as a region to map its * grant table in.