From patchwork Thu Sep 22 12:52:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 76778 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp14716qgf; Thu, 22 Sep 2016 05:55:18 -0700 (PDT) X-Received: by 10.107.11.101 with SMTP id v98mr2764405ioi.145.1474548918480; Thu, 22 Sep 2016 05:55:18 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id e193si2839347iof.159.2016.09.22.05.55.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 22 Sep 2016 05:55:18 -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 1bn3VG-0003zn-A7; Thu, 22 Sep 2016 12:53:26 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bn3VF-0003z1-A1 for xen-devel@lists.xen.org; Thu, 22 Sep 2016 12:53:25 +0000 Received: from [85.158.137.68] by server-14.bemta-3.messagelabs.com id 5D/83-01833-444D3E75; Thu, 22 Sep 2016 12:53:24 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrBIsWRWlGSWpSXmKPExsVSPpHPSdf5yuN wg88P9C2WfFzM4sDocXT3b6YAxijWzLyk/IoE1oyH+46yFjy2rlj88B1TA+NSgy5GLg4hgVOM Ep3nt7FCOHsYJW7caQdyODnYBLQkzk//wQ5iiwjISqzumsMOUsQscJ1R4s77bWBFwgKeEvc6H oEVsQioStz9PIOli5GDg1fAQ+LOn2CQsISAhsTK3gksIDYnUPmEI+vBWoWASlZeWQhm8woISp yc+QSshllAQuLgixfMEL2KEm3rT7JB2JISB1fcYAG5QQLk6hnb+lkhEqYSXes62SYwCs5CMms WklkLGJlWMWoUpxaVpRbpGlroJRVlpmeU5CZm5ugaGhjr5aYWFyemp+YkJhXrJefnbmIEhmg9 AwPjDsbfpz0PMUpyMCmJ8l7ofxwuxJeUn1KZkVicEV9UmpNafIhRhoNDSYL38SWgnGBRanpqR VpmDjBaYNISHDxKIrzFl4HSvMUFibnFmekQqVOMilLivL9B+gRAEhmleXBtsAi9xCgrJczLyM DAIMRTkFqUm1mCKv+KUZyDUUmYdwbIFJ7MvBK46a+AFjMBLd7y8wHI4pJEhJRUA6PsuvPM/2b OXJPD4O2WrtdoKnBbrN7zz+8NG58x/C1/cNH46goB+z0zLxs9ndV4qdzh8tPWO7I8kjOWnKwt 8GieksfEs6bs7OzSa53p1Y9KMrZo7eBrtVvWLJN4Pt4/rPD/S3Ub59Op3raKat2rnnMzLtike Pv5aVbDz7M32x3dzcyfynBlca4SS3FGoqEWc1FxIgBgpCflywIAAA== X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-10.tower-31.messagelabs.com!1474548800!61443157!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.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 21965 invoked from network); 22 Sep 2016 12:53:23 -0000 Received: from szxga03-in.huawei.com (HELO szxga03-in.huawei.com) (119.145.14.66) by server-10.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 22 Sep 2016 12:53:23 -0000 Received: from 172.24.1.47 (EHLO szxeml431-hub.china.huawei.com) ([172.24.1.47]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id CIG48120; Thu, 22 Sep 2016 20:53:00 +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; Thu, 22 Sep 2016 20:52:50 +0800 From: z00226004 To: Date: Thu, 22 Sep 2016 20:52:19 +0800 Message-ID: <1474548753-12596-3-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1474548753-12596-1-git-send-email-zhaoshenglong@huawei.com> References: <1474548753-12596-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.0A020202.57E3D42E.0292, 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: 79f7c01679c9a3ce23bfbdf31bbed57f 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 v6 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 336358c..94ab743 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -91,6 +91,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.