From patchwork Thu Feb 12 06:34:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 44588 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ee0-f69.google.com (mail-ee0-f69.google.com [74.125.83.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A41102151D for ; Thu, 12 Feb 2015 06:36:48 +0000 (UTC) Received: by mail-ee0-f69.google.com with SMTP id b15sf5606827eek.0 for ; Wed, 11 Feb 2015 22:36:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=ARrPdFfD4Wlhtz3AUVi62i5DSamCHqkO14xso3LMYZg=; b=XRv08XsOJA+BQ9RNO/vN2Xrge+x5v7WBStMOSS9u16db5JIIby6p3LvfprvJwWPkOt HSFLM1jR4qXoioh6wvoFKZSeq6TOxmdEEZQmI5Mat1nxf4OTet7qZG69UmuyY0OeEqjR lTnkT1BqNKsxjyMody51n21A8/FDQjfMOszuDVVYfkIy2KUXXAm/D6TXGb92Z8KnCCQy 0Jjd2ddyJ5HR3gZJv1/nqVPgN/9m4GcSbKiGwcSEBc5rrNUIrGFgMU0paY4Q1wTiraEJ F1iFt+P+PmTyPngMYJADZ7ASvwpd+TR8aPF3MfI9QZ63aZeUb+NKCQCGnLElNO0cZwJk qukg== X-Gm-Message-State: ALoCoQlO8aEUnra58MfOu0dwo7VLq5auu+esEjMJyecoex6qoeRFS2c1s4S+HDgvlldfZFUV03BB X-Received: by 10.112.45.197 with SMTP id p5mr299987lbm.18.1423723007771; Wed, 11 Feb 2015 22:36:47 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.116.115 with SMTP id jv19ls144042lab.64.gmail; Wed, 11 Feb 2015 22:36:47 -0800 (PST) X-Received: by 10.112.25.104 with SMTP id b8mr1782223lbg.69.1423723007624; Wed, 11 Feb 2015 22:36:47 -0800 (PST) Received: from mail-lb0-f179.google.com (mail-lb0-f179.google.com. [209.85.217.179]) by mx.google.com with ESMTPS id z5si2207313lbk.126.2015.02.11.22.36.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Feb 2015 22:36:47 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) client-ip=209.85.217.179; Received: by mail-lb0-f179.google.com with SMTP id w7so7635477lbi.10 for ; Wed, 11 Feb 2015 22:36:47 -0800 (PST) X-Received: by 10.152.26.199 with SMTP id n7mr1812279lag.29.1423723007497; Wed, 11 Feb 2015 22:36:47 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp254634lbj; Wed, 11 Feb 2015 22:36:46 -0800 (PST) X-Received: by 10.221.58.204 with SMTP id wl12mr1741936vcb.78.1423723006093; Wed, 11 Feb 2015 22:36:46 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id l17si2006173vcp.91.2015.02.11.22.36.45 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 11 Feb 2015 22:36:46 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YLnMl-0001OE-Qc; Thu, 12 Feb 2015 06:35:11 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YLnMj-0001Nd-RO for xen-devel@lists.xenproject.org; Thu, 12 Feb 2015 06:35:10 +0000 Received: from [85.158.139.211] by server-15.bemta-5.messagelabs.com id 3F/50-02758-D994CD45; Thu, 12 Feb 2015 06:35:09 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-15.tower-206.messagelabs.com!1423722905!8113760!1 X-Originating-IP: [209.85.220.42] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.13.4; banners=-,-,- X-VirusChecked: Checked Received: (qmail 11431 invoked from network); 12 Feb 2015 06:35:06 -0000 Received: from mail-pa0-f42.google.com (HELO mail-pa0-f42.google.com) (209.85.220.42) by server-15.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 12 Feb 2015 06:35:06 -0000 Received: by mail-pa0-f42.google.com with SMTP id rd3so9360656pab.1 for ; Wed, 11 Feb 2015 22:35:05 -0800 (PST) X-Received: by 10.70.88.199 with SMTP id bi7mr3936467pdb.126.1423722905010; Wed, 11 Feb 2015 22:35:05 -0800 (PST) Received: from localhost.localdomain.localdomain ([210.177.145.249]) by mx.google.com with ESMTPSA id dx6sm2696149pab.14.2015.02.11.22.35.02 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Feb 2015 22:35:04 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org, linux-arm-kernel@lists.infradead.org Date: Thu, 12 Feb 2015 06:34:58 +0000 Message-Id: <1423722898-16110-3-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1423722898-16110-1-git-send-email-julien.grall@linaro.org> References: <1423722898-16110-1-git-send-email-julien.grall@linaro.org> Cc: Russell King , ian.campbell@citrix.com, ard.biesheuvel@linaro.org, Catalin Marinas , Julien Grall , Will Deacon , stefano.stabellini@eu.citrix.com Subject: [Xen-devel] [PATCH 2/2] arm, arm64/xen: move Xen initialization earlier X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.179 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Archive: From: Stefano Stabellini Currently, Xen is initialized/discovered in an initcall. This doesn't allow us to support earlyprintk or choosing the preferred console when running on Xen. The current function xen_guest_init is now split in 2 parts: - xen_early_init: Check if there is a Xen node in the device tree and setup domain type - xen_guest_init: Retrieve the information from the device node and initialize Xen (grant table, shared page...) The former is called in setup_arch, while the latter is an initcall. Signed-off-by: Stefano Stabellini Signed-off-by: Julien Grall Cc: Russell King Cc: Catalin Marinas Cc: Will Deacon --- It's based on a patch sent by Stefano nearly 2 years ago [1]. [1] http://lists.xen.org/archives/html/xen-devel/2013-08/msg02960.html --- arch/arm/include/asm/xen/hypervisor.h | 8 +++++ arch/arm/kernel/setup.c | 2 ++ arch/arm/xen/enlighten.c | 58 ++++++++++++++++++++--------------- arch/arm64/kernel/setup.c | 2 ++ 4 files changed, 46 insertions(+), 24 deletions(-) diff --git a/arch/arm/include/asm/xen/hypervisor.h b/arch/arm/include/asm/xen/hypervisor.h index 1317ee4..04ff8e7 100644 --- a/arch/arm/include/asm/xen/hypervisor.h +++ b/arch/arm/include/asm/xen/hypervisor.h @@ -1,6 +1,8 @@ #ifndef _ASM_ARM_XEN_HYPERVISOR_H #define _ASM_ARM_XEN_HYPERVISOR_H +#include + extern struct shared_info *HYPERVISOR_shared_info; extern struct start_info *xen_start_info; @@ -18,4 +20,10 @@ static inline enum paravirt_lazy_mode paravirt_get_lazy_mode(void) extern struct dma_map_ops *xen_dma_ops; +#ifdef CONFIG_XEN +void __init xen_early_init(void); +#else +static inline void xen_early_init(void) { return; } +#endif + #endif /* _ASM_ARM_XEN_HYPERVISOR_H */ diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c index e55408e..8b59d0d 100644 --- a/arch/arm/kernel/setup.c +++ b/arch/arm/kernel/setup.c @@ -46,6 +46,7 @@ #include #include #include +#include #include #include @@ -936,6 +937,7 @@ void __init setup_arch(char **cmdline_p) arm_dt_init_cpu_maps(); psci_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 90101c8..0abeefa 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -53,6 +53,8 @@ EXPORT_SYMBOL_GPL(xen_platform_pci_unplug); static unsigned int xen_events_irq; +static __initdata struct device_node *xen_node; + /* map fgmfn of domid to lpfn in the current domain */ static int map_foreign_page(unsigned long lpfn, unsigned long fgmfn, unsigned int domid) @@ -222,42 +224,28 @@ static irqreturn_t xen_arm_callback(int irq, void *arg) * documentation of the Xen Device Tree format. */ #define GRANT_TABLE_PHYSADDR 0 -static int __init xen_guest_init(void) +void __init xen_early_init(void) { - struct xen_add_to_physmap xatp; - static struct shared_info *shared_info_page = 0; - struct device_node *node; int len; const char *s = NULL; const char *version = NULL; const char *xen_prefix = "xen,xen-"; - struct resource res; - phys_addr_t grant_frames; - node = of_find_compatible_node(NULL, NULL, "xen,xen"); - if (!node) { + xen_node = of_find_compatible_node(NULL, NULL, "xen,xen"); + if (!xen_node) { pr_debug("No Xen support\n"); - return 0; + return; } - s = of_get_property(node, "compatible", &len); + 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) { pr_debug("Xen version not found\n"); - return 0; - } - if (of_address_to_resource(node, GRANT_TABLE_PHYSADDR, &res)) - return 0; - grant_frames = res.start; - xen_events_irq = irq_of_parse_and_map(node, 0); - if (!xen_events_irq) { - pr_debug("Xen event channel interrupt not found\n"); - return -ENODEV; + return; } - pr_info("Xen %s support found, events_irq=%d gnttab_frame=%pa\n", - version, xen_events_irq, &grant_frames); + pr_info("Xen %s support found\n", version); xen_domain_type = XEN_HVM_DOMAIN; @@ -267,10 +255,32 @@ static int __init xen_guest_init(void) xen_start_info->flags |= SIF_INITDOMAIN|SIF_PRIVILEGED; else xen_start_info->flags &= ~(SIF_INITDOMAIN|SIF_PRIVILEGED); +} + +static int __init xen_guest_init(void) +{ + struct xen_add_to_physmap xatp; + struct shared_info *shared_info_page = NULL; + struct resource res; + phys_addr_t grant_frames; + + if (!xen_domain()) + return 0; + + if (of_address_to_resource(xen_node, GRANT_TABLE_PHYSADDR, &res)) { + pr_err("Xen grant table base address not found\n"); + return -ENODEV; + } + grant_frames = res.start; + + xen_events_irq = irq_of_parse_and_map(xen_node, 0); + if (!xen_events_irq) { + pr_err("Xen event channel interrupt not found\n"); + return -ENODEV; + } + + shared_info_page = (struct shared_info *)get_zeroed_page(GFP_KERNEL); - if (!shared_info_page) - shared_info_page = (struct shared_info *) - get_zeroed_page(GFP_KERNEL); if (!shared_info_page) { pr_err("not enough memory\n"); return -ENOMEM; diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c index e8420f6..c00ae01 100644 --- a/arch/arm64/kernel/setup.c +++ b/arch/arm64/kernel/setup.c @@ -62,6 +62,7 @@ #include #include #include +#include unsigned int processor_id; EXPORT_SYMBOL(processor_id); @@ -388,6 +389,7 @@ void __init setup_arch(char **cmdline_p) unflatten_device_tree(); psci_init(); + xen_early_init(); cpu_read_bootcpu_ops(); #ifdef CONFIG_SMP