From patchwork Wed Feb 18 13:51:52 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 5844171 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 8D0189F380 for ; Wed, 18 Feb 2015 13:55:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 89A4C20225 for ; Wed, 18 Feb 2015 13:55:41 +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 33D9920221 for ; Wed, 18 Feb 2015 13:55:39 +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 1YO54J-0007As-Ax; Wed, 18 Feb 2015 13:53:35 +0000 Received: from mail-wi0-f171.google.com ([209.85.212.171]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1YO53k-0006w9-3s for linux-arm-kernel@lists.infradead.org; Wed, 18 Feb 2015 13:53:02 +0000 Received: by mail-wi0-f171.google.com with SMTP id hi2so41111862wib.4 for ; Wed, 18 Feb 2015 05:52:38 -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=lFJudObO4HrDI4MNYEBZ8iRaheVZSdZ3Fz8O9XimagY=; b=lHcCoQLWHJdwpOmK4e+sUvMJTkogNBIi0YMpgjvjAPCgRu22DWuAU/+LrLap2Pbwfq Gal6nCe1AICodCaHzHZxc+XSLHbR5egdQ8YYsTsC5SZOCZpsXTvk1/szoSFC9KTm7P9M BihM7StOfzkNTRSFY+pYiTogzq8tGbHQTOwWMddxrceOR4+IeAfLHPQeVyegw6UsHE3s nRMbw0epKW2M5lbKZjB4I/SxpZkkfRvyrE7kJTK0/wDm3kEdtTWpvc+eXNYVqi7kPpx8 /O11mTxlv2OwriUNTd5djcxqAA7GBqTCqH08Qotk3OdJPZsKvzlsVCxR3B5wm0mdBLRd oX3A== X-Gm-Message-State: ALoCoQn0Ugq/OuxYjclHWnDp4AAVjQLShuqySAkRKt2zfYGW4lFi4om4TvM9/8oZnFWvDaw5v4UV X-Received: by 10.194.190.162 with SMTP id gr2mr73574536wjc.13.1424267556861; Wed, 18 Feb 2015 05:52:36 -0800 (PST) Received: from chilopoda.uk.xensource.com. ([185.25.64.249]) by mx.google.com with ESMTPSA id fo15sm29568440wic.19.2015.02.18.05.52.35 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 18 Feb 2015 05:52:36 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org, stefano.stabellini@citrix.com, linux-arm-kernel@lists.infradead.org, linux@arm.linux.org.uk, catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH v2 2/3] arm,arm64/xen: move Xen initialization earlier Date: Wed, 18 Feb 2015 13:51:52 +0000 Message-Id: <1424267513-15836-3-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1424267513-15836-1-git-send-email-julien.grall@linaro.org> References: <1424267513-15836-1-git-send-email-julien.grall@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150218_055300_515128_BCADEFC0 X-CRM114-Status: GOOD ( 18.80 ) X-Spam-Score: -0.7 (/) Cc: ard.biesheuvel@linaro.org, ian.campbell@citrix.com, Stefano Stabellini , Julien Grall , tim@xen.org, leif.lindholm@linaro.org 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 Acked-by: Ian Campbell 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 Changes in v2: - Add Ian's ack --- 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 c8d3a17..1660432 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 __read_mostly 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