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: 5817141 Return-Path: X-Original-To: patchwork-linux-arm@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 6B3109F380 for ; Thu, 12 Feb 2015 06:38:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 549402017D for ; Thu, 12 Feb 2015 06:37:59 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3DC0F20173 for ; Thu, 12 Feb 2015 06:37:58 +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 1YLnNO-0007Li-B5; Thu, 12 Feb 2015 06:35:50 +0000 Received: from mail-pa0-f44.google.com ([209.85.220.44]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YLnMx-0006lP-JU for linux-arm-kernel@lists.infradead.org; Thu, 12 Feb 2015 06:35:25 +0000 Received: by mail-pa0-f44.google.com with SMTP id kq14so9338258pab.3 for ; Wed, 11 Feb 2015 22:35:05 -0800 (PST) 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=Zd28lFlREXrYYdRNroOk/wRPWzGFbpUr1fCA9H+LegQ=; b=XhleQ6GXqdeTtxn2VhvAivnd51fG4qRAKE3wZGmY2vris9CGQgBMXhj41oTBmmV6Er TucOhivPzAg5HEB0cow4R7iLTwquKKYZ1OxjJ+3Ei2awF/DKQwrq3QQ1qcVwRn32Hh7l kZDn8mlqWcTD8NMvr6kfgGercDMocirAwj4o0c/OLgPB09SF9qVJUzmDGl8+7kFw0y0+ y4bTAzn9FB8CDzhogy6+SS6Gs1JiUlouEMnGvMJ+ie8nMe3szgH/8x0RlWSS3ldyvXTC ct2qlCMts82gu/rm2bfQ4w+01FGIn69ivSXH4542eTB8fh8O5xaLSKI0ZUhmoGxmZG3l o79A== X-Gm-Message-State: ALoCoQm9zn9HFpW1/4t+Q+fGBqVZ53Gzlvxea8o0KMvNaQvSGSYQLehhdKIL8y153VNwC/yV0n8b 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 Subject: [PATCH 2/2] arm,arm64/xen: move Xen initialization earlier 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150211_223523_715117_2B95D64E X-CRM114-Status: GOOD ( 19.43 ) X-Spam-Score: -0.7 (/) Cc: Russell King , ian.campbell@citrix.com, ard.biesheuvel@linaro.org, Catalin Marinas , Julien Grall , Will Deacon , stefano.stabellini@eu.citrix.com X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , 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.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, 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: 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