Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1364230 > unrolled thread

[PATCH v7 11/17] ARM: XEN: Move xen_early_init() before efi_init()

Started byShannon Zhao <shannon.zhao@linaro.org>
First post2016-03-24 15:50 +0100
Last post2016-03-31 13:20 +0200
Articles 4 — 3 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH v7 11/17] ARM: XEN: Move xen_early_init() before efi_init() Shannon Zhao <shannon.zhao@linaro.org> - 2016-03-24 15:50 +0100
    Re: [PATCH v7 11/17] ARM: XEN: Move xen_early_init() before  efi_init() Stefano Stabellini <stefano.stabellini@eu.citrix.com> - 2016-03-26 14:00 +0100
      Re: [PATCH v7 11/17] ARM: XEN: Move xen_early_init() before  efi_init() Will Deacon <will.deacon@arm.com> - 2016-03-29 18:10 +0200
        Re: [Xen-devel] [PATCH v7 11/17] ARM: XEN: Move xen_early_init()  before efi_init() Stefano Stabellini <stefano.stabellini@eu.citrix.com> - 2016-03-31 13:20 +0200

#1364230 — [PATCH v7 11/17] ARM: XEN: Move xen_early_init() before efi_init()

FromShannon Zhao <shannon.zhao@linaro.org>
Date2016-03-24 15:50 +0100
Subject[PATCH v7 11/17] ARM: XEN: Move xen_early_init() before efi_init()
Message-ID<rgeKf-3Y1-47@gated-at.bofh.it>
Move xen_early_init() before efi_init(), then when calling efi_init()
could initialize Xen specific UEFI.

Check if it runs on Xen hypervisor through the flat dts.

Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 arch/arm/xen/enlighten.c  | 56 ++++++++++++++++++++++++++++++++++-------------
 arch/arm64/kernel/setup.c |  2 +-
 2 files changed, 42 insertions(+), 16 deletions(-)

diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
index 680aae0..c43617f 100644
--- a/arch/arm/xen/enlighten.c
+++ b/arch/arm/xen/enlighten.c
@@ -20,6 +20,7 @@
 #include <linux/irqreturn.h>
 #include <linux/module.h>
 #include <linux/of.h>
+#include <linux/of_fdt.h>
 #include <linux/of_irq.h>
 #include <linux/of_address.h>
 #include <linux/cpuidle.h>
@@ -53,8 +54,6 @@ struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
 
 static __read_mostly unsigned int xen_events_irq;
 
-static __initdata struct device_node *xen_node;
-
 int xen_remap_domain_gfn_array(struct vm_area_struct *vma,
 			       unsigned long addr,
 			       xen_pfn_t *gfn, int nr,
@@ -238,6 +237,33 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
 	return IRQ_HANDLED;
 }
 
+static __initdata struct {
+	const char *compat;
+	const char *prefix;
+	const char *version;
+	bool found;
+} hyper_node = {"xen,xen", "xen,xen-", NULL, false};
+
+static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
+				      int depth, void *data)
+{
+	const void *s = NULL;
+	int len;
+
+	if (depth != 1 || strcmp(uname, "hypervisor") != 0)
+		return 0;
+
+	if (of_flat_dt_is_compatible(node, hyper_node.compat))
+		hyper_node.found = true;
+
+	s = of_get_flat_dt_prop(node, "compatible", &len);
+	if (strlen(hyper_node.prefix) + 3  < len &&
+	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
+		hyper_node.version = s + strlen(hyper_node.prefix);
+
+	return 0;
+}
+
 /*
  * see Documentation/devicetree/bindings/arm/xen.txt for the
  * documentation of the Xen Device Tree format.
@@ -245,26 +271,18 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
 #define GRANT_TABLE_PHYSADDR 0
 void __init xen_early_init(void)
 {
-	int len;
-	const char *s = NULL;
-	const char *version = NULL;
-	const char *xen_prefix = "xen,xen-";
-
-	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
-	if (!xen_node) {
+	of_scan_flat_dt(fdt_find_hyper_node, NULL);
+	if (!hyper_node.found) {
 		pr_debug("No Xen support\n");
 		return;
 	}
-	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) {
+
+	if (hyper_node.version == NULL) {
 		pr_debug("Xen version not found\n");
 		return;
 	}
 
-	pr_info("Xen %s support found\n", version);
+	pr_info("Xen %s support found\n", hyper_node.version);
 
 	xen_domain_type = XEN_HVM_DOMAIN;
 
@@ -305,6 +323,14 @@ static void __init xen_acpi_guest_init(void)
 
 static void __init xen_dt_guest_init(void)
 {
+	struct device_node *xen_node;
+
+	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
+	if (!xen_node) {
+		pr_err("Xen support was detected before, but it has disappeared\n");
+		return;
+	}
+
 	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
 }
 
diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
index 450987d..6cf5051 100644
--- a/arch/arm64/kernel/setup.c
+++ b/arch/arm64/kernel/setup.c
@@ -313,6 +313,7 @@ void __init setup_arch(char **cmdline_p)
 	 */
 	local_async_enable();
 
+	xen_early_init();
 	efi_init();
 	arm64_memblock_init();
 
@@ -334,7 +335,6 @@ void __init setup_arch(char **cmdline_p)
 	} else {
 		psci_acpi_init();
 	}
