From patchwork Thu Jun 23 03:16: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: 70719 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp217347qgy; Wed, 22 Jun 2016 20:20:50 -0700 (PDT) X-Received: by 10.107.4.195 with SMTP id 186mr47446327ioe.143.1466652033138; Wed, 22 Jun 2016 20:20:33 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id u67si2973366itf.74.2016.06.22.20.20.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 22 Jun 2016 20:20:33 -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 1bFv9h-0000Dt-DN; Thu, 23 Jun 2016 03:18:13 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bFv9f-0000Cx-Ue for xen-devel@lists.xen.org; Thu, 23 Jun 2016 03:18:12 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id 88/25-02783-3F45B675; Thu, 23 Jun 2016 03:18:11 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGIsWRWlGSWpSXmKPExsVSPpHPSfdTSHa 4QeMHHYslHxezODB6HN39mymAMYo1My8pvyKBNaN922Kmgl26FR17nrE2MJ5S6WLk5BASOMUo 0XLEo4uRC8jewyjx49s2dpAEm4CuxMeNU8BsEQFZidVdc9hBipgFrjNK3Hm/jbWLkYNDWMBTY to1VpAaFgFViSWrrzCC2LwC7hJ3L/wFi0sIaEis7J3AAmJzCnhInJz1hBlisbvEnDV7WSDqBS VOznwCZjMLSEgcfPGCGaJXUaJt/Uk2CFtS4uCKGywgN0iAHP1kRTsTRMJUYmPXP9YJjIKzkMy ahWTWAkamVYzqxalFZalFupZ6SUWZ6RkluYmZObqGBsZ6uanFxYnpqTmJScV6yfm5mxiB4VnP wMC4g/H1T6dDjJIcTEqivFYO2eFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHgdg4FygkWp6akVa Zk5wEiBSUtw8CiJ8EqApHmLCxJzizPTIVKnGBWlxHntQRICIImM0jy4Nlh0XmKUlRLmZWRgYB DiKUgtys0sQZV/xSjOwagkzLsWZApPZl4J3PRXQIuZgBYv608HWVySiJCSamAUOxuu3fr6Y97 Jd18cjG/Outrz76im1O4lKUXNWm6BgkdLMvK+zT6outszY1rN72JL1QYXk741Aoqfq/Zcuuly dHXOF+2DswOu3gmRzZH1LQ5vfX2N5eGUm9uZLmiel4/LCk3ieHX+1dLWKd8uNCq+Naj2/Plws ti93vfbqhvKGH6y2T/t1+pVYinOSDTUYi4qTgQA6W9cOMkCAAA= X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-10.tower-31.messagelabs.com!1466651888!46046554!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 28059 invoked from network); 23 Jun 2016 03:18:10 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-10.tower-31.messagelabs.com with SMTP; 23 Jun 2016 03:18:10 -0000 Received: from 172.24.1.36 (EHLO szxeml430-hub.china.huawei.com) ([172.24.1.36]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CDT13165; Thu, 23 Jun 2016 11:17:38 +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:27 +0800 From: Shannon Zhao To: Date: Thu, 23 Jun 2016 11:16:51 +0800 Message-ID: <1466651824-6964-5-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.0A090202.576B54D2.00E8, 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: 6abee7b30348c456ac2d2021299b9f5c 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 04/17] libxl/arm: prepare for constructing ACPI tables 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 It only constructs the ACPI tables for 64-bit ARM DomU when user enables acpi because 32-bit DomU doesn't support ACPI. Signed-off-by: Shannon Zhao --- tools/libxl/Makefile | 4 +++ tools/libxl/libxl_arm.c | 19 +++++++++- tools/libxl/libxl_arm_acpi.c | 85 ++++++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_arm_acpi.h | 32 +++++++++++++++++ 4 files changed, 139 insertions(+), 1 deletion(-) create mode 100644 tools/libxl/libxl_arm_acpi.c create mode 100644 tools/libxl/libxl_arm_acpi.h diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile index 9fee752..264b6ef 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -77,6 +77,10 @@ endif LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o +LIBXL_OBJS-$(CONFIG_ARM) += libxl_arm_acpi.o + +libxl_arm_acpi.o: libxl_arm_acpi.c + $(CC) -c $(CFLAGS) -I../../xen/include/ -o $@ libxl_arm_acpi.c ifeq ($(CONFIG_NetBSD),y) LIBXL_OBJS-y += libxl_netbsd.o diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c index cc5a717..f5db74b 100644 --- a/tools/libxl/libxl_arm.c +++ b/tools/libxl/libxl_arm.c @@ -1,6 +1,7 @@ #include "libxl_internal.h" #include "libxl_arch.h" #include "libxl_libfdt_compat.h" +#include "libxl_arm_acpi.h" #include #include @@ -888,8 +889,24 @@ int libxl__arch_domain_init_hw_description(libxl__gc *gc, libxl__domain_build_state *state, struct xc_dom_image *dom) { + int rc; + assert(info->type == LIBXL_DOMAIN_TYPE_PV); - return libxl__prepare_dtb(gc, info, state, dom); + rc = libxl__prepare_dtb(gc, info, state, dom); + if (rc) + return rc; + + if (!state->config.acpi) { + LOG(DEBUG, "Generating ACPI tables is disabled by user."); + return 0; + } + + if (strcmp(dom->guest_type, "xen-3.0-aarch64")) { + LOG(DEBUG, "Do not generate ACPI tables for %s", dom->guest_type); + state->config.acpi = false; + } + + return libxl__prepare_acpi(gc, info, state, dom); } static void finalise_one_memory_node(libxl__gc *gc, void *fdt, diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c new file mode 100644 index 0000000..60c31f9 --- /dev/null +++ b/tools/libxl/libxl_arm_acpi.c @@ -0,0 +1,85 @@ +/* + * ARM DmoU ACPI generation + * + * Copyright (C) 2008-2010 Kevin O'Connor + * Copyright (C) 2006 Fabrice Bellard + * Copyright (C) 2013 Red Hat Inc + * + * Author: Michael S. Tsirkin + * + * Copyright (c) 2015 HUAWEI TECHNOLOGIES CO.,LTD. + * + * Author: Shannon Zhao + * + * Copyright (C) 2016 Linaro Ltd. + * + * Author: Shannon Zhao + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +#include "libxl_arm_acpi.h" + +#include +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; +#include +#include + +enum { + RSDP, + XSDT, + GTDT, + MADT, + FADT, + DSDT, + NUMS, +}; + +struct acpitable { + void *table; + size_t size; +}; + +static struct acpitable acpitables[NUMS]; + +int libxl__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; + int rc; + + /* 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); + + dom->acpitable_blob = NULL; + dom->acpitable_size = 0; + + return 0; +} + +/* + * Local variables: + * mode: C + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libxl/libxl_arm_acpi.h b/tools/libxl/libxl_arm_acpi.h new file mode 100644 index 0000000..5899210 --- /dev/null +++ b/tools/libxl/libxl_arm_acpi.h @@ -0,0 +1,32 @@ +/* + * Copyright (C) 2016 Linaro Ltd. + * + * Author: Shannon Zhao + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published + * by the Free Software Foundation; version 2.1 only. with the special + * exception on linking described in file LICENSE. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + */ + +#include "libxl_internal.h" +#include "libxl_arch.h" + +#include + +int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, + libxl__domain_build_state *state, + struct xc_dom_image *dom); + +/* + * Local variables: + * mode: C + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */