diff mbox

[1/3] xen/arm: Enable cpu_hotplug.c

Message ID 1444844997-27314-1-git-send-email-stefano.stabellini@eu.citrix.com (mailing list archive)
State New, archived
Headers show

Commit Message

Stefano Stabellini Oct. 14, 2015, 5:49 p.m. UTC
Build cpu_hotplug for ARM and ARM64 guests.

Rename arch_(un)register_cpu to xen_(un)register_cpu and provide an
empty implementation on ARM and ARM64. On x86 just call
arch_(un)register_cpu as we are already doing.

Initialize cpu_hotplug on ARM.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
---
 arch/arm/include/asm/xen/hypervisor.h |    8 ++++++++
 arch/x86/include/asm/xen/hypervisor.h |    5 +++++
 arch/x86/xen/enlighten.c              |   15 +++++++++++++++
 drivers/xen/Makefile                  |    2 --
 drivers/xen/cpu_hotplug.c             |    6 ++++--
 5 files changed, 32 insertions(+), 4 deletions(-)

Comments

Konrad Rzeszutek Wilk Oct. 14, 2015, 6:05 p.m. UTC | #1
On October 14, 2015 1:49:55 PM EDT, Stefano Stabellini <stefano.stabellini@eu.citrix.com> wrote:
>Build cpu_hotplug for ARM and ARM64 guests.
>
>Rename arch_(un)register_cpu to xen_(un)register_cpu and provide an
>empty implementation on ARM and ARM64. On x86 just call
>arch_(un)register_cpu as we are already doing.
>
>Initialize cpu_hotplug on ARM.

Have you tested this on x86? As your changes touch the generic code path.