-	xen_early_init();
 
 	cpu_read_bootcpu_ops();
 	smp_init_cpus();
-- 
2.1.4

[toc] | [next] | [standalone]


#1364941 — Re: [PATCH v7 11/17] ARM: XEN: Move xen_early_init() before efi_init()

FromStefano Stabellini <stefano.stabellini@eu.citrix.com>
Date2016-03-26 14:00 +0100
SubjectRe: [PATCH v7 11/17] ARM: XEN: Move xen_early_init() before efi_init()
Message-ID<rgVYR-We-3@gated-at.bofh.it>
In reply to#1364230
Will, Catalin,

are you OK with this patch?

Thanks,

Stefano

On Thu, 24 Mar 2016, Shannon Zhao wrote:
> Move xen_early_init() before efi_init(), then when calling efi_init()
> could initialize Xen specific UEFI.
> 
> Check if it runs on Xen hypervisor through the flat dts.
> 
> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org>
> Reviewed-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> ---
>  arch/arm/xen/enlighten.c  | 56 ++++++++++++++++++++++++++++++++++-------------
>  arch/arm64/kernel/setup.c |  2 +-
>  2 files changed, 42 insertions(+), 16 deletions(-)
> 
> diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c
> index 680aae0..c43617f 100644
> --- a/arch/arm/xen/enlighten.c
> +++ b/arch/arm/xen/enlighten.c
> @@ -20,6 +20,7 @@
>  #include <linux/irqreturn.h>
>  #include <linux/module.h>
>  #include <linux/of.h>
> +#include <linux/of_fdt.h>
>  #include <linux/of_irq.h>
>  #include <linux/of_address.h>
>  #include <linux/cpuidle.h>
> @@ -53,8 +54,6 @@ struct xen_memory_region xen_extra_mem[XEN_EXTRA_MEM_MAX_REGIONS] __initdata;
>  
>  static __read_mostly unsigned int xen_events_irq;
>  
> -static __initdata struct device_node *xen_node;
> -
>  int xen_remap_domain_gfn_array(struct vm_area_struct *vma,
>  			       unsigned long addr,
>  			       xen_pfn_t *gfn, int nr,
> @@ -238,6 +237,33 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
>  	return IRQ_HANDLED;
>  }
>  
> +static __initdata struct {
> +	const char *compat;
> +	const char *prefix;
> +	const char *version;
> +	bool found;
> +} hyper_node = {"xen,xen", "xen,xen-", NULL, false};
> +
> +static int __init fdt_find_hyper_node(unsigned long node, const char *uname,
> +				      int depth, void *data)
> +{
> +	const void *s = NULL;
> +	int len;
> +
> +	if (depth != 1 || strcmp(uname, "hypervisor") != 0)
> +		return 0;
> +
> +	if (of_flat_dt_is_compatible(node, hyper_node.compat))
> +		hyper_node.found = true;
> +
> +	s = of_get_flat_dt_prop(node, "compatible", &len);
> +	if (strlen(hyper_node.prefix) + 3  < len &&
> +	    !strncmp(hyper_node.prefix, s, strlen(hyper_node.prefix)))
> +		hyper_node.version = s + strlen(hyper_node.prefix);
> +
> +	return 0;
> +}
> +
>  /*
>   * see Documentation/devicetree/bindings/arm/xen.txt for the
>   * documentation of the Xen Device Tree format.
> @@ -245,26 +271,18 @@ static irqreturn_t xen_arm_callback(int irq, void *arg)
>  #define GRANT_TABLE_PHYSADDR 0
>  void __init xen_early_init(void)
>  {
> -	int len;
> -	const char *s = NULL;
> -	const char *version = NULL;
> -	const char *xen_prefix = "xen,xen-";
> -
> -	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
> -	if (!xen_node) {
> +	of_scan_flat_dt(fdt_find_hyper_node, NULL);
> +	if (!hyper_node.found) {
>  		pr_debug("No Xen support\n");
>  		return;
>  	}
> -	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) {
> +
> +	if (hyper_node.version == NULL) {
>  		pr_debug("Xen version not found\n");
>  		return;
>  	}
>  
> -	pr_info("Xen %s support found\n", version);
> +	pr_info("Xen %s support found\n", hyper_node.version);
>  
>  	xen_domain_type = XEN_HVM_DOMAIN;
>  
> @@ -305,6 +323,14 @@ static void __init xen_acpi_guest_init(void)
>  
>  static void __init xen_dt_guest_init(void)
>  {
> +	struct device_node *xen_node;
> +
> +	xen_node = of_find_compatible_node(NULL, NULL, "xen,xen");
> +	if (!xen_node) {
> +		pr_err("Xen support was detected before, but it has disappeared\n");
> +		return;
> +	}
> +
>  	xen_events_irq = irq_of_parse_and_map(xen_node, 0);
>  }
>  
> diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> index 450987d..6cf5051 100644
> --- a/arch/arm64/kernel/setup.c
> +++ b/arch/arm64/kernel/setup.c
> @@ -313,6 +313,7 @@ void __init setup_arch(char **cmdline_p)
>  	 */
>  	local_async_enable();
>  
> +	xen_early_init();
>  	efi_init();
>  	arm64_memblock_init();
>  
> @@ -334,7 +335,6 @@ void __init setup_arch(char **cmdline_p)
>  	} else {
>  		psci_acpi_init();
>  	}
> -	xen_early_init();
>  
>  	cpu_read_bootcpu_ops();
>  	smp_init_cpus();
> -- 
> 2.1.4
> 

