From patchwork Fri Sep 2 02:55:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 75272 Delivered-To: patch@linaro.org Received: by 10.140.29.8 with SMTP id a8csp623845qga; Thu, 1 Sep 2016 19:59:02 -0700 (PDT) X-Received: by 10.157.7.55 with SMTP id 52mr18596605ote.90.1472785134783; Thu, 01 Sep 2016 19:58:54 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id i46si10098563ote.232.2016.09.01.19.58.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Sep 2016 19:58:54 -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 1bfef4-00073H-13; Fri, 02 Sep 2016 02:56:58 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bfef3-00071w-25 for xen-devel@lists.xen.org; Fri, 02 Sep 2016 02:56:57 +0000 Received: from [85.158.143.35] by server-5.bemta-6.messagelabs.com id 2F/82-29563-87AE8C75; Fri, 02 Sep 2016 02:56:56 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrGIsWRWlGSWpSXmKPExsVi9XuGg275qxP hBj+nK1ks+biYxYHR4+ju30wBjFGsmXlJ+RUJrBln5vSzF2y1rpj7aA1LA+Nv/S5GLg4hgVOM Eu+nP2KBcHYzSmw9+4i5i5GTg01AV+LjxinsILaIgKzE6q457CBFzALXGSXuvN/G2sXIwSEs4 Cmx4GwUiMkioCKx8Io4SDmvgIdE0+P/jCC2hICGxMreCSwgNidQ9dtVn8BGCgHVPH71iAmiXl Di5MwnYDXMAhISB1+8YIboVZRoW3+SDcKWlDi44gbYnRIgR0/Y2sEGsldCwFRi2V3bCYyCs5C MmoVk1AJGplWMGsWpRWWpRbqGhnpJRZnpGSW5iZk5uoYGZnq5qcXFiempOYlJxXrJ+bmbGIHh yQAEOxg/LQs4xCjJwaQkypv/5ES4EF9SfkplRmJxRnxRaU5q8SFGGQ4OJQleo5dAOcGi1PTUi rTMHGCkwKQlOHiURHjNQNK8xQWJucWZ6RCpU4yKUuK8L14AJQRAEhmleXBtsOi8xCgrJczLCH SIEE9BalFuZgmq/CtGcQ5GJWHeAJDxPJl5JXDTXwEtZgJaXHLtOMjikkSElFQDo06vmazcqgv KCZITJfbJHZEpcfCf6bVZe/H3ZI1jajFFs+Pl5PTLZfIm1XNq1wowLno+bcVpr6bbUlcPBDE/ FfG+G1ofvdv98fe/YtZPfXMtA0qnWIsz3pO6LKv261CmUs8JGbHbPhWxBvl+LhoPQk8XdTF3z DtiKvSeY6N99cmF9/csne2txFKckWioxVxUnAgAaE+6VckCAAA= X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-9.tower-21.messagelabs.com!1472785011!31169599!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.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 26987 invoked from network); 2 Sep 2016 02:56:54 -0000 Received: from szxga01-in.huawei.com (HELO szxga01-in.huawei.com) (58.251.152.64) by server-9.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 2 Sep 2016 02:56:54 -0000 Received: from 172.24.1.60 (EHLO szxeml431-hub.china.huawei.com) ([172.24.1.60]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DQM36297; Fri, 02 Sep 2016 10:56:14 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml431-hub.china.huawei.com (10.82.67.208) with Microsoft SMTP Server id 14.3.235.1; Fri, 2 Sep 2016 10:56:00 +0800 From: Shannon Zhao To: Date: Fri, 2 Sep 2016 10:55:25 +0800 Message-ID: <1472784939-14404-3-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1472784939-14404-1-git-send-email-zhaoshenglong@huawei.com> References: <1472784939-14404-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.0A0B0207.57C8EA4F.00B1, 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: fe3f5838006c5aa929cc8e0c86e955af 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 v5 02/16] 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. And the generation codes are only built for 64-bit toolstack. Signed-off-by: Shannon Zhao Acked-by: Julien Grall --- tools/libxl/Makefile | 7 +++++ tools/libxl/libxl_arm.c | 24 +++++++++++++++- tools/libxl/libxl_arm.h | 33 ++++++++++++++++++++++ tools/libxl/libxl_arm_acpi.c | 62 +++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_arm_no_acpi.c | 34 ++++++++++++++++++++++ xen/include/public/arch-arm.h | 4 +++ 6 files changed, 163 insertions(+), 1 deletion(-) create mode 100644 tools/libxl/libxl_arm.h create mode 100644 tools/libxl/libxl_arm_acpi.c create mode 100644 tools/libxl/libxl_arm_no_acpi.c diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile index a148374..afd93de 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -90,6 +90,13 @@ acpi: LIBXL_OBJS-$(CONFIG_X86) += libxl_cpuid.o libxl_x86.o libxl_psr.o libxl_x86_acpi.o LIBXL_OBJS-$(CONFIG_ARM) += libxl_nocpuid.o libxl_arm.o libxl_libfdt_compat.o +ifeq ($(CONFIG_ARM_64),y) +LIBXL_OBJS-y += libxl_arm_acpi.o +libxl_arm_acpi.o: libxl_arm_acpi.c + $(CC) -c $(CFLAGS) -I../../xen/include/ -o $@ libxl_arm_acpi.c +else +LIBXL_OBJS-$(CONFIG_ARM) += libxl_arm_no_acpi.o +endif 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 8ec5cd5..333c9a1 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.h" #include #include @@ -885,8 +886,29 @@ 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) goto out; + + if (!libxl_defbool_val(info->acpi)) { + LOG(DEBUG, "Generating ACPI tables is disabled by user."); + rc = 0; + goto out; + } + + if (strcmp(dom->guest_type, "xen-3.0-aarch64")) { + /* ACPI is only supported for 64-bit guest currently. */ + LOG(ERROR, "Can not enable libxl option 'acpi' for %s", dom->guest_type); + rc = ERROR_FAIL; + goto out; + } + + rc = libxl__prepare_acpi(gc, info, state, dom); + +out: + return rc; } static void finalise_one_memory_node(libxl__gc *gc, void *fdt, diff --git a/tools/libxl/libxl_arm.h b/tools/libxl/libxl_arm.h new file mode 100644 index 0000000..1c01177 --- /dev/null +++ b/tools/libxl/libxl_arm.h @@ -0,0 +1,33 @@ +/* + * 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 + +_hidden +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: + */ diff --git a/tools/libxl/libxl_arm_acpi.c b/tools/libxl/libxl_arm_acpi.c new file mode 100644 index 0000000..810aed8 --- /dev/null +++ b/tools/libxl/libxl_arm_acpi.c @@ -0,0 +1,62 @@ +/* + * ARM DomU ACPI generation + * + * 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.h" + +#include + +/* Below typedefs are useful for the headers under acpi/ */ +typedef uint8_t u8; +typedef uint16_t u16; +typedef uint32_t u32; +typedef uint64_t u64; + +#include +#include + +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 = 0; + + vers = libxl_get_version_info(CTX); + if (vers == NULL) { + rc = ERROR_FAIL; + goto out; + } + + LOG(DEBUG, "constructing ACPI tables for Xen version %d.%d guest", + vers->xen_version_major, vers->xen_version_minor); + + dom->acpi_modules[0].data = NULL; + dom->acpi_modules[0].length = 0; + dom->acpi_modules[0].guest_addr_out = GUEST_ACPI_BASE; + +out: + return rc; +} + +/* + * Local variables: + * mode: C + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/tools/libxl/libxl_arm_no_acpi.c b/tools/libxl/libxl_arm_no_acpi.c new file mode 100644 index 0000000..e7f7411 --- /dev/null +++ b/tools/libxl/libxl_arm_no_acpi.c @@ -0,0 +1,34 @@ +/* + * ARM DomU ACPI generation + * + * 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.h" + +int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, + libxl__domain_build_state *state, + struct xc_dom_image *dom) +{ + return ERROR_FAIL; +} + +/* + * Local variables: + * mode: C + * c-basic-offset: 4 + * indent-tabs-mode: nil + * End: + */ diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index 870bc3b..4b4c959 100644 --- a/xen/include/public/arch-arm.h +++ b/xen/include/public/arch-arm.h @@ -406,6 +406,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 0x02000000ULL + /* * 16MB == 4096 pages reserved for guest to use as a region to map its * grant table in.