From patchwork Tue May 31 04:43:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 68870 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1727927qge; Mon, 30 May 2016 21:51:04 -0700 (PDT) X-Received: by 10.31.209.71 with SMTP id i68mr2541131vkg.18.1464670264165; Mon, 30 May 2016 21:51:04 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id j190si22790509vkg.169.2016.05.30.21.51.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 30 May 2016 21:51:04 -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 1b7bcu-0000JI-LL; Tue, 31 May 2016 04:50:00 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1b7bct-0000Hw-Cn for xen-devel@lists.xen.org; Tue, 31 May 2016 04:49:59 +0000 Received: from [85.158.143.35] by server-3.bemta-6.messagelabs.com id B3/A2-25713-6F71D475; Tue, 31 May 2016 04:49:58 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBIsWRWlGSWpSXmKPExsVSPpHPSfebuG+ 4wda7ghZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa0bftx+MBS9kKlZe7GdsYGwS62Lk4hASOMMo sXjSFnYIZw+jxLZDX9i6GDk52AR0JT5unMIOYosIyEqs7poDVsQssIlRou3LRRaQhLCAtcTbl 7MZQWwWAVWJh0efMoPYvAIeEj0N/8HiEgIaEit7J4DVcwp4Spyf+BKsRgioZt+y04wQ9YISJ2 c+AathFpCQOPjiBTNEr6JE2/qTbBC2pMTBFTdYQI6QEDjFKLH82yZWiISpxIn7N1kmMArOQjJ rFpJZCxiZVjGqF6cWlaUW6RrpJRVlpmeU5CZm5ugaGpjp5aYWFyemp+YkJhXrJefnbmIEhigD EOxgXPbX6RCjJAeTkiiv1W+fcCG+pPyUyozE4oz4otKc1OJDjDIcHEoSvMHAkBcSLEpNT61Iy 8wBRgtMWoKDR0mENx4kzVtckJhbnJkOkTrFqCglzisJkhAASWSU5sG1wSL0EqOslDAvI9AhQj wFqUW5mSWo8q8YxTkYlYR5jUCm8GTmlcBNfwW0mAlkcYYPyOKSRISUVANj/e416Vu0GB56z3G +cc9d9Psu93MrHztLsu7xemLB7trM9Vtkq1HZ3Jc7Hgf32hfeOsmxvONlakix+5J+tRt/7UuC /Ca9X10WmHWoSGCp9emmf7KS7uVS9/4ujLNViZaf53Dk24HIBU8mrZNTPFy8MEroTZlly8VtD Wm5ZjIX/Y8/4zLTyDZUYinOSDTUYi4qTgQAawdsSssCAAA= X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-14.tower-21.messagelabs.com!1464670195!16563322!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.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21671 invoked from network); 31 May 2016 04:49:57 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-14.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 31 May 2016 04:49:57 -0000 Received: from 172.24.1.137 (EHLO szxeml428-hub.china.huawei.com) ([172.24.1.137]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CCK66911; Tue, 31 May 2016 12:44:49 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml428-hub.china.huawei.com (10.82.67.183) with Microsoft SMTP Server id 14.3.235.1; Tue, 31 May 2016 12:44:35 +0800 From: Shannon Zhao To: Date: Tue, 31 May 2016 12:43:27 +0800 Message-ID: <1464669816-11476-6-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1464669816-11476-1-git-send-email-zhaoshenglong@huawei.com> References: <1464669816-11476-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.574D1715.0041, 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: 5a9c0ef99eb3bbef575fbe78a879585b Cc: sstabellini@kernel.org, ian.jackson@eu.citrix.com, peter.huangpeng@huawei.com, julien.grall@arm.com, shannon.zhao@linaro.org, wei.liu2@citrix.comg Subject: [Xen-devel] [PATCH 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,