From patchwork Thu Jul 26 15:33:54 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 1243781 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 28DF53FC33 for ; Thu, 26 Jul 2012 16:24:20 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1SuQjs-0002Nq-Kc; Thu, 26 Jul 2012 16:16:36 +0000 Received: from smtp02.citrix.com ([66.165.176.63]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1SuQR1-0006Me-Rr for linux-arm-kernel@lists.infradead.org; Thu, 26 Jul 2012 15:57:10 +0000 X-IronPort-AV: E=Sophos;i="4.77,659,1336363200"; d="scan'208";a="203311712" Received: from ftlpmailmx02.citrite.net ([10.13.107.66]) by FTLPIPO02.CITRIX.COM with ESMTP/TLS/RC4-MD5; 26 Jul 2012 11:56:55 -0400 Received: from ukmail1.uk.xensource.com (10.80.16.128) by smtprelay.citrix.com (10.13.107.66) with Microsoft SMTP Server id 8.3.213.0; Thu, 26 Jul 2012 11:56:55 -0400 Received: from kaball.uk.xensource.com ([10.80.2.59]) by ukmail1.uk.xensource.com with esmtp (Exim 4.69) (envelope-from ) id 1SuQ5N-0006qa-34; Thu, 26 Jul 2012 16:34:45 +0100 From: Stefano Stabellini To: Subject: [PATCH 12/24] xen/arm: Introduce xen_guest_init Date: Thu, 26 Jul 2012 16:33:54 +0100 Message-ID: <1343316846-25860-12-git-send-email-stefano.stabellini@eu.citrix.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Note: CRM114 invocation failed X-Spam-Note: SpamAssassin invocation failed Cc: xen-devel@lists.xensource.com, linaro-dev@lists.linaro.org, Ian.Campbell@citrix.com, arnd@arndb.de, konrad.wilk@oracle.com, catalin.marinas@arm.com, Stefano Stabellini , tim@xen.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org We used to rely on a core_initcall to initialize Xen on ARM, however core_initcalls are actually called after early consoles are initialized. That means that hvc_xen.c is going to be initialized before Xen. Given the lack of a better alternative, just call a new Xen initialization function (xen_guest_init) from xen_cons_init. xen_guest_init has to be arch independent, so write both an ARM and an x86 implementation. The x86 implementation is currently empty because we can be sure that xen_hvm_guest_init is called early enough. Signed-off-by: Stefano Stabellini --- arch/arm/xen/enlighten.c | 7 ++++++- arch/x86/xen/enlighten.c | 8 ++++++++ drivers/tty/hvc/hvc_xen.c | 7 ++++++- include/xen/xen.h | 2 ++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 8c923af..dc68074 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -44,7 +44,7 @@ EXPORT_SYMBOL_GPL(xen_remap_domain_mfn_range); * - one interrupt for Xen event notifications; * - one memory region to map the grant_table. */ -static int __init xen_guest_init(void) +int __init xen_guest_init(void) { int cpu; struct xen_add_to_physmap xatp; @@ -58,6 +58,10 @@ static int __init xen_guest_init(void) } xen_domain_type = XEN_HVM_DOMAIN; + /* already setup */ + if (shared_info_page != 0 && HYPERVISOR_shared_info == shared_info_page) + return 0; + if (!shared_info_page) shared_info_page = (struct shared_info *) get_zeroed_page(GFP_KERNEL); @@ -88,4 +92,5 @@ static int __init xen_guest_init(void) } return 0; } +EXPORT_SYMBOL_GPL(xen_guest_init); core_initcall(xen_guest_init); diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c index ff962d4..6131d43 100644 --- a/arch/x86/xen/enlighten.c +++ b/arch/x86/xen/enlighten.c @@ -1567,4 +1567,12 @@ const struct hypervisor_x86 x86_hyper_xen_hvm __refconst = { .init_platform = xen_hvm_guest_init, }; EXPORT_SYMBOL(x86_hyper_xen_hvm); + +int __init xen_guest_init(void) +{ + /* do nothing: rely on x86_hyper_xen_hvm for the initialization */ + return 0; + +} +EXPORT_SYMBOL_GPL(xen_guest_init); #endif diff --git a/drivers/tty/hvc/hvc_xen.c b/drivers/tty/hvc/hvc_xen.c index dc07f56..3c04fb8 100644 --- a/drivers/tty/hvc/hvc_xen.c +++ b/drivers/tty/hvc/hvc_xen.c @@ -577,6 +577,12 @@ static void __exit xen_hvc_fini(void) static int xen_cons_init(void) { const struct hv_ops *ops; + int r; + + /* retrieve xen infos */ + r = xen_guest_init(); + if (r < 0) + return r; if (!xen_domain()) return 0; @@ -584,7 +590,6 @@ static int xen_cons_init(void) if (xen_initial_domain()) ops = &dom0_hvc_ops; else { - int r; ops = &domU_hvc_ops; if (xen_hvm_domain()) diff --git a/include/xen/xen.h b/include/xen/xen.h index 2c0d3a5..792a4d2 100644 --- a/include/xen/xen.h +++ b/include/xen/xen.h @@ -9,8 +9,10 @@ enum xen_domain_type { #ifdef CONFIG_XEN extern enum xen_domain_type xen_domain_type; +int xen_guest_init(void); #else #define xen_domain_type XEN_NATIVE +static inline int xen_guest_init(void) { return 0; } #endif #define xen_domain() (xen_domain_type != XEN_NATIVE)