From patchwork Fri Jan 15 06:55:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 59838 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp357086lbb; Thu, 14 Jan 2016 22:57:54 -0800 (PST) X-Received: by 10.98.72.87 with SMTP id v84mr12392403pfa.15.1452841073920; Thu, 14 Jan 2016 22:57:53 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q73si14522571pfi.248.2016.01.14.22.57.53; Thu, 14 Jan 2016 22:57:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754703AbcAOG4v (ORCPT + 29 others); Fri, 15 Jan 2016 01:56:51 -0500 Received: from szxga01-in.huawei.com ([58.251.152.64]:13176 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754452AbcAOG4l (ORCPT ); Fri, 15 Jan 2016 01:56:41 -0500 Received: from 172.24.1.51 (EHLO SZXEML429-HUB.china.huawei.com) ([172.24.1.51]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DDB64116; Fri, 15 Jan 2016 14:56:33 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by SZXEML429-HUB.china.huawei.com (10.82.67.184) with Microsoft SMTP Server id 14.3.235.1; Fri, 15 Jan 2016 14:56:21 +0800 From: Shannon Zhao To: , , , CC: , , , , , , , , , Subject: [PATCH v2 10/16] ARM: XEN: Move xen_early_init() before efi_init() Date: Fri, 15 Jan 2016 14:55:23 +0800 Message-ID: <1452840929-19612-11-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1452840929-19612-1-git-send-email-zhaoshenglong@huawei.com> References: <1452840929-19612-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.0A020201.56989822.0102, 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: fa884f13f016bde697713d37307e6f73 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 | 56 ++++++++++++++++++++++++++++++++++------------- arch/arm64/kernel/setup.c | 2 +- 2 files changed, 42 insertions(+), 16 deletions(-) -- 2.0.4 diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 4e78c49..5d0fe68 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -52,8 +53,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, @@ -222,6 +221,33 @@ static irqreturn_t xen_arm_callback(int irq, void *arg) return IRQ_HANDLED; } +static __initdata struct { + const char *compat; + const char *prefix; + const char *version; + bool found; +} xen_node = {"xen,xen", "xen,xen-", NULL, false}; + +static int __init fdt_find_xen_node(unsigned long node, const char *uname, + int depth, void *data) +{ + const void *s = NULL; + int len; + + if (depth != 1 || strcmp(uname, "hypervisor") != 0) + return 0; + + if (of_flat_dt_is_compatible(node, xen_node.compat)) + xen_node.found = true; + + s = of_get_flat_dt_prop(node, "compatible", &len); + if (strlen(xen_node.prefix) + 3 < len && + !strncmp(xen_node.prefix, s, strlen(xen_node.prefix))) + xen_node.version = s + strlen(xen_node.prefix); + + return 0; +} + /* * see Documentation/devicetree/bindings/arm/xen.txt for the * documentation of the Xen Device Tree format. @@ -229,26 +255,18 @@ 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-"; - - xen_node = of_find_compatible_node(NULL, NULL, "xen,xen"); - if (!xen_node) { + of_scan_flat_dt(fdt_find_xen_node, NULL); + if (!xen_node.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 (xen_node.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", xen_node.version); xen_domain_type = XEN_HVM_DOMAIN; @@ -296,6 +314,14 @@ static int __init xen_guest_init(void) } #endif } 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); } diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index 8119479..a4a2878 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -313,6 +313,7 @@ void __init setup_arch(char **cmdline_p) */ local_async_enable(); + xen_early_init(); efi_init(); arm64_memblock_init(); @@ -334,7 +335,6 @@ void __init setup_arch(char **cmdline_p) } else { psci_acpi_init(); } - xen_early_init(); cpu_read_bootcpu_ops(); smp_init_cpus();