[toc] | [prev] | [next] | [standalone]


#1366420 — Re: [PATCH v7 11/17] ARM: XEN: Move xen_early_init() before efi_init()

FromWill Deacon <will.deacon@arm.com>
Date2016-03-29 18:10 +0200
SubjectRe: [PATCH v7 11/17] ARM: XEN: Move xen_early_init() before efi_init()
Message-ID<ri4no-iJ-7@gated-at.bofh.it>
In reply to#1364941
On Sat, Mar 26, 2016 at 12:54:09PM +0000, Stefano Stabellini wrote:
> are you OK with this patch?

Nothing against it, but the only arm64 bit is:

> > diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> > index 450987d..6cf5051 100644
> > --- a/arch/arm64/kernel/setup.c
> > +++ b/arch/arm64/kernel/setup.c
> > @@ -313,6 +313,7 @@ void __init setup_arch(char **cmdline_p)
> >  	 */
> >  	local_async_enable();
> >  
> > +	xen_early_init();
> >  	efi_init();
> >  	arm64_memblock_init();
> >  
> > @@ -334,7 +335,6 @@ void __init setup_arch(char **cmdline_p)
> >  	} else {
> >  		psci_acpi_init();
> >  	}
> > -	xen_early_init();

so it's difficult to care too much ;) I do hope that there won't be a
need to split up efi_init() in future because some of it has to happen
before xen_early_init, but that doesn't sound likely at the moment.

Will

[toc] | [prev] | [next] | [standalone]


#1368185 — Re: [Xen-devel] [PATCH v7 11/17] ARM: XEN: Move xen_early_init() before efi_init()

FromStefano Stabellini <stefano.stabellini@eu.citrix.com>
Date2016-03-31 13:20 +0200
SubjectRe: [Xen-devel] [PATCH v7 11/17] ARM: XEN: Move xen_early_init() before efi_init()
Message-ID<riINQ-451-25@gated-at.bofh.it>
In reply to#1366420
On Tue, 29 Mar 2016, Will Deacon wrote:
> On Sat, Mar 26, 2016 at 12:54:09PM +0000, Stefano Stabellini wrote:
> > are you OK with this patch?
> 
> Nothing against it, but the only arm64 bit is:
> 
> > > diff --git a/arch/arm64/kernel/setup.c b/arch/arm64/kernel/setup.c
> > > index 450987d..6cf5051 100644
> > > --- a/arch/arm64/kernel/setup.c
> > > +++ b/arch/arm64/kernel/setup.c
> > > @@ -313,6 +313,7 @@ void __init setup_arch(char **cmdline_p)
> > >  	 */
> > >  	local_async_enable();
> > >  
> > > +	xen_early_init();
> > >  	efi_init();
> > >  	arm64_memblock_init();
> > >  
> > > @@ -334,7 +335,6 @@ void __init setup_arch(char **cmdline_p)
> > >  	} else {
> > >  		psci_acpi_init();
> > >  	}
> > > -	xen_early_init();
> 
> so it's difficult to care too much ;)

Understood :-)


> I do hope that there won't be a
> need to split up efi_init() in future because some of it has to happen
> before xen_early_init, but that doesn't sound likely at the moment.

Right.

The series is almost fully acked, if you are OK with it, as soon as the
last couple of remaining comments are resolved, I'll queue it up in the
xentip tree for 4.7 (now it is too late for 4.6).

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web