>
>Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
>---
> arch/arm/include/asm/xen/hypervisor.h |    8 ++++++++
> arch/x86/include/asm/xen/hypervisor.h |    5 +++++
> arch/x86/xen/enlighten.c              |   15 +++++++++++++++
> drivers/xen/Makefile                  |    2 --
> drivers/xen/cpu_hotplug.c             |    6 ++++--
> 5 files changed, 32 insertions(+), 4 deletions(-)
>
>diff --git a/arch/arm/include/asm/xen/hypervisor.h
>b/arch/arm/include/asm/xen/hypervisor.h
>index 04ff8e7..2bc418a 100644
>--- a/arch/arm/include/asm/xen/hypervisor.h
>+++ b/arch/arm/include/asm/xen/hypervisor.h
>@@ -26,4 +26,12 @@ void __init xen_early_init(void);
> static inline void xen_early_init(void) { return; }
> #endif
> 
>+static inline void xen_arch_register_cpu(int num)
>+{
>+}
>+
>+static inline void xen_arch_unregister_cpu(int num)
>+{
>+}
>+
> #endif /* _ASM_ARM_XEN_HYPERVISOR_H */
>diff --git a/arch/x86/include/asm/xen/hypervisor.h
>b/arch/x86/include/asm/xen/hypervisor.h
>index d866959..8b2d4be 100644
>--- a/arch/x86/include/asm/xen/hypervisor.h
>+++ b/arch/x86/include/asm/xen/hypervisor.h
>@@ -57,4 +57,9 @@ static inline bool xen_x2apic_para_available(void)
> }
> #endif
> 
>+#ifdef CONFIG_HOTPLUG_CPU
>+void xen_arch_register_cpu(int num);
>+void xen_arch_unregister_cpu(int num);
>+#endif
>+
> #endif /* _ASM_X86_XEN_HYPERVISOR_H */
>diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
>index 11d6fb4..ba62d8e 100644
>--- a/arch/x86/xen/enlighten.c
>+++ b/arch/x86/xen/enlighten.c
>@@ -71,6 +71,7 @@
> #include <asm/mwait.h>
> #include <asm/pci_x86.h>
> #include <asm/pat.h>
>+#include <asm/cpu.h>
> 
> #ifdef CONFIG_ACPI
> #include <linux/acpi.h>
>@@ -1868,3 +1869,17 @@ const struct hypervisor_x86 x86_hyper_xen = {
> 	.set_cpu_features       = xen_set_cpu_features,
> };
> EXPORT_SYMBOL(x86_hyper_xen);
>+
>+#ifdef CONFIG_HOTPLUG_CPU
>+void xen_arch_register_cpu(int num)
>+{
>+	arch_register_cpu(num);
>+}
>+EXPORT_SYMBOL(xen_arch_register_cpu);
>+
>+void xen_arch_unregister_cpu(int num)
>+{
>+	arch_unregister_cpu(num);
>+}
>+EXPORT_SYMBOL(xen_arch_unregister_cpu);
>+#endif
>diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
>index e293bc5..aa8a7f7 100644
>--- a/drivers/xen/Makefile
>+++ b/drivers/xen/Makefile
>@@ -1,6 +1,4 @@
>-ifeq ($(filter y, $(CONFIG_ARM) $(CONFIG_ARM64)),)
> obj-$(CONFIG_HOTPLUG_CPU)		+= cpu_hotplug.o
>-endif
> obj-$(CONFIG_X86)			+= fallback.o
> obj-y	+= grant-table.o features.o balloon.o manage.o preempt.o
> obj-y	+= events/
>diff --git a/drivers/xen/cpu_hotplug.c b/drivers/xen/cpu_hotplug.c
>index cc6513a..122b351 100644
>--- a/drivers/xen/cpu_hotplug.c
>+++ b/drivers/xen/cpu_hotplug.c
>@@ -11,7 +11,7 @@
> static void enable_hotplug_cpu(int cpu)
> {
> 	if (!cpu_present(cpu))
>-		arch_register_cpu(cpu);
>+		xen_arch_register_cpu(cpu);
> 
> 	set_cpu_present(cpu, true);
> }
>@@ -19,7 +19,7 @@ static void enable_hotplug_cpu(int cpu)
> static void disable_hotplug_cpu(int cpu)
> {
> 	if (cpu_present(cpu))
>-		arch_unregister_cpu(cpu);
>+		xen_arch_unregister_cpu(cpu);
> 
> 	set_cpu_present(cpu, false);
> }
>@@ -102,8 +102,10 @@ static int __init setup_vcpu_hotplug_event(void)
> 	static struct notifier_block xsn_cpu = {
> 		.notifier_call = setup_cpu_watcher };
> 
>+#ifdef CONFIG_X86
> 	if (!xen_pv_domain())
> 		return -ENODEV;
>+#endif
> 
> 	register_xenstore_notifier(&xsn_cpu);
>
Stefano Stabellini Oct. 14, 2015, 6:17 p.m. UTC | #2
On Wed, 14 Oct 2015, Konrad Rzeszutek Wilk wrote:
> On October 14, 2015 1:49:55 PM EDT, Stefano Stabellini <stefano.stabellini@eu.citrix.com> wrote:
> >Build cpu_hotplug for ARM and ARM64 guests.
> >
> >Rename arch_(un)register_cpu to xen_(un)register_cpu and provide an
> >empty implementation on ARM and ARM64. On x86 just call
> >arch_(un)register_cpu as we are already doing.
> >
> >Initialize cpu_hotplug on ARM.
> 
> Have you tested this on x86? As your changes touch the generic code path.

Only build-tested at this stage, because all my x86 test boxes are
unavailable at the moment (they are being relocated). As soon as they
come back online I will test.


