From patchwork Tue Nov 17 09:57:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 7635421 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 88E86BF90C for ; Tue, 17 Nov 2015 10:39:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9CE3A204E0 for ; Tue, 17 Nov 2015 10:39:50 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id AF1A9204E4 for ; Tue, 17 Nov 2015 10:39:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zyde4-0001To-6K; Tue, 17 Nov 2015 10:37:52 +0000 Received: from mail-wm0-x22a.google.com ([2a00:1450:400c:c09::22a]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zyd2x-0007DN-KJ for linux-arm-kernel@lists.infradead.org; Tue, 17 Nov 2015 10:00:03 +0000 Received: by wmww144 with SMTP id w144so146137994wmw.1 for ; Tue, 17 Nov 2015 01:59:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TtoFvU7L4+w9g3Rnm04aToh+WNq7GSEGsSLBs0tLu6k=; b=O/DPtuDAMHoXMTwt5vrsmqatVU1YzzrbS50XAokv8gVII8q4qc7RmMxJupgCn8FZaa 6po3EocVO+sFfjj/chfuvevs8D8t+bGpVurF3StUj5WPR5hB2l33Vp/t4gpJVOR7P1Ej dEdeHBPXwrTg7VDafzVu39ttrTBjdSvbMzv2cizn1wMHmFp+k3p11zuixNI/PHDiu+2J HlGxyQ3AMDStk+Uctps85k+DKuEC8KKB1N5V8hynb0uW0yvXI7ExJoUJz6Dpna0vytvT VT5jGNuKmAr9eoJWOCD3HDkBcqa16yfm7RN0ifHqLvzDCYYS7qzmqwv97/9mo5e8cgcv K8XA== 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=TtoFvU7L4+w9g3Rnm04aToh+WNq7GSEGsSLBs0tLu6k=; b=OL39H1l0eU9o5x7jsj5bVz4oOQwQaqoAYT0TjXNcacoyCimJNL9lTJ1oVuF2PaN6Wi SNxWn+wZDx0xIJ0Jcp9Y64Lc/AE0EbCVHCiNBrphYDDd4mq8vltDbMJx2asfvolMDbR6 VcF40X62iNkeSkCl6YbHiO+N/RxcgqVe/mmgh4v1nEkf7PmFBfBtvVKLeVvn4+AsDnH1 ZiXYgpMOHZOXne0hCOHsBGZ3UP+nnfPpSFNy1DH8T/egeQwm1sOXHzdGlQHfadtkL/Ks /LvNCGeKKcaJntcICaqZrUigpxh+Gq+Bqy3NeBBiFxnxEp95ohLfApeJ9w4F12LM/c1n 9sPw== X-Gm-Message-State: ALoCoQkf53ltEQuzkkm9DPqTknxbHzuFWQAujkJmG99RpOCvc/Z1ZMzmPQxKbmEvnOpmndrO+dOG X-Received: by 10.194.91.164 with SMTP id cf4mr41539176wjb.139.1447754350105; Tue, 17 Nov 2015 01:59:10 -0800 (PST) Received: from localhost ([78.129.251.54]) by smtp.gmail.com with ESMTPSA id e189sm23135062wma.4.2015.11.17.01.59.07 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 17 Nov 2015 01:59:09 -0800 (PST) From: shannon.zhao@linaro.org To: ian.campbell@citrix.com, stefano.stabellini@citrix.com, catalin.marinas@arm.com, will.deacon@arm.com, julien.grall@citrix.com, ard.biesheuvel@linaro.org, mark.rutland@arm.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH 13/13] ARM: XEN: Move xen_early_init() before efi_init() Date: Tue, 17 Nov 2015 17:57:11 +0800 Message-Id: <1447754231-7772-14-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1447754231-7772-1-git-send-email-shannon.zhao@linaro.org> References: <1447754231-7772-1-git-send-email-shannon.zhao@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151117_015932_502488_DFCB68E2 X-CRM114-Status: GOOD ( 17.32 ) X-Spam-Score: -2.6 (--) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, hangaohuai@huawei.com, linux-efi@vger.kernel.org, peter.huangpeng@huawei.com, xen-devel@lists.xen.org, shannon.zhao@linaro.org, zhaoshenglong@huawei.com, christoffer.dall@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Shannon Zhao Move xen_early_init() before efi_init(), then when calling efi_init() could initialize Xen specific UEFI. Check if it runs on Xen hypervisor through the flat dts. Signed-off-by: Shannon Zhao --- arch/arm/xen/enlighten.c | 62 ++++++++++++++++++++++++++++++++++++----------- arch/arm64/kernel/setup.c | 2 +- 2 files changed, 49 insertions(+), 15 deletions(-) diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index b8e9db8..d4f884c 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -48,8 +49,6 @@ struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata; static __read_mostly unsigned int xen_events_irq; -static __initdata struct device_node *xen_node; - int xen_remap_domain_gfn_array(struct vm_area_struct *vma, unsigned long addr, xen_pfn_t *gfn, int nr, @@ -142,6 +141,34 @@ static irqreturn_t xen_arm_callback(int irq, void *arg) return IRQ_HANDLED; } +struct xen_node_info { + const char *compat; + const char *prefix; + const char *version; + bool found; +}; + +static int __init fdt_find_xen_node(unsigned long node, const char *uname, + int depth, void *data) +{ + struct xen_node_info *info = data; + const void *s = NULL; + int len; + + if (depth != 1 || strcmp(uname, "hypervisor") != 0) + return 0; + + if (of_flat_dt_is_compatible(node, info->compat)) + info->found = true; + + s = of_get_flat_dt_prop(node, "compatible", &len); + if (strlen(info->prefix) + 3 < len && + !strncmp(info->prefix, s, strlen(info->prefix))) + info->version = s + strlen(info->prefix); + + return 0; +} + /* * see Documentation/devicetree/bindings/arm/xen.txt for the * documentation of the Xen Device Tree format. @@ -149,26 +176,25 @@ static irqreturn_t xen_arm_callback(int irq, void *arg) #define GRANT_TABLE_PHYSADDR 0 void __init xen_early_init(void) { - int len; - const char *s = NULL; - const char *version = NULL; - const char *xen_prefix = "xen,xen-"; + struct xen_node_info info; + + info.compat = "xen,xen"; + info.prefix = "xen,xen-"; + info.version = NULL; + info.found = false; - xen_node = of_find_compatible_node(NULL, NULL, "xen,xen"); - if (!xen_node) { + of_scan_flat_dt(fdt_find_xen_node, &info); + if (!info.found) { pr_debug("No Xen support\n"); return; } - s = of_get_property(xen_node, "compatible", &len); - if (strlen(xen_prefix) + 3 < len && - !strncmp(xen_prefix, s, strlen(xen_prefix))) - version = s + strlen(xen_prefix); - if (version == NULL) { + + if (info.version == NULL) { pr_debug("Xen version not found\n"); return; } - pr_info("Xen %s support found\n", version); + pr_info("Xen %s support found\n", info.version); xen_domain_type = XEN_HVM_DOMAIN; @@ -204,6 +230,14 @@ static int __init xen_guest_init(void) } xen_events_irq = a.value & 0xff; } else { + struct device_node *xen_node; + + xen_node = of_find_compatible_node(NULL, NULL, "xen,xen"); + if (!xen_node) { + pr_debug("No Xen support\n"); + return -ENODEV; + } + xen_events_irq = irq_of_parse_and_map(xen_node, 0); if (!xen_events_irq) { pr_err("Xen event channel interrupt not found\n"); diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 2322479..ee95593 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -428,6 +428,7 @@ void __init setup_arch(char **cmdline_p) */ local_async_enable(); + xen_early_init(); efi_init(); arm64_memblock_init(); @@ -446,7 +447,6 @@ void __init setup_arch(char **cmdline_p) } else { psci_acpi_init(); } - xen_early_init(); cpu_read_bootcpu_ops(); smp_init_cpus();