Skip to contentSkip to conversation

arm/arm64: Detect Xen support earlier

PATCH In review Julien Grall 3 participants 21 messages Feb 12, 2015 – Feb 18, 2015

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover arm/arm64: Detect Xen support earlier

Hello,

This small patch series move the detection of running on Xen earlier. This is required in order to support earlyprintk via Xen and selecting the preferred console.

Ard, the patch to move the call earlier (see #2) differed from the one I sent you privately mostly because it's not possible to translate an IRQ before the GIC has been initialized.

Let me know if it works for you.

Sincerely yours,

Julien Grall (1):
arm/xen: Correctly check if the event channel interrupt is present

Stefano Stabellini (1):
arm,arm64/xen: move Xen initialization earlier

 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, 47 insertions(+), 23 deletions(-)
Signature · 1 line
2.1.0
#1 lore raw

PATCH 1/2 arm/xen: Correctly check if the event channel interrupt is present

The function irq_of_parse_and_map returns 0 when the IRQ is not found.

Furthermore xen_events_irq is only read when the CPU is bring up, so it's not necessary to use the attribute __read_mostly.

Lastly, move the check before notifying the user that we are running on Xen.

---
 arch/arm/xen/enlighten.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
arch/arm/xen/enlighten.c +6 -4
index 263a204..90101c8 100644
@@ -51,7 +51,7 @@ EXPORT_SYMBOL_GPL(xen_have_vector_callback);
 int xen_platform_pci_unplug = XEN_UNPLUG_ALL;
 EXPORT_SYMBOL_GPL(xen_platform_pci_unplug);
 
-static __read_mostly int xen_events_irq = -1;
+static unsigned int xen_events_irq;
 
 /* map fgmfn of domid to lpfn in the current domain */
 static int map_foreign_page(unsigned long lpfn, unsigned long fgmfn,
@@ -251,12 +251,14 @@ static int __init xen_guest_init(void)
 		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;
+	}
+
 	pr_info("Xen %s support found, events_irq=%d gnttab_frame=%pa\n",
 			version, xen_events_irq, &grant_frames);
 
-	if (xen_events_irq < 0)
-		return -ENODEV;
-
 	xen_domain_type = XEN_HVM_DOMAIN;
 
 	xen_setup_features();
Signature · 1 line
2.1.0
#2 lore raw

PATCH 1/2 arm/xen: Correctly check if the event channel interrupt is present

Quoted 4 lines · Julien Grall

The function irq_of_parse_and_map returns 0 when the IRQ is not found.

Furthermore xen_events_irq is only read when the CPU is bring up, so it's not necessary to use the attribute __read_mostly.

Part of the purpose of __read_mostly is to move such things out of sharing cachelines with other more hot read/write things, as much as it is to group all the "read only" things together.

#3 lore raw

PATCH 1/2 arm/xen: Correctly check if the event channel interrupt is present

Hi Ian,

Quoted 9 lines · Ian Campbell
Quoted 4 lines · Julien Grall

The function irq_of_parse_and_map returns 0 when the IRQ is not found.

Furthermore xen_events_irq is only read when the CPU is bring up, so it's not necessary to use the attribute __read_mostly.

Part of the purpose of __read_mostly is to move such things out of sharing cachelines with other more hot read/write things, as much as it is to group all the "read only" things together.

Hmmm... You are right. I didn't understand this macro like that.

I will resend the series with this patch drop and add Ard's patch [1].

Regards,

[1] https://patches.linaro.org/44633/

Signature · 1 line
Julien Grall
#4 lore raw

PATCH 1/2 arm/xen: Correctly check if the event channel interrupt is present

Quoted 9 lines · Julien Grall

Hi Ian,

Quoted 6 lines · Ian Campbell
Quoted 4 lines · Julien Grall

The function irq_of_parse_and_map returns 0 when the IRQ is not found.

Furthermore xen_events_irq is only read when the CPU is bring up, so it's not necessary to use the attribute __read_mostly.

Quoted 7 lines
Quoted 3 lines

Part of the purpose of __read_mostly is to move such things out of sharing cachelines with other more hot read/write things, as much as it is to group all the "read only" things together.

Hmmm... You are right. I didn't understand this macro like that.

I will resend the series with this patch drop and add Ard's patch [1].

Actually I'm stupid... This patch is still useful except the __read_mostly.

Quoted 5 lines

Regards,

[1] https://patches.linaro.org/44633/

Signature · 1 line
Julien Grall
#5 lore raw

Re: [PATCH 1/2] arm/xen: Correctly check if the event channel interrupt is present

In reply to Ian Campbell

Hi Ian,

Quoted 9 lines · Ian Campbell
Quoted 4 lines · Julien Grall

The function irq_of_parse_and_map returns 0 when the IRQ is not found.

Furthermore xen_events_irq is only read when the CPU is bring up, so it's not necessary to use the attribute __read_mostly.

Part of the purpose of __read_mostly is to move such things out of sharing cachelines with other more hot read/write things, as much as it is to group all the "read only" things together.

Hmmm... You are right. I didn't understand this macro like that.

I will resend the series with this patch drop and add Ard's patch [1].

Regards,

[1] https://patches.linaro.org/44633/

Signature · 1 line
Julien Grall
#6 lore raw

Re: [PATCH 1/2] arm/xen: Correctly check if the event channel interrupt is present

In reply to Julien Grall
Quoted 4 lines · Julien Grall

The function irq_of_parse_and_map returns 0 when the IRQ is not found.

Furthermore xen_events_irq is only read when the CPU is bring up, so it's not necessary to use the attribute __read_mostly.

Part of the purpose of __read_mostly is to move such things out of sharing cachelines with other more hot read/write things, as much as it is to group all the "read only" things together.

#7 lore raw

PATCH 1/2 arm/xen: Correctly check if the event channel interrupt is present

In reply to Julien Grall

The function irq_of_parse_and_map returns 0 when the IRQ is not found.

Furthermore xen_events_irq is only read when the CPU is bring up, so it's not necessary to use the attribute __read_mostly.

Lastly, move the check before notifying the user that we are running on Xen.

---
 arch/arm/xen/enlighten.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
arch/arm/xen/enlighten.c +6 -4
index 263a204..90101c8 100644
@@ -51,7 +51,7 @@ EXPORT_SYMBOL_GPL(xen_have_vector_callback);
 int xen_platform_pci_unplug = XEN_UNPLUG_ALL;
 EXPORT_SYMBOL_GPL(xen_platform_pci_unplug);
 
-static __read_mostly int xen_events_irq = -1;
+static unsigned int xen_events_irq;
 
 /* map fgmfn of domid to lpfn in the current domain */
 static int map_foreign_page(unsigned long lpfn, unsigned long fgmfn,
@@ -251,12 +251,14 @@ static int __init xen_guest_init(void)
 		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;
+	}
+
 	pr_info("Xen %s support found, events_irq=%d gnttab_frame=%pa\n",
 			version, xen_events_irq, &grant_frames);
 
-	if (xen_events_irq < 0)
-		return -ENODEV;
-
 	xen_domain_type = XEN_HVM_DOMAIN;
 
 	xen_setup_features();
Signature · 1 line
2.1.0
#8 lore raw

PATCH 2/2 arm,arm64/xen: move Xen initialization earlier

In reply to Julien Grall

From: Stefano Stabellini <[email protected]>

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.

Cc Russell King <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>

---
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(-)
arch/arm/include/asm/xen/hypervisor.h +8 -0
index 1317ee4..04ff8e7 100644
@@ -1,6 +1,8 @@
 #ifndef _ASM_ARM_XEN_HYPERVISOR_H
 #define _ASM_ARM_XEN_HYPERVISOR_H
 
+#include <linux/init.h>
+
 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 */
arch/arm/kernel/setup.c +2 -0
index e55408e..8b59d0d 100644
@@ -46,6 +46,7 @@
 #include <asm/cacheflush.h>
 #include <asm/cachetype.h>
 #include <asm/tlbflush.h>
+#include <asm/xen/hypervisor.h>
 
 #include <asm/prom.h>
 #include <asm/mach/arch.h>
@@ -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()) {
arch/arm/xen/enlighten.c +34 -24

92 lines not on this page · raw message

arch/arm64/kernel/setup.c +2 -0
index e8420f6..c00ae01 100644
@@ -62,6 +62,7 @@
 #include <asm/memblock.h>
 #include <asm/psci.h>
 #include <asm/efi.h>
+#include <asm/xen/hypervisor.h>
 
 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
Signature · 1 line
2.1.0
#9 lore raw

PATCH 2/2 arm, arm64/xen: move Xen initialization earlier

In reply to Julien Grall

From: Stefano Stabellini <[email protected]>

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.

Cc Russell King <[email protected]>
Cc Catalin Marinas <[email protected]>
Cc Will Deacon <[email protected]>

---
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(-)
arch/arm/include/asm/xen/hypervisor.h +8 -0
index 1317ee4..04ff8e7 100644
@@ -1,6 +1,8 @@
 #ifndef _ASM_ARM_XEN_HYPERVISOR_H
 #define _ASM_ARM_XEN_HYPERVISOR_H
 
+#include <linux/init.h>
+
 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 */
arch/arm/kernel/setup.c +2 -0
index e55408e..8b59d0d 100644
@@ -46,6 +46,7 @@
 #include <asm/cacheflush.h>
 #include <asm/cachetype.h>
 #include <asm/tlbflush.h>
+#include <asm/xen/hypervisor.h>
 
 #include <asm/prom.h>
 #include <asm/mach/arch.h>
@@ -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()) {
arch/arm/xen/enlighten.c +34 -24

92 lines not on this page · raw message

arch/arm64/kernel/setup.c +2 -0
index e8420f6..c00ae01 100644
@@ -62,6 +62,7 @@
 #include <asm/memblock.h>
 #include <asm/psci.h>
 #include <asm/efi.h>
+#include <asm/xen/hypervisor.h>
 
 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
Signature · 1 line
2.1.0
#10 lore raw

cover arm/arm64: Detect Xen support earlier

In reply to Julien Grall
Quoted 6 lines · Julien Grall

Hello,

This small patch series move the detection of running on Xen earlier. This is required in order to support earlyprintk via Xen and selecting the preferred console.

Quoted 6 lines

Ard, the patch to move the call earlier (see #2) differed from the one I sent you privately mostly because it's not possible to translate an IRQ before the GIC has been initialized.

Let me know if it works for you.

I have tested these patches with my preferred console patch on top, and it results in console output without having to pass 'console=hvc0' on the command line.

I didn't check anything else, nor do I have enough of a clue about Xen to notice anything else out of the ordinary

So FWIW,

Quoted 17 lines

Sincerely yours,

Julien Grall (1):
arm/xen: Correctly check if the event channel interrupt is present

Stefano Stabellini (1):
arm,arm64/xen: move Xen initialization earlier

 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, 47 insertions(+), 23 deletions(-)

--
2.1.0

Tested-by on the v1 series
#11 lore raw
In reply to Julien Grall
Quoted 6 lines · Julien Grall

Hello,

This small patch series move the detection of running on Xen earlier. This is required in order to support earlyprintk via Xen and selecting the preferred console.

Quoted 6 lines

Ard, the patch to move the call earlier (see #2) differed from the one I sent you privately mostly because it's not possible to translate an IRQ before the GIC has been initialized.

Let me know if it works for you.

I have tested these patches with my preferred console patch on top, and it results in console output without having to pass 'console=hvc0' on the command line.

I didn't check anything else, nor do I have enough of a clue about Xen to notice anything else out of the ordinary

So FWIW,

Quoted 17 lines

Sincerely yours,

Julien Grall (1):
arm/xen: Correctly check if the event channel interrupt is present

Stefano Stabellini (1):
arm,arm64/xen: move Xen initialization earlier

 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, 47 insertions(+), 23 deletions(-)

--
2.1.0

#12 lore raw

cover arm/arm64: Detect Xen support earlier

In reply to Julien Grall
Quoted 5 lines · Julien Grall

Hello,

This small patch series move the detection of running on Xen earlier. This is required in order to support earlyprintk via Xen and selecting the preferred console.

Thanks for doing this, having all of the init done in an initcall (even a relatively early one) has been a niggle I've wanted address for ages, for exactly earlyprintk and preferred console reasons.

I had a very minor comment on #1 but nonetheless both patches:

Ian.

#13 lore raw

cover arm/arm64: Detect Xen support earlier

Hi Ian,

Quoted 7 lines · Ian Campbell
Quoted 5 lines · Julien Grall

Hello,

This small patch series move the detection of running on Xen earlier. This is required in order to support earlyprintk via Xen and selecting the preferred console.

Quoted 6 lines

Thanks for doing this, having all of the init done in an initcall (even a relatively early one) has been a niggle I've wanted address for ages, for exactly earlyprintk and preferred console reasons.

I had a very minor comment on #1 but nonetheless both patches:

Can I keep you ack on the first one with the __read_mostly dropped?

Regards,

Signature · 1 line
Julien Grall
#14 lore raw

cover arm/arm64: Detect Xen support earlier

Quoted 10 lines · Julien Grall

Hi Ian,

Quoted 7 lines · Ian Campbell
Quoted 5 lines · Julien Grall

Hello,

This small patch series move the detection of running on Xen earlier. This is required in order to support earlyprintk via Xen and selecting the preferred console.

Quoted 8 lines
Quoted 6 lines

Thanks for doing this, having all of the init done in an initcall (even a relatively early one) has been a niggle I've wanted address for ages, for exactly earlyprintk and preferred console reasons.

I had a very minor comment on #1 but nonetheless both patches:

Can I keep you ack on the first one with the __read_mostly dropped?

Sure.

BTW, when reposting you might want to CC the arch/arm* maintainers on this intro mail as well as just the second patch.

Ian.

#15 lore raw

cover arm/arm64: Detect Xen support earlier

Quoted 18 lines · Ian Campbell
Quoted 17 lines · Julien Grall

Hi Ian,

Quoted 13 lines · Ian Campbell
Quoted 5 lines · Julien Grall

Hello,

This small patch series move the detection of running on Xen earlier. This is required in order to support earlyprintk via Xen and selecting the preferred console.

Thanks for doing this, having all of the init done in an initcall (even a relatively early one) has been a niggle I've wanted address for ages, for exactly earlyprintk and preferred console reasons.

I had a very minor comment on #1 but nonetheless both patches:

Quoted 6 lines
Quoted 1 line

Can I keep you ack on the first one with the __read_mostly dropped?

Sure.

BTW, when reposting you might want to CC the arch/arm* maintainers on this intro mail as well as just the second patch.

Ok. I wasn't sure if this patches should go via the Xen tree or ARM one.

Signature · 1 line
Julien Grall
#16 lore raw

cover arm/arm64: Detect Xen support earlier

Quoted 20 lines · Julien Grall
Quoted 18 lines · Ian Campbell
Quoted 17 lines · Julien Grall

Hi Ian,

Quoted 13 lines · Ian Campbell
Quoted 5 lines · Julien Grall

Hello,

This small patch series move the detection of running on Xen earlier. This is required in order to support earlyprintk via Xen and selecting the preferred console.

Thanks for doing this, having all of the init done in an initcall (even a relatively early one) has been a niggle I've wanted address for ages, for exactly earlyprintk and preferred console reasons.

I had a very minor comment on #1 but nonetheless both patches:

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Can I keep you ack on the first one with the __read_mostly dropped?

Sure.

BTW, when reposting you might want to CC the arch/arm* maintainers on this intro mail as well as just the second patch.

Ok. I wasn't sure if this patches should go via the Xen tree or ARM one.

That's a question for all relevant maintainers to discuss -- and replies to the 0/N mail is a good place to do that. I suggest you explicitly ask the question in the intro next time around.

Ian.

#17 lore raw
In reply to Julien Grall
Quoted 20 lines · Julien Grall
Quoted 18 lines · Ian Campbell
Quoted 17 lines · Julien Grall

Hi Ian,

Quoted 13 lines · Ian Campbell
Quoted 5 lines · Julien Grall

Hello,

This small patch series move the detection of running on Xen earlier. This is required in order to support earlyprintk via Xen and selecting the preferred console.

Thanks for doing this, having all of the init done in an initcall (even a relatively early one) has been a niggle I've wanted address for ages, for exactly earlyprintk and preferred console reasons.

I had a very minor comment on #1 but nonetheless both patches:

Quoted 8 lines
Quoted 6 lines
Quoted 1 line

Can I keep you ack on the first one with the __read_mostly dropped?

Sure.

BTW, when reposting you might want to CC the arch/arm* maintainers on this intro mail as well as just the second patch.

Ok. I wasn't sure if this patches should go via the Xen tree or ARM one.

That's a question for all relevant maintainers to discuss -- and replies to the 0/N mail is a good place to do that. I suggest you explicitly ask the question in the intro next time around.

Ian.

#18 lore raw
In reply to Ian Campbell
Quoted 18 lines · Ian Campbell
Quoted 17 lines · Julien Grall

Hi Ian,

Quoted 13 lines · Ian Campbell
Quoted 5 lines · Julien Grall

Hello,

This small patch series move the detection of running on Xen earlier. This is required in order to support earlyprintk via Xen and selecting the preferred console.

Thanks for doing this, having all of the init done in an initcall (even a relatively early one) has been a niggle I've wanted address for ages, for exactly earlyprintk and preferred console reasons.

I had a very minor comment on #1 but nonetheless both patches:

Quoted 6 lines
Quoted 1 line

Can I keep you ack on the first one with the __read_mostly dropped?

Sure.

BTW, when reposting you might want to CC the arch/arm* maintainers on this intro mail as well as just the second patch.

Ok. I wasn't sure if this patches should go via the Xen tree or ARM one.

Signature · 1 line
Julien Grall
#19 lore raw
In reply to Julien Grall
Quoted 10 lines · Julien Grall

Hi Ian,

Quoted 7 lines · Ian Campbell
Quoted 5 lines · Julien Grall

Hello,

This small patch series move the detection of running on Xen earlier. This is required in order to support earlyprintk via Xen and selecting the preferred console.

Quoted 8 lines
Quoted 6 lines

Thanks for doing this, having all of the init done in an initcall (even a relatively early one) has been a niggle I've wanted address for ages, for exactly earlyprintk and preferred console reasons.

I had a very minor comment on #1 but nonetheless both patches:

Can I keep you ack on the first one with the __read_mostly dropped?

Sure.

BTW, when reposting you might want to CC the arch/arm* maintainers on this intro mail as well as just the second patch.

Ian.

Acked-by on the v1 series
#20 lore raw
In reply to Julien Grall
Quoted 5 lines · Julien Grall

Hello,

This small patch series move the detection of running on Xen earlier. This is required in order to support earlyprintk via Xen and selecting the preferred console.

Thanks for doing this, having all of the init done in an initcall (even a relatively early one) has been a niggle I've wanted address for ages, for exactly earlyprintk and preferred console reasons.

I had a very minor comment on #1 but nonetheless both patches:

Ian.