> >Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> >---
> > arch/arm/include/asm/xen/hypervisor.h |    8 ++++++++
> > arch/x86/include/asm/xen/hypervisor.h |    5 +++++
> > arch/x86/xen/enlighten.c              |   15 +++++++++++++++
> > drivers/xen/Makefile                  |    2 --
> > drivers/xen/cpu_hotplug.c             |    6 ++++--
> > 5 files changed, 32 insertions(+), 4 deletions(-)
> >
> >diff --git a/arch/arm/include/asm/xen/hypervisor.h
> >b/arch/arm/include/asm/xen/hypervisor.h
> >index 04ff8e7..2bc418a 100644
> >--- a/arch/arm/include/asm/xen/hypervisor.h
> >+++ b/arch/arm/include/asm/xen/hypervisor.h
> >@@ -26,4 +26,12 @@ void __init xen_early_init(void);
> > static inline void xen_early_init(void) { return; }
> > #endif
> > 
> >+static inline void xen_arch_register_cpu(int num)
> >+{
> >+}
> >+
> >+static inline void xen_arch_unregister_cpu(int num)
> >+{
> >+}
> >+
> > #endif /* _ASM_ARM_XEN_HYPERVISOR_H */
> >diff --git a/arch/x86/include/asm/xen/hypervisor.h
> >b/arch/x86/include/asm/xen/hypervisor.h
> >index d866959..8b2d4be 100644
> >--- a/arch/x86/include/asm/xen/hypervisor.h
> >+++ b/arch/x86/include/asm/xen/hypervisor.h
> >@@ -57,4 +57,9 @@ static inline bool xen_x2apic_para_available(void)
> > }
> > #endif
> > 
> >+#ifdef CONFIG_HOTPLUG_CPU
> >+void xen_arch_register_cpu(int num);
> >+void xen_arch_unregister_cpu(int num);
> >+#endif
> >+
> > #endif /* _ASM_X86_XEN_HYPERVISOR_H */
> >diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
> >index 11d6fb4..ba62d8e 100644
> >--- a/arch/x86/xen/enlighten.c
> >+++ b/arch/x86/xen/enlighten.c
> >@@ -71,6 +71,7 @@
> > #include <asm/mwait.h>
> > #include <asm/pci_x86.h>
> > #include <asm/pat.h>
> >+#include <asm/cpu.h>
> > 
> > #ifdef CONFIG_ACPI
> > #include <linux/acpi.h>
> >@@ -1868,3 +1869,17 @@ const struct hypervisor_x86 x86_hyper_xen = {
> > 	.set_cpu_features       = xen_set_cpu_features,
> > };
> > EXPORT_SYMBOL(x86_hyper_xen);
> >+
> >+#ifdef CONFIG_HOTPLUG_CPU
> >+void xen_arch_register_cpu(int num)
> >+{
> >+	arch_register_cpu(num);
> >+}
> >+EXPORT_SYMBOL(xen_arch_register_cpu);
> >+
> >+void xen_arch_unregister_cpu(int num)
> >+{
> >+	arch_unregister_cpu(num);
> >+}
> >+EXPORT_SYMBOL(xen_arch_unregister_cpu);
> >+#endif
> >diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
> >index e293bc5..aa8a7f7 100644
> >--- a/drivers/xen/Makefile
> >+++ b/drivers/xen/Makefile
> >@@ -1,6 +1,4 @@
> >-ifeq ($(filter y, $(CONFIG_ARM) $(CONFIG_ARM64)),)
> > obj-$(CONFIG_HOTPLUG_CPU)		+= cpu_hotplug.o
> >-endif
> > obj-$(CONFIG_X86)			+= fallback.o
> > obj-y	+= grant-table.o features.o balloon.o manage.o preempt.o
> > obj-y	+= events/
> >diff --git a/drivers/xen/cpu_hotplug.c b/drivers/xen/cpu_hotplug.c
> >index cc6513a..122b351 100644
> >--- a/drivers/xen/cpu_hotplug.c
> >+++ b/drivers/xen/cpu_hotplug.c
> >@@ -11,7 +11,7 @@
> > static void enable_hotplug_cpu(int cpu)
> > {
> > 	if (!cpu_present(cpu))
> >-		arch_register_cpu(cpu);
> >+		xen_arch_register_cpu(cpu);
> > 
> > 	set_cpu_present(cpu, true);
> > }
> >@@ -19,7 +19,7 @@ static void enable_hotplug_cpu(int cpu)
> > static void disable_hotplug_cpu(int cpu)
> > {
> > 	if (cpu_present(cpu))
> >-		arch_unregister_cpu(cpu);
> >+		xen_arch_unregister_cpu(cpu);
> > 
> > 	set_cpu_present(cpu, false);
> > }
> >@@ -102,8 +102,10 @@ static int __init setup_vcpu_hotplug_event(void)
> > 	static struct notifier_block xsn_cpu = {
> > 		.notifier_call = setup_cpu_watcher };
> > 
> >+#ifdef CONFIG_X86
> > 	if (!xen_pv_domain())
> > 		return -ENODEV;
> >+#endif
> > 
> > 	register_xenstore_notifier(&xsn_cpu);
> > 
> 
>
Julien Grall Oct. 14, 2015, 10:51 p.m. UTC | #3
Hi Stefano,

