From patchwork Fri Apr 1 15:49:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 8726171 Return-Path: X-Original-To: patchwork-xen-devel@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 834F2C0554 for ; Fri, 1 Apr 2016 15:53:36 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8342A203DC for ; Fri, 1 Apr 2016 15:53:35 +0000 (UTC) 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.kernel.org (Postfix) with ESMTPS id 849E920145 for ; Fri, 1 Apr 2016 15:53:34 +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 1am1Lu-0004xT-Ot; Fri, 01 Apr 2016 15:51:14 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1am1Lu-0004wn-62 for xen-devel@lists.xen.org; Fri, 01 Apr 2016 15:51:14 +0000 Received: from [193.109.254.147] by server-5.bemta-14.messagelabs.com id 83/5F-03497-1F89EF65; Fri, 01 Apr 2016 15:51:13 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrKIsWRWlGSWpSXmKPExsVyMfSOse6HGf/ CDGbeN7ZY8nExiwOjx9Hdv5kCGKNYM/OS8isSWDMOXm1mLpihXLHv8y32Bsbvsl2MXBxCAhMZ JXZvPMsG4rAIzGOWaPx3nR3EkRDoZ5WYP+sgYxcjB5ATI3HnhH8XIyeQWSnx7dsnRhBbSEBNY tnhhcwQk54wSkz4f54FJMEmoCPxYtJONpBeEQEPiT0fa0HCzALnmCQ+z2YHsYUFfCRWTnwIZr MIqEpsfr0YbCYvUPn5T5uYIHbJSZw//pMZxOYEik/+94oFYq+7xMNZs9gnMAosYGRYxahRnFp Ullqka2ihl1SUmZ5RkpuYmaNraGiil5taXJyYnpqTmFSsl5yfu4kRGFj1DAyMOxiPbPc8xCjJ waQkyms47V+YEF9SfkplRmJxRnxRaU5q8SFGGQ4OJQneJ9OBcoJFqempFWmZOcAQh0lLcPAoi fDWgqR5iwsSc4sz0yFSpxiNObb8vraWiWPb1HtrmYRY8vLzUqXEeQ+ClAqAlGaU5sENgsXeJU ZZKWFeRgYGBiGegtSi3MwSVPlXjOIcjErCvK9ApvBk5pXA7XsFdAoT0Ckd0mCnlCQipKQaGFX LOs9aPb3OqhyyMktF/ULlTwWdifuPfZQx2JWXe/uX5AUjg6MSTisrrLeZW7Y0vmlfv09U+fqC 582Lq5RCd/nwLvP+wiky6SzXZb/UjPvn7go8OiYV/KU90q4/4NQlo93cM8/Kf86XTNLmE9zjb OUXcbbjyMVJ3+zav77K/Kr05fIM7pLJl5VYijMSDbWYi4oTAVVyJ0y4AgAA X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-11.tower-27.messagelabs.com!1459525871!26491404!1 X-Originating-IP: [209.85.220.51] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.28; banners=-,-,- X-VirusChecked: Checked Received: (qmail 37456 invoked from network); 1 Apr 2016 15:51:12 -0000 Received: from mail-pa0-f51.google.com (HELO mail-pa0-f51.google.com) (209.85.220.51) by server-11.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 1 Apr 2016 15:51:12 -0000 Received: by mail-pa0-f51.google.com with SMTP id td3so93493723pab.2 for ; Fri, 01 Apr 2016 08:51:12 -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=iSZ52egyHaz291xkpxKSTgmZXQQh4Z28P+eMY3WYeMY=; b=iwSqaOOCmW9Jn0ZN0zdt1lnOTOdMANokCTmQrOCc7T1gf2ALWpbGmlbukwerp0NTIf rkUbh2GGVwifO0MOw791ps6v4GSwczPoAQDTYStfu8K3GwBHqf4tmofLXRdkLOmWw83y LmydVQGM1AAexbjhNxSCFtgxkVYdYkbFfB5Vo= 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=iSZ52egyHaz291xkpxKSTgmZXQQh4Z28P+eMY3WYeMY=; b=THiXsHUsp6YyzybIPEPBymFwaj8w7TLgEZDGY0BZ8rejX8g74Fum/VK/pEabwmzPSN a/xxGSiUaBPvFa9DdES9dE+yIYjiybhVwpb42u052P+Yi4za+54TXnTeDpeD0a9W0H8S IJl8MQP05lrvupMmbqxkKQaLqu4Zf9CKTXPyhlU1x+aDKg2AO2+6PB3mDit39oUumSga 7c5DHT+9TjiyN1nQmjF2RBfzZvj/N+AZ1UuC+DrQv0E1++ocz5lDo1XRteR8OuLsXDF4 m/EFz+yMXCLNEHFtqay28Vmp+iYQbjOtYR4gDfcjUSb4SsHukrfqSwQGdjJhu3rT9VdQ ZIMQ== X-Gm-Message-State: AD7BkJL2u4bkt1RyxxeHUcbZgifkIHjMaKJQfIyVjRIWz9ilXln7rLFxBvtdr9V7vNCVnM/s X-Received: by 10.67.6.10 with SMTP id cq10mr32018849pad.120.1459525870955; Fri, 01 Apr 2016 08:51:10 -0700 (PDT) Received: from localhost.localdomain ([167.160.116.218]) by smtp.gmail.com with ESMTPSA id yj1sm22536791pac.16.2016.04.01.08.51.02 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 01 Apr 2016 08:51:08 -0700 (PDT) From: Shannon Zhao To: linux-arm-kernel@lists.infradead.org, stefano.stabellini@citrix.com Date: Fri, 1 Apr 2016 23:49:09 +0800 Message-Id: <1459525755-36968-12-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1459525755-36968-1-git-send-email-shannon.zhao@linaro.org> References: <1459525755-36968-1-git-send-email-shannon.zhao@linaro.org> Cc: devicetree@vger.kernel.org, linux-efi@vger.kernel.org, Russell King , catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, peter.huangpeng@huawei.com, julien.grall@arm.com, david.vrabel@citrix.com, zhaoshenglong@huawei.com, xen-devel@lists.xen.org, shannon.zhao@linaro.org Subject: [Xen-devel] [PATCH v10 11/17] ARM: XEN: Move xen_early_init() before efi_init() 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" X-Spam-Status: No, score=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, 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 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. Cc: Russell King Signed-off-by: Shannon Zhao Reviewed-by: Stefano Stabellini Reviewed-by: Julien Grall --- arch/arm/kernel/setup.c | 2 +- arch/arm/xen/enlighten.c | 56 ++++++++++++++++++++++++++++++++++------------- arch/arm64/kernel/setup.c | 2 +- 3 files changed, 43 insertions(+), 17 deletions(-) diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index 139791e..5bc7516 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -1035,6 +1035,7 @@ void __init setup_arch(char **cmdline_p) early_paging_init(mdesc); #endif setup_dma_zone(mdesc); + xen_early_init(); efi_init(); sanity_check_meminfo(); arm_memblock_init(mdesc); @@ -1051,7 +1052,6 @@ void __init setup_arch(char **cmdline_p) arm_dt_init_cpu_maps(); psci_dt_init(); - xen_early_init(); #ifdef CONFIG_SMP if (is_smp()) { if (!mdesc->smp_init || !mdesc->smp_init()) { diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 06bd61a..13e3e9f 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -53,8 +54,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, @@ -238,6 +237,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; +} hyper_node = {"xen,xen", "xen,xen-", NULL, false}; + +static int __init fdt_find_hyper_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, hyper_node.compat)) + hyper_node.found = true; + + s = of_get_flat_dt_prop(node, "compatible", &len); + if (strlen(hyper_node.prefix) + 3 < len && + !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix))) + hyper_node.version = s + strlen(hyper_node.prefix); + + return 0; +} + /* * see Documentation/devicetree/bindings/arm/xen.txt for the * documentation of the Xen Device Tree format. @@ -245,26 +271,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_hyper_node, NULL); + if (!hyper_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 (hyper_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", hyper_node.version); xen_domain_type = XEN_HVM_DOMAIN; @@ -305,6 +323,14 @@ static void __init xen_acpi_guest_init(void) static void __init xen_dt_guest_init(void) { + struct device_node *xen_node; + + xen_node = of_find_compatible_node(NULL, NULL, "xen,xen"); + if (!xen_node) { + pr_err("Xen support was detected before, but it has disappeared\n"); + return; + } + 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 9dc6776..7cf992f 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -320,6 +320,7 @@ void __init setup_arch(char **cmdline_p) */ cpu_uninstall_idmap(); + xen_early_init(); efi_init(); arm64_memblock_init(); @@ -341,7 +342,6 @@ void __init setup_arch(char **cmdline_p) } else { psci_acpi_init(); } - xen_early_init(); cpu_read_bootcpu_ops(); smp_init_cpus();