From patchwork Tue Aug 16 10:24:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 9283189 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 113EB60839 for ; Tue, 16 Aug 2016 10:29:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3D6928C85 for ; Tue, 16 Aug 2016 10:29:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E873C28D79; Tue, 16 Aug 2016 10:29:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4624128C85 for ; Tue, 16 Aug 2016 10:29:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bZbaE-0001yQ-2Y; Tue, 16 Aug 2016 10:26: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 1bZbaC-0001wi-Tq for xen-devel@lists.xen.org; Tue, 16 Aug 2016 10:26:57 +0000 Received: from [193.109.254.147] by server-1.bemta-6.messagelabs.com id 62/BE-21406-07AE2B75; Tue, 16 Aug 2016 10:26:56 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCIsWRWlGSWpSXmKPExsVi9XuGg27+q03 hBjufmFss+biYxYHR4+ju30wBjFGsmXlJ+RUJrBn3jukWXDasWLKhoIHxsHoXIxeHkMApRomX k5YyQjh7GCVOXr7H3MXIycEmoCvxceMUdhBbREBWYnXXHHaQImaB64wSd95vYwVJCAt4Sqy8c 4kNxGYRUJXYcO8sC4jNK+AhsbFtLyOILSGgIbGydwJQnIODE6j+2hSwciGgktMzF7JClAtKnJ z5BKyVWUBC4uCLF8wQrYoSbetPskHYkhIHV9xgAblBAuTqv/MWsoHMlBAwlVjYHzqBUXAWklG zkIxawMi0ilG9OLWoLLVI10IvqSgzPaMkNzEzR9fQwEwvN7W4ODE9NScxqVgvOT93EyMwNBmA YAfj7Mv+hxglOZiURHlnTtwYLsSXlJ9SmZFYnBFfVJqTWnyIUYaDQ0mCN+jlpnAhwaLU9NSKt MwcYJTApCU4eJREeE1B0rzFBYm5xZnpEKlTjIpS4rxyIAkBkERGaR5cGywyLzHKSgnzMgIdIs RTkFqUm1mCKv+KUZyDUUmY9+8LoCk8mXklcNNfAS1mAlqsL70BZHFJIkJKqoFxv6ECx/ENTyo jf1V9kl63PuYBX3v3Vd9rzO0Pmf/MeDRPqPAJu+p18Tg1wWjZLzLWS3yeCuxdq5Kf/kJ+6teF 4qf1nNQlrTd8n/jq1Zl3eXIRjDnn1tUoLCw1LVLwmvRp1pSVn5OcjullnZ5w8+g5u3/bV9esf fs3vVrozcXvETu/cV/PbeY+q8RSnJFoqMVcVJwIAGXQSyzHAgAA X-Env-Sender: zhaoshenglong@huawei.com X-Msg-Ref: server-8.tower-27.messagelabs.com!1471343210!43787640!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 39782 invoked from network); 16 Aug 2016 10:26:54 -0000 Received: from szxga01-in.huawei.com (HELO szxga01-in.huawei.com) (58.251.152.64) by server-8.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 16 Aug 2016 10:26:54 -0000 Received: from 172.24.1.36 (EHLO szxeml434-hub.china.huawei.com) ([172.24.1.36]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DPP02653; Tue, 16 Aug 2016 18:26:20 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml434-hub.china.huawei.com (10.82.67.225) with Microsoft SMTP Server id 14.3.235.1; Tue, 16 Aug 2016 18:25:33 +0800 From: Shannon Zhao To: Date: Tue, 16 Aug 2016 18:24:59 +0800 Message-ID: <1471343113-10652-3-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1471343113-10652-1-git-send-email-zhaoshenglong@huawei.com> References: <1471343113-10652-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.0A090203.57B2EA4E.0035, 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: f41ed33119f13b79fb0bce10033acb00 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 v4 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" X-Virus-Scanned: ClamAV using ClamSMTP 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 | 23 +++++++++++++++- tools/libxl/libxl_arm.h | 44 +++++++++++++++++++++++++++++++ tools/libxl/libxl_arm_acpi.c | 61 +++++++++++++++++++++++++++++++++++++++++++ xen/include/public/arch-arm.h | 4 +++ 5 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 tools/libxl/libxl_arm.h create mode 100644 tools/libxl/libxl_arm_acpi.c diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile index a148374..6139bed 100644 --- a/tools/libxl/Makefile +++ b/tools/libxl/Makefile @@ -90,6 +90,10 @@ 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 +LIBXL_OBJS-$(CONFIG_ARM_64) += 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 bd3d611..8c7fc09 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,28 @@ 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")) { + 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..fe1c05f --- /dev/null +++ b/tools/libxl/libxl_arm.h @@ -0,0 +1,44 @@ +/* + * 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 + +#if defined(__aarch64__) +_hidden +int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, + libxl__domain_build_state *state, + struct xc_dom_image *dom); +#else +_hidden +static inline int libxl__prepare_acpi(libxl__gc *gc, + libxl_domain_build_info *info, + libxl__domain_build_state *state, + struct xc_dom_image *dom) +{ + return 0; +} +#endif + +/* + * 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..ec6cf08 --- /dev/null +++ b/tools/libxl/libxl_arm_acpi.c @@ -0,0 +1,61 @@ +/* + * 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 + +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/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h index 870bc3b..0afd654 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 0x00200000ULL + /* * 16MB == 4096 pages reserved for guest to use as a region to map its * grant table in.