On 14/10/2015 18:49, Stefano Stabellini wrote:
> Build cpu_hotplug for ARM and ARM64 guests.
>
> Rename arch_(un)register_cpu to xen_(un)register_cpu and provide an
> empty implementation on ARM and ARM64. On x86 just call
> arch_(un)register_cpu as we are already doing.
>
> Initialize cpu_hotplug on ARM.
>
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> ---
>   arch/arm/include/asm/xen/hypervisor.h |    8 ++++++++
>   arch/x86/include/asm/xen/hypervisor.h |    5 +++++
>   arch/x86/xen/enlighten.c              |   15 +++++++++++++++
>   drivers/xen/Makefile                  |    2 --
>   drivers/xen/cpu_hotplug.c             |    6 ++++--
>   5 files changed, 32 insertions(+), 4 deletions(-)
>
> diff --git a/arch/arm/include/asm/xen/hypervisor.h b/arch/arm/include/asm/xen/hypervisor.h
> index 04ff8e7..2bc418a 100644
> --- a/arch/arm/include/asm/xen/hypervisor.h
> +++ b/arch/arm/include/asm/xen/hypervisor.h
> @@ -26,4 +26,12 @@ void __init xen_early_init(void);
>   static inline void xen_early_init(void) { return; }
>   #endif
>

