From patchwork Tue May 31 05:02:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 68883 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1732577qge; Mon, 30 May 2016 22:05:26 -0700 (PDT) X-Received: by 10.159.37.66 with SMTP id 60mr14030886uaz.130.1464671119432; Mon, 30 May 2016 22:05:19 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id e123si22887783vka.74.2016.05.30.22.05.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 22:05: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; 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 1b7bqP-0003EQ-0M; Tue, 31 May 2016 05:03:57 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b7bqN-0003Dr-SU for xen-devel@lists.xen.org; Tue, 31 May 2016 05:03:55 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id 52/8B-06230-B3B1D475; Tue, 31 May 2016 05:03:55 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRWlGSWpSXmKPExsVSPpHPUddK2jf cYN4fDYslHxezODB6HN39mymAMYo1My8pvyKBNaPv2w/GghcyFSsv9jM2MDaJdTFycQgJnGGU mHtqChOEs4dR4t7re4xdjJwcbAK6Eh83TmEHsUUEZCVWd81hByliFtjIKPHk7Vc2kISwgJNEy /X/YA0sAqoSc7avY+1i5ODgFfCQ2L06DiQsIaAhsbJ3AguIzSngKXHk43MwWwiopLVxB1grr4 CgxMmZT8DizAISEgdfvGCG6FWUaFt/kg3ClpQ4uOIGC8gNEgKnGCVmH2tmgUiYSnz68od9AqP gLCSzZiGZtYCRaRWjenFqUVlqka6xXlJRZnpGSW5iZo6uoYGZXm5qcXFiempOYlKxXnJ+7iZG YIAyAMEOxo5/TocYJTmYlER5rX77hAvxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4D0g6RsuJFiUm p5akZaZA4wVmLQEB4+SCO8+kDRvcUFibnFmOkTqFKOilDjvW5CEAEgiozQPrg0Wn5cYZaWEeR mBDhHiKUgtys0sQZV/xSjOwagkzDsZZApPZl4J3PRXQIuZgBbHZ/iALC5JREhJNTAy/m9hzw9 Ut93bxK+5ds+TfdPmpn4VYox26rjGY3egJ0L0FmexjoLrkXNqpip37v7wnCzJNfXS0p70RW/V duTYmS/coPQkd9L8PUFt7myBbALhst/E1lnl3hbJ7fLYN8lGpmT7t4cxxmUinQuvOX58k8ven bffzYWTRWC/odnO9S0hxS3zC5RYijMSDbWYi4oTAel7NyfKAgAA X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-8.tower-21.messagelabs.com!1464671030!16563625!1 X-Originating-IP: [119.145.14.65] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTE5LjE0NS4xNC42NSA9PiA3NzQ2Mw==\n X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19394 invoked from network); 31 May 2016 05:03:53 -0000 Received: from szxga02-in.huawei.com (HELO szxga02-in.huawei.com) (119.145.14.65) by server-8.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 31 May 2016 05:03:53 -0000 Received: from 172.24.1.137 (EHLO SZXEML429-HUB.china.huawei.com) ([172.24.1.137]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DHY49916; Tue, 31 May 2016 13:03:37 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by SZXEML429-HUB.china.huawei.com (10.82.67.184) with Microsoft SMTP Server id 14.3.235.1; Tue, 31 May 2016 13:03:27 +0800 From: Shannon Zhao To: Date: Tue, 31 May 2016 13:02:57 +0800 Message-ID: <1464670986-10256-6-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1464670986-10256-1-git-send-email-zhaoshenglong@huawei.com> References: <1464670986-10256-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.574D1B2A.008F, 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: 89b7a54f2b727a56ff4cba748b3ed5d6 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 Subject: [Xen-devel] [PATCH RESEND 05/14] libxl/arm: Construct ACPI GTDT 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 GTDT table with the interrupt information of timers. Signed-off-by: Shannon Zhao --- tools/libxl/libxl_arm.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index 9e99159..0fb4f69 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -3,6 +3,7 @@ #include "libxl_libfdt_compat.h" #include +#include #include #include #include @@ -880,13 +881,85 @@ out: return rc; } +static void make_acpi_header(struct acpi_table_header *h, const char *sig, + int len, uint8_t rev) +{ + memcpy(&h->signature, sig, 4); + h->length = len; + h->revision = rev; + memcpy(h->oem_id, ACPI_BUILD_APPNAME6, 6); + memcpy(h->oem_table_id, ACPI_BUILD_APPNAME4, 4); + memcpy(h->oem_table_id + 4, sig, 4); + h->oem_revision = 1; + memcpy(h->asl_compiler_id, ACPI_BUILD_APPNAME4, 4); + h->asl_compiler_revision = 1; + h->checksum = 0; +} + +static void make_acpi_gtdt(libxl__gc *gc, struct xc_dom_image *dom) +{ + struct acpi_gtdt_descriptor *gtdt; + + gtdt = libxl__zalloc(gc, sizeof(*gtdt)); + + gtdt->secure_el1_interrupt = GUEST_TIMER_PHYS_S_PPI; + gtdt->secure_el1_flags = (ACPI_LEVEL_SENSITIVE << ACPI_GTDT_INTERRUPT_MODE) + |(ACPI_ACTIVE_LOW << ACPI_GTDT_INTERRUPT_POLARITY); + gtdt->non_secure_el1_interrupt = GUEST_TIMER_PHYS_NS_PPI; + gtdt->non_secure_el1_flags = + (ACPI_LEVEL_SENSITIVE << ACPI_GTDT_INTERRUPT_MODE) + |(ACPI_ACTIVE_LOW << ACPI_GTDT_INTERRUPT_POLARITY); + gtdt->virtual_timer_interrupt = GUEST_TIMER_VIRT_PPI; + gtdt->virtual_timer_flags = + (ACPI_LEVEL_SENSITIVE << ACPI_GTDT_INTERRUPT_MODE) + |(ACPI_ACTIVE_LOW << ACPI_GTDT_INTERRUPT_POLARITY); + + make_acpi_header(>dt->header, "GTDT", sizeof(*gtdt), 2); + + dom->acpitable_blob->gtdt.table = (void *)gtdt; + /* Align to 64bit. */ + dom->acpitable_blob->gtdt.size = sizeof(*gtdt); + dom->acpitable_size += dom->acpitable_blob->gtdt.size; +} + +static int prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, + libxl__domain_build_state *state, + struct xc_dom_image *dom) +{ + const libxl_version_info *vers; + + /* convenience aliases */ + xc_domain_configuration_t *xc_config = &state->config; + + vers = libxl_get_version_info(CTX); + if (vers == NULL) + return ERROR_FAIL; + + LOG(DEBUG, "constructing ACPI tables for Xen version %d.%d guest", + vers->xen_version_major, vers->xen_version_minor); + + /* Alloc memory for ACPI blob placeholders. */ + dom->acpitable_blob = libxl__zalloc(gc, sizeof(struct acpitable_blob)); + dom->acpitable_size = 0; + + make_acpi_gtdt(gc, dom); + + return 0; +} + int libxl__arch_domain_init_hw_description(libxl__gc *gc, libxl_domain_build_info *info, libxl__domain_build_state *state, struct xc_dom_image *dom) { + int rc; + assert(info->type == LIBXL_DOMAIN_TYPE_PV); - return prepare_dtb(gc, info, state, dom); + rc = prepare_dtb(gc, info, state, dom); + if (rc) + return rc; + + return prepare_acpi(gc, info, state, dom); } static void finalise_one_memory_node(libxl__gc *gc, void *fdt,