From patchwork Thu Sep 29 01:18:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 77109 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp79899qgf; Wed, 28 Sep 2016 18:22:17 -0700 (PDT) X-Received: by 10.107.4.146 with SMTP id 140mr191584ioe.158.1475112137697; Wed, 28 Sep 2016 18:22:17 -0700 (PDT) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id x79si7639955iod.63.2016.09.28.18.22.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Sep 2016 18:22:17 -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; dkim=neutral (body hash did not verify) header.i=@linaro.org; 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; dmarc=fail (p=NONE dis=NONE) header.from=linaro.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 1bpQ0f-0001Ja-KK; Thu, 29 Sep 2016 01:19:37 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bpQ0d-0001Id-Oj for xen-devel@lists.xen.org; Thu, 29 Sep 2016 01:19:35 +0000 Received: from [193.109.254.147] by server-11.bemta-6.messagelabs.com id F1/50-08498-72C6CE75; Thu, 29 Sep 2016 01:19:35 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsVyMfTAJl21nDf hBt87ZCyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oxjD2QL9llVfNsq3sB4Tb+LkYtDSGASo8Sr iw2sIA6LwDxmiVVTdrKAOBIC/awSp/7NY+5i5ARyYiS+HP/ODmFXSizbtAIsLiSgJrHs8EJmi FFNTBIznsxgAUmwCehIvJi0kw3EFhGQlrj2+TIjSBGzwBFGiVvzT4J1Cwt4SnQuXwlUxAG0W1 Xi2YQ6kDCvgLXE/oaVUMs0JabPeg1WzilgI/Gh5RfUYmuJZd82s0xgFFjAyLCKUaM4tagstUj XyFIvqSgzPaMkNzEzR9fQwEwvN7W4ODE9NScxqVgvOT93EyMwsBiAYAfjgUWBhxglOZiURHk5 fd6EC/El5adUZiQWZ8QXleakFh9ilOHgUJLgvZIFlBMsSk1PrUjLzAGGOExagoNHSYT3FUiat 7ggMbc4Mx0idYrRmGPL72trmTi2Tb23lkmIJS8/L1VKnPcqSKkASGlGaR7cIFjsXWKUlRLmZQ Q6TYinILUoN7MEVf4VozgHo5Iw72uQKTyZeSVw+14BncIEdMrSEy9ATilJREhJNTDaa2p8yhH arfDshybXC96bGSuXlv5NYXI5ZSnqetLo9XqNxeu2evjr35aI1BTycvjCsWm1RtZlr7eXNlc2 Ktp4KwifZGHbnXxm70OmJNZOV453K9gOiPH2WvtXOf4/l9TAFe/AsLCpRyAjY8mivx879tf5n HrpKcBd++p9+cbjjKcuvXwQdlyJpTgj0VCLuag4EQCDOVN2uAIAAA== X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-2.tower-27.messagelabs.com!1475111973!9586595!1 X-Originating-IP: [209.85.192.178] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 52903 invoked from network); 29 Sep 2016 01:19:34 -0000 Received: from mail-pf0-f178.google.com (HELO mail-pf0-f178.google.com) (209.85.192.178) by server-2.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 29 Sep 2016 01:19:34 -0000 Received: by mail-pf0-f178.google.com with SMTP id l25so22857145pfb.1 for ; Wed, 28 Sep 2016 18:19:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xb+Z9FJEErarckW/VKlIRC1rXMZ6UhRw44AyP2jwVVs=; b=ASn1WMc/HySZPM7ryj8g13fqJ58Q5ggGh8RRHMGojM/51ojthdYLVXsV0bILS/mi+D fhY873KToKLd+E76akH7zXs6j8KS31z7sPZyoTRmDVklCxb2fMJ/jCF7qm3Hnwh3sSbD yukIuzxFep7t32Vx30W0rnjoYmpJjSIbzt+GE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xb+Z9FJEErarckW/VKlIRC1rXMZ6UhRw44AyP2jwVVs=; b=bwu5UkvLs6y2PUgjOi6X4gZRrlFEZuRv4LeRTvAghypJJbcR3uDu5IktUuzWaBlFUJ 2zmDNDHUPPbjL+eDzP90jyytynoOV65mtvZ2Yt1/ocSg+52OhB/ypShujYMfOzZYfF3G Ry3h/5nxJGEVOwdD1oS3h4dci8xkJ6GzliNoAFK2AfxfXYtKnSmk9hDmZ83CgnqXiios 8AlS63RQE+DWUD3HpnakUMU158KjNH3JyxhX+UQP4Tv+3FOSqJq8v5d07X1+YVKkfpVW YW1Rjyueah18X9K5TV/MUPpjyugyCKhVLm7mvcBq3mFcGA+gSf8bHLVBkGbiT0Kjpm5U KN2A== X-Gm-Message-State: AE9vXwPQKzttRW0cquXeNvznwKujx0imjm0ksqV2rJDvJgJRJSra8uVlJZMrQMOL1Pl4ZbgB X-Received: by 10.98.84.67 with SMTP id i64mr62396823pfb.105.1475111972776; Wed, 28 Sep 2016 18:19:32 -0700 (PDT) Received: from HZA160860128-A.china.huawei.com ([67.238.99.186]) by smtp.gmail.com with ESMTPSA id wd7sm15228744pab.2.2016.09.28.18.19.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 28 Sep 2016 18:19:31 -0700 (PDT) From: Shannon Zhao To: xen-devel@lists.xen.org Date: Wed, 28 Sep 2016 18:18:48 -0700 Message-Id: <20160929011902.7784-3-shannon.zhao@linaro.org> X-Mailer: git-send-email 2.10.0.windows.1 In-Reply-To: <20160929011902.7784-1-shannon.zhao@linaro.org> References: <20160929011902.7784-1-shannon.zhao@linaro.org> Cc: sstabellini@kernel.org, wei.liu2@citrix.com, ian.jackson@eu.citrix.com, julien.grall@arm.com, Shannon Zhao , zhaoshenglong@huawei.com, boris.ostrovsky@oracle.com Subject: [Xen-devel] [PATCH v8 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: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" 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 Acked-by: Wei Liu --- tools/libxl/Makefile | 7 +++++ tools/libxl/libxl_arm.c | 24 +++++++++++++++- tools/libxl/libxl_arm.h | 32 +++++++++++++++++++++ tools/libxl/libxl_arm_acpi.c | 61 +++++++++++++++++++++++++++++++++++++++++ tools/libxl/libxl_arm_no_acpi.c | 33 ++++++++++++++++++++++ xen/include/public/arch-arm.h | 4 +++ 6 files changed, 160 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 3c63bf9..d8cd5f9 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..ec76c32 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, 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..fcce405 --- /dev/null +++ b/tools/libxl/libxl_arm.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 + +_hidden +int libxl__prepare_acpi(libxl__gc *gc, libxl_domain_build_info *info, + 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..5bf9396 --- /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 + +/* 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, + 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..88ebbb6 --- /dev/null +++ b/tools/libxl/libxl_arm_no_acpi.c @@ -0,0 +1,33 @@ +/* + * 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, + 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 17ce3a0..498d03d 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 xen_mk_ullong(0x03020000) /* vCPU0..127 */ #define GUEST_GICV3_GICR0_SIZE xen_mk_ullong(0x01000000) +/* 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.