From patchwork Thu Mar 24 14:44:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 8661741 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9717F9F36E for ; Thu, 24 Mar 2016 14:50:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8E80B203B6 for ; Thu, 24 Mar 2016 14:50:09 +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 9D4C9203A0 for ; Thu, 24 Mar 2016 14:50:08 +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 1aj6YD-0003Ow-LY; Thu, 24 Mar 2016 14:47:53 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1aj6YB-0003Nn-W9 for xen-devel@lists.xen.org; Thu, 24 Mar 2016 14:47:52 +0000 Received: from [85.158.139.211] by server-4.bemta-5.messagelabs.com id E6/1C-20731-71EF3F65; Thu, 24 Mar 2016 14:47:51 +0000 X-Env-Sender: shannon.zhao@linaro.org X-Msg-Ref: server-9.tower-206.messagelabs.com!1458830869!31281627!1 X-Originating-IP: [209.85.192.171] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 16252 invoked from network); 24 Mar 2016 14:47:50 -0000 Received: from mail-pf0-f171.google.com (HELO mail-pf0-f171.google.com) (209.85.192.171) by server-9.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 24 Mar 2016 14:47:50 -0000 Received: by mail-pf0-f171.google.com with SMTP id x3so59448702pfb.1 for ; Thu, 24 Mar 2016 07:47:50 -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=/JfdRIt+dbFvzE1r7m7ANfVpO8z0cANkZTrNVxGJYm0=; b=EsiMbx/T33XYWmeRz9CWTj1D+iLGdTAeNxyZAwhIkyewP5S4q99gT5wACb2uzGTYlW qXSB7JLXE2HUDsOvTTKlXH54lWFyZH4DgQZ+NJf/q0Ps1AADXiF7pBmLNm/LVff9J92E hvH474y+Km3SisXR+CdGEZVLXrU0D9OecMRNQ= 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=/JfdRIt+dbFvzE1r7m7ANfVpO8z0cANkZTrNVxGJYm0=; b=LksZ+wtSqaWnDaL1iUmxqFoNRuah+14ywEcdVMHoQkLhHau86hkBD0Dv8/27Sv5bIA DBxSW3C7i1OVu8e/ZvZKFdGBsyfw1iWUdiXsuD3xzbqekrQZMGVj/BHG7eaS9dqq08e+ sEgAB4ENXwvuuIOvXKQ6MFrXLh24yFhLDZLkO+bhEUtCf07gy2LGuOYBpPZZ0vZetlv6 oLE6Ee0ls8M9mUD+dacIRqW6FpIqv56GXgYzUqAJztsdD3n7EwC/3OUPB9pJ/97DX94v HE2h/R6lZujgiB8/Zxd9zfNQXxoWAl5GOMhJ1O+9TityKDxxH0+etI0BmGDld6dhjSVb HBmw== X-Gm-Message-State: AD7BkJKN2M5q7HT2DeTXc4q0OX9GRJwHk/HgLLpJzgsYxBymyTsGJEH84PcVJbuUOtcHfrJ5 X-Received: by 10.98.68.91 with SMTP id r88mr13445439pfa.12.1458830869143; Thu, 24 Mar 2016 07:47:49 -0700 (PDT) Received: from localhost.localdomain ([104.238.45.135]) by smtp.gmail.com with ESMTPSA id lq10sm10780673pab.36.2016.03.24.07.47.40 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 24 Mar 2016 07:47:47 -0700 (PDT) From: Shannon Zhao To: linux-arm-kernel@lists.infradead.org, stefano.stabellini@citrix.com, david.vrabel@citrix.com Date: Thu, 24 Mar 2016 22:44:30 +0800 Message-Id: <1458830676-27075-12-git-send-email-shannon.zhao@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1458830676-27075-1-git-send-email-shannon.zhao@linaro.org> References: <1458830676-27075-1-git-send-email-shannon.zhao@linaro.org> Cc: devicetree@vger.kernel.org, linux-efi@vger.kernel.org, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, peter.huangpeng@huawei.com, julien.grall@arm.com, shannon.zhao@linaro.org, zhaoshenglong@huawei.com, xen-devel@lists.xen.org Subject: [Xen-devel] [PATCH v7 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. Signed-off-by: Shannon Zhao Reviewed-by: Stefano Stabellini --- arch/arm/xen/enlighten.c | 56 ++++++++++++++++++++++++++++++++++------------- arch/arm64/kernel/setup.c | 2 +- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 680aae0..c43617f 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 450987d..6cf5051 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();