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: 44774 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-we0-f199.google.com (mail-we0-f199.google.com [74.125.82.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AEC7221544 for ; Wed, 18 Feb 2015 13:54:23 +0000 (UTC) Received: by wesk11 with SMTP id k11sf887282wes.3 for ; Wed, 18 Feb 2015 05:54:23 -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=fImPVbmjJ3wMJg1SgkNxdaXGZyOG6EMXrUWMMyP7wQQ=; b=E5ZiqYJJcxEvy2T7Vv5yOowGCNK8EEpw4Ej84l7RZuAe7ilMzTVcfJlg3Yg68kB8K2 kmxXyQqCQQrGHOoWWiw6ceZvvwzRnILyBdYrFTF+XNodysKfuLslBsNWiWMlgsvQKPEI 3JieRSvgR/BRUjYdWGj8SxvKksJy0iw35LV7Da0MvYcapKoTQV7hYPCKJxs21bZVqhG4 dh1iXDEtD00vDNmMxWalEMXxtRWqglBVsC/U0LoZMuAxFNQMQdjvRX45VqP5LtJYZY4W oU4P2nceTpSH03MiEK4I4q62I+u9+WOE3fGYDSHn/Csj4D1lq0bgtFfjl9mu1JG2mAJ7 MSqg== X-Gm-Message-State: ALoCoQmhnfmr9RCwPEeMFcjx0Rb2cQXqCopGiyGnnhp1W8/j2LXZhOSVrjFQgahCCQJt5PT32k7b X-Received: by 10.112.146.65 with SMTP id ta1mr1406652lbb.19.1424267662944; Wed, 18 Feb 2015 05:54:22 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.43.98 with SMTP id v2ls18514lal.104.gmail; Wed, 18 Feb 2015 05:54:22 -0800 (PST) X-Received: by 10.152.182.132 with SMTP id ee4mr30261533lac.50.1424267662649; Wed, 18 Feb 2015 05:54:22 -0800 (PST) Received: from mail-lb0-f178.google.com (mail-lb0-f178.google.com. [209.85.217.178]) by mx.google.com with ESMTPS id w1si12796212lal.38.2015.02.18.05.54.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Feb 2015 05:54:22 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.178 as permitted sender) client-ip=209.85.217.178; Received: by lbiz11 with SMTP id z11so1199989lbi.5 for ; Wed, 18 Feb 2015 05:54:22 -0800 (PST) X-Received: by 10.152.88.4 with SMTP id bc4mr33894386lab.86.1424267662550; Wed, 18 Feb 2015 05:54:22 -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 h5csp2863108lbj; Wed, 18 Feb 2015 05:54:21 -0800 (PST) X-Received: by 10.52.135.80 with SMTP id pq16mr6706950vdb.3.1424267659389; Wed, 18 Feb 2015 05:54:19 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id xm6si10438625vdc.65.2015.02.18.05.54.18 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 18 Feb 2015 05:54:19 -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 1YO53S-0005vr-QY; Wed, 18 Feb 2015 13:52:42 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YO53R-0005uk-Ql for xen-devel@lists.xenproject.org; Wed, 18 Feb 2015 13:52:42 +0000 Received: from [193.109.254.147] by server-1.bemta-14.messagelabs.com id 6C/A0-02601-92994E45; Wed, 18 Feb 2015 13:52:41 +0000 X-Env-Sender: julien.grall@linaro.org X-Msg-Ref: server-7.tower-27.messagelabs.com!1424267558!14174192!1 X-Originating-IP: [74.125.82.180] 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 13995 invoked from network); 18 Feb 2015 13:52:38 -0000 Received: from mail-we0-f180.google.com (HELO mail-we0-f180.google.com) (74.125.82.180) by server-7.tower-27.messagelabs.com with RC4-SHA encrypted SMTP; 18 Feb 2015 13:52:38 -0000 Received: by wesw62 with SMTP id w62so1246723wes.9 for ; Wed, 18 Feb 2015 05:52:38 -0800 (PST) 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 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> Cc: ard.biesheuvel@linaro.org, ian.campbell@citrix.com, Stefano Stabellini , Julien Grall , tim@xen.org, leif.lindholm@linaro.org Subject: [Xen-devel] [PATCH v2 2/3] 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.178 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 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