I know that those helpers are empty for now. But I would prefer to see 
them protected by (FWIW, it's what you did for x86).

#ifdef CONFIG_CPU_HOTPLUG

> +static inline void xen_arch_register_cpu(int num)
> +{
> +}
> +
> +static inline void xen_arch_unregister_cpu(int num)
> +{
> +}
> +

#endif

>   #endif /* _ASM_ARM_XEN_HYPERVISOR_H */

[...]

> diff --git a/drivers/xen/cpu_hotplug.c b/drivers/xen/cpu_hotplug.c
> index cc6513a..122b351 100644
> --- a/drivers/xen/cpu_hotplug.c
> +++ b/drivers/xen/cpu_hotplug.c
> @@ -11,7 +11,7 @@
>   static void enable_hotplug_cpu(int cpu)
>   {
>   	if (!cpu_present(cpu))
> -		arch_register_cpu(cpu);
> +		xen_arch_register_cpu(cpu);
>
>   	set_cpu_present(cpu, true);
>   }
> @@ -19,7 +19,7 @@ static void enable_hotplug_cpu(int cpu)
>   static void disable_hotplug_cpu(int cpu)
>   {
>   	if (cpu_present(cpu))
> -		arch_unregister_cpu(cpu);
> +		xen_arch_unregister_cpu(cpu);
>
>   	set_cpu_present(cpu, false);
>   }
> @@ -102,8 +102,10 @@ static int __init setup_vcpu_hotplug_event(void)
>   	static struct notifier_block xsn_cpu = {
>   		.notifier_call = setup_cpu_watcher };
>
> +#ifdef CONFIG_X86
>   	if (!xen_pv_domain())
>   		return -ENODEV;
> +#endif

For ARM, you need to check if it's a Xen domain. Otherwise a kernel 
aware of Xen won't boot on baremetal.

>
>   	register_xenstore_notifier(&xsn_cpu);
>
>

Regards,
Stefano Stabellini Oct. 16, 2015, 3:21 p.m. UTC | #4
On Wed, 14 Oct 2015, Stefano Stabellini wrote:
> On Wed, 14 Oct 2015, Konrad Rzeszutek Wilk wrote:
> > On October 14, 2015 1:49:55 PM EDT, Stefano Stabellini <stefano.stabellini@eu.citrix.com> wrote:
> > >Build cpu_hotplug for ARM and ARM64 guests.
> > >
> > >Rename arch_(un)register_cpu to xen_(un)register_cpu and provide an
> > >empty implementation on ARM and ARM64. On x86 just call
> > >arch_(un)register_cpu as we are already doing.
> > >
> > >Initialize cpu_hotplug on ARM.
> > 
> > Have you tested this on x86? As your changes touch the generic code path.
> 
> Only build-tested at this stage, because all my x86 test boxes are
> unavailable at the moment (they are being relocated). As soon as they
> come back online I will test.

Tested with a PV guest on x86 and it's fine.


> 
> > >Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> > >---
> > > arch/arm/include/asm/xen/hypervisor.h |    8 ++++++++
> > > arch/x86/include/asm/xen/hypervisor.h |    5 +++++
> > > arch/x86/xen/enlighten.c              |   15 +++++++++++++++
> > > drivers/xen/Makefile                  |    2 --
> > > drivers/xen/cpu_hotplug.c             |    6 ++++--
> > > 5 files changed, 32 insertions(+), 4 deletions(-)
> > >
> > >diff --git a/arch/arm/include/asm/xen/hypervisor.h
> > >b/arch/arm/include/asm/xen/hypervisor.h
> > >index 04ff8e7..2bc418a 100644
> > >--- a/arch/arm/include/asm/xen/hypervisor.h
> > >+++ b/arch/arm/include/asm/xen/hypervisor.h
> > >@@ -26,4 +26,12 @@ void __init xen_early_init(void);
> > > static inline void xen_early_init(void) { return; }
> > > #endif
> > > 
> > >+static inline void xen_arch_register_cpu(int num)
> > >+{
> > >+}
> > >+
> > >+static inline void xen_arch_unregister_cpu(int num)
> > >+{
> > >+}
> > >+
> > > #endif /* _ASM_ARM_XEN_HYPERVISOR_H */
> > >diff --git a/arch/x86/include/asm/xen/hypervisor.h
> > >b/arch/x86/include/asm/xen/hypervisor.h
> > >index d866959..8b2d4be 100644
> > >--- a/arch/x86/include/asm/xen/hypervisor.h
> > >+++ b/arch/x86/include/asm/xen/hypervisor.h
> > >@@ -57,4 +57,9 @@ static inline bool xen_x2apic_para_available(void)
> > > }
> > > #endif
> > > 
> > >+#ifdef CONFIG_HOTPLUG_CPU
> > >+void xen_arch_register_cpu(int num);
> > >+void xen_arch_unregister_cpu(int num);
> > >+#endif
> > >+
> > > #endif /* _ASM_X86_XEN_HYPERVISOR_H */
> > >diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
> > >index 11d6fb4..ba62d8e 100644
> > >--- a/arch/x86/xen/enlighten.c
> > >+++ b/arch/x86/xen/enlighten.c
> > >@@ -71,6 +71,7 @@
> > > #include <asm/mwait.h>
> > > #include <asm/pci_x86.h>
> > > #include <asm/pat.h>
> > >+#include <asm/cpu.h>
> > > 
> > > #ifdef CONFIG_ACPI
> > > #include <linux/acpi.h>
> > >@@ -1868,3 +1869,17 @@ const struct hypervisor_x86 x86_hyper_xen = {
> > > 	.set_cpu_features       = xen_set_cpu_features,
> > > };
> > > EXPORT_SYMBOL(x86_hyper_xen);
> > >+
> > >+#ifdef CONFIG_HOTPLUG_CPU
> > >+void xen_arch_register_cpu(int num)
> > >+{
> > >+	arch_register_cpu(num);
> > >+}
> > >+EXPORT_SYMBOL(xen_arch_register_cpu);
> > >+
> > >+void xen_arch_unregister_cpu(int num)
> > >+{
> > >+	arch_unregister_cpu(num);
> > >+}
> > >+EXPORT_SYMBOL(xen_arch_unregister_cpu);
> > >+#endif
> > >diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
> > >index e293bc5..aa8a7f7 100644
> > >--- a/drivers/xen/Makefile
> > >+++ b/drivers/xen/Makefile
> > >@@ -1,6 +1,4 @@
> > >-ifeq ($(filter y, $(CONFIG_ARM) $(CONFIG_ARM64)),)
> > > obj-$(CONFIG_HOTPLUG_CPU)		+= cpu_hotplug.o
> > >-endif
> > > obj-$(CONFIG_X86)			+= fallback.o
> > > obj-y	+= grant-table.o features.o balloon.o manage.o preempt.o
> > > obj-y	+= events/
> > >diff --git a/drivers/xen/cpu_hotplug.c b/drivers/xen/cpu_hotplug.c
> > >index cc6513a..122b351 100644
> > >--- a/drivers/xen/cpu_hotplug.c
> > >+++ b/drivers/xen/cpu_hotplug.c
> > >@@ -11,7 +11,7 @@
> > > static void enable_hotplug_cpu(int cpu)
> > > {
> > > 	if (!cpu_present(cpu))
> > >-		arch_register_cpu(cpu);
> > >+		xen_arch_register_cpu(cpu);
> > > 
> > > 	set_cpu_present(cpu, true);
> > > }
> > >@@ -19,7 +19,7 @@ static void enable_hotplug_cpu(int cpu)
> > > static void disable_hotplug_cpu(int cpu)
> > > {
> > > 	if (cpu_present(cpu))
> > >-		arch_unregister_cpu(cpu);
> > >+		xen_arch_unregister_cpu(cpu);
> > > 
> > > 	set_cpu_present(cpu, false);
> > > }
> > >@@ -102,8 +102,10 @@ static int __init setup_vcpu_hotplug_event(void)
> > > 	static struct notifier_block xsn_cpu = {
> > > 		.notifier_call = setup_cpu_watcher };
> > > 
> > >+#ifdef CONFIG_X86
> > > 	if (!xen_pv_domain())
> > > 		return -ENODEV;
> > >+#endif
> > > 
> > > 	register_xenstore_notifier(&xsn_cpu);
> > > 
> > 
> > 
>
Stefano Stabellini Oct. 16, 2015, 3:23 p.m. UTC | #5
On Wed, 14 Oct 2015, Julien Grall wrote:
> Hi Stefano,
> 
> On 14/10/2015 18:49, Stefano Stabellini wrote:
> > Build cpu_hotplug for ARM and ARM64 guests.
> > 
> > Rename arch_(un)register_cpu to xen_(un)register_cpu and provide an
> > empty implementation on ARM and ARM64. On x86 just call
> > arch_(un)register_cpu as we are already doing.
> > 
> > Initialize cpu_hotplug on ARM.
> > 
> > Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> > ---
> >   arch/arm/include/asm/xen/hypervisor.h |    8 ++++++++
> >   arch/x86/include/asm/xen/hypervisor.h |    5 +++++
> >   arch/x86/xen/enlighten.c              |   15 +++++++++++++++
> >   drivers/xen/Makefile                  |    2 --
> >   drivers/xen/cpu_hotplug.c             |    6 ++++--
> >   5 files changed, 32 insertions(+), 4 deletions(-)
> > 
> > diff --git a/arch/arm/include/asm/xen/hypervisor.h
> > b/arch/arm/include/asm/xen/hypervisor.h
> > index 04ff8e7..2bc418a 100644
> > --- a/arch/arm/include/asm/xen/hypervisor.h
> > +++ b/arch/arm/include/asm/xen/hypervisor.h
> > @@ -26,4 +26,12 @@ void __init xen_early_init(void);
> >   static inline void xen_early_init(void) { return; }
> >   #endif
> > 
> 
> I know that those helpers are empty for now. But I would prefer to see them
> protected by (FWIW, it's what you did for x86).
> 
> #ifdef CONFIG_CPU_HOTPLUG

Fair enough.


> > +static inline void xen_arch_register_cpu(int num)
> > +{
> > +}
> > +
> > +static inline void xen_arch_unregister_cpu(int num)
> > +{
> > +}
> > +
> 
> #endif
> 
> >   #endif /* _ASM_ARM_XEN_HYPERVISOR_H */
> 
> [...]
> 
> > diff --git a/drivers/xen/cpu_hotplug.c b/drivers/xen/cpu_hotplug.c
> > index cc6513a..122b351 100644
> > --- a/drivers/xen/cpu_hotplug.c
> > +++ b/drivers/xen/cpu_hotplug.c
> > @@ -11,7 +11,7 @@
> >   static void enable_hotplug_cpu(int cpu)
> >   {
> >   	if (!cpu_present(cpu))
> > -		arch_register_cpu(cpu);
> > +		xen_arch_register_cpu(cpu);
> > 
> >   	set_cpu_present(cpu, true);
> >   }
> > @@ -19,7 +19,7 @@ static void enable_hotplug_cpu(int cpu)
> >   static void disable_hotplug_cpu(int cpu)
> >   {
> >   	if (cpu_present(cpu))
> > -		arch_unregister_cpu(cpu);
> > +		xen_arch_unregister_cpu(cpu);
> > 
> >   	set_cpu_present(cpu, false);
> >   }
> > @@ -102,8 +102,10 @@ static int __init setup_vcpu_hotplug_event(void)
> >   	static struct notifier_block xsn_cpu = {
> >   		.notifier_call = setup_cpu_watcher };
> > 
> > +#ifdef CONFIG_X86
> >   	if (!xen_pv_domain())
> >   		return -ENODEV;
> > +#endif
> 
> For ARM, you need to check if it's a Xen domain. Otherwise a kernel aware of
> Xen won't boot on baremetal.

That's a good point!


> > 
> >   	register_xenstore_notifier(&xsn_cpu);
> > 
> > 
> 
> Regards,
> 
> -- 
> Julien Grall
>
diff mbox

Patch

diff --git a/arch/arm/include/asm/xen/hypervisor.h b/arch/arm/include/asm/xen/hypervisor.h
index 04ff8e7..2bc418a 100644
--- a/arch/arm/include/asm/xen/hypervisor.h
+++ b/arch/arm/include/asm/xen/hypervisor.h
@@ -26,4 +26,12 @@  void __init xen_early_init(void);
 static inline void xen_early_init(void) { return; }
 #endif
 
+static inline void xen_arch_register_cpu(int num)
+{
+}
+
+static inline void xen_arch_unregister_cpu(int num)
+{
+}
+
 #endif /* _ASM_ARM_XEN_HYPERVISOR_H */
diff --git a/arch/x86/include/asm/xen/hypervisor.h b/arch/x86/include/asm/xen/hypervisor.h
index d866959..8b2d4be 100644
--- a/arch/x86/include/asm/xen/hypervisor.h
+++ b/arch/x86/include/asm/xen/hypervisor.h
@@ -57,4 +57,9 @@  static inline bool xen_x2apic_para_available(void)
 }
 #endif
 
+#ifdef CONFIG_HOTPLUG_CPU
+void xen_arch_register_cpu(int num);
+void xen_arch_unregister_cpu(int num);
+#endif
+
 #endif /* _ASM_X86_XEN_HYPERVISOR_H */
diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
index 11d6fb4..ba62d8e 100644
--- a/arch/x86/xen/enlighten.c
+++ b/arch/x86/xen/enlighten.c
@@ -71,6 +71,7 @@ 
 #include <asm/mwait.h>
 #include <asm/pci_x86.h>
 #include <asm/pat.h>
+#include <asm/cpu.h>
 
 #ifdef CONFIG_ACPI
 #include <linux/acpi.h>
@@ -1868,3 +1869,17 @@  const struct hypervisor_x86 x86_hyper_xen = {
 	.set_cpu_features       = xen_set_cpu_features,
 };
 EXPORT_SYMBOL(x86_hyper_xen);
+
+#ifdef CONFIG_HOTPLUG_CPU
+void xen_arch_register_cpu(int num)
+{
+	arch_register_cpu(num);
+}
+EXPORT_SYMBOL(xen_arch_register_cpu);
+
+void xen_arch_unregister_cpu(int num)
+{
+	arch_unregister_cpu(num);
+}
+EXPORT_SYMBOL(xen_arch_unregister_cpu);
+#endif
diff --git a/drivers/xen/Makefile b/drivers/xen/Makefile
index e293bc5..aa8a7f7 100644
--- a/drivers/xen/Makefile
+++ b/drivers/xen/Makefile
@@ -1,6 +1,4 @@ 
-ifeq ($(filter y, $(CONFIG_ARM) $(CONFIG_ARM64)),)
 obj-$(CONFIG_HOTPLUG_CPU)		+= cpu_hotplug.o
-endif
 obj-$(CONFIG_X86)			+= fallback.o
 obj-y	+= grant-table.o features.o balloon.o manage.o preempt.o
 obj-y	+= events/
diff --git a/drivers/xen/cpu_hotplug.c b/drivers/xen/cpu_hotplug.c
index cc6513a..122b351 100644
--- a/drivers/xen/cpu_hotplug.c
+++ b/drivers/xen/cpu_hotplug.c
@@ -11,7 +11,7 @@ 
 static void enable_hotplug_cpu(int cpu)
 {
 	if (!cpu_present(cpu))
-		arch_register_cpu(cpu);
+		xen_arch_register_cpu(cpu);
 
 	set_cpu_present(cpu, true);
 }
@@ -19,7 +19,7 @@  static void enable_hotplug_cpu(int cpu)
 static void disable_hotplug_cpu(int cpu)
 {
 	if (cpu_present(cpu))
-		arch_unregister_cpu(cpu);
+		xen_arch_unregister_cpu(cpu);
 
 	set_cpu_present(cpu, false);
 }
@@ -102,8 +102,10 @@  static int __init setup_vcpu_hotplug_event(void)
 	static struct notifier_block xsn_cpu = {
 		.notifier_call = setup_cpu_watcher };
 
+#ifdef CONFIG_X86
 	if (!xen_pv_domain())
 		return -ENODEV;
+#endif
 
 	register_xenstore_notifier(&xsn_cpu);