From 2798ba7d19aed645663398a21ec4006bfdbb1ef3 Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Thu, 25 Apr 2013 13:53:09 +0000 Subject: xen/arm: actually pass a non-NULL percpu pointer to request_percpu_irq Signed-off-by: Stefano Stabellini Reviewed-by: Ian Campbell CC: stable@vger.kernel.org --- arch/arm/xen/enlighten.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/arm') diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 8dc0605a9ce9..99ce18915a89 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -239,7 +239,7 @@ static int __init xen_init_events(void) xen_init_IRQ(); if (request_percpu_irq(xen_events_irq, xen_arm_callback, - "events", xen_vcpu)) { + "events", &xen_vcpu)) { pr_err("Error requesting IRQ %d\n", xen_events_irq); return -EINVAL; } -- cgit v1.2.3 From ea0af61321347d7742714d3ebf30df418e6482e2 Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Thu, 25 Apr 2013 13:53:05 +0000 Subject: xen/arm: implement HYPERVISOR_vcpu_op Signed-off-by: Stefano Stabellini Reviewed-by: Ian Campbell --- arch/arm/include/asm/xen/hypercall.h | 1 + arch/arm/xen/enlighten.c | 1 + arch/arm/xen/hypercall.S | 1 + 3 files changed, 3 insertions(+) (limited to 'arch/arm') diff --git a/arch/arm/include/asm/xen/hypercall.h b/arch/arm/include/asm/xen/hypercall.h index 8a823253d775..799f42ecca63 100644 --- a/arch/arm/include/asm/xen/hypercall.h +++ b/arch/arm/include/asm/xen/hypercall.h @@ -46,6 +46,7 @@ int HYPERVISOR_event_channel_op(int cmd, void *arg); unsigned long HYPERVISOR_hvm_op(int op, void *arg); int HYPERVISOR_memory_op(unsigned int cmd, void *arg); int HYPERVISOR_physdev_op(int cmd, void *arg); +int HYPERVISOR_vcpu_op(int cmd, int vcpuid, void *extra_args); static inline void MULTI_update_va_mapping(struct multicall_entry *mcl, unsigned long va, diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 99ce18915a89..82d5e63cb03b 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -259,4 +259,5 @@ EXPORT_SYMBOL_GPL(HYPERVISOR_sched_op); EXPORT_SYMBOL_GPL(HYPERVISOR_hvm_op); EXPORT_SYMBOL_GPL(HYPERVISOR_memory_op); EXPORT_SYMBOL_GPL(HYPERVISOR_physdev_op); +EXPORT_SYMBOL_GPL(HYPERVISOR_vcpu_op); EXPORT_SYMBOL_GPL(privcmd_call); diff --git a/arch/arm/xen/hypercall.S b/arch/arm/xen/hypercall.S index 71f723984cbd..199cb2da7663 100644 --- a/arch/arm/xen/hypercall.S +++ b/arch/arm/xen/hypercall.S @@ -87,6 +87,7 @@ HYPERCALL2(event_channel_op); HYPERCALL2(hvm_op); HYPERCALL2(memory_op); HYPERCALL2(physdev_op); +HYPERCALL3(vcpu_op); ENTRY(privcmd_call) stmdb sp!, {r4} -- cgit v1.2.3 From 9a9ab3cc00dc0c338e3ab96f75a0e1a3c1aa3c27 Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Thu, 25 Apr 2013 16:17:04 +0000 Subject: xen/arm: SMP support Map vcpu_info using VCPUOP_register_vcpu_info on all the online vcpus, make sure the allocated struct doesn't cross a page boundary. Call enable_percpu_irq on every cpu. Changes in v5: - allocate xen_vcpu_info dynamically, aligning it to the size of the struct; - use VCPUOP_register_vcpu_info on cpu0 too. Changed in v2: - move the percpu variable argument fix to a separate patch; - remove unused variable. Signed-off-by: Stefano Stabellini --- arch/arm/xen/enlighten.c | 48 ++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 6 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 82d5e63cb03b..6c87d116df63 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -32,6 +33,7 @@ struct shared_info xen_dummy_shared_info; struct shared_info *HYPERVISOR_shared_info = (void *)&xen_dummy_shared_info; DEFINE_PER_CPU(struct vcpu_info *, xen_vcpu); +static struct vcpu_info __percpu *xen_vcpu_info; /* These are unused until we support booting "pre-ballooned" */ unsigned long xen_released_pages; @@ -148,6 +150,29 @@ int xen_unmap_domain_mfn_range(struct vm_area_struct *vma, } EXPORT_SYMBOL_GPL(xen_unmap_domain_mfn_range); +static int __init xen_secondary_init(unsigned int cpu) +{ + struct vcpu_register_vcpu_info info; + struct vcpu_info *vcpup; + int err; + + pr_info("Xen: initializing cpu%d\n", cpu); + vcpup = per_cpu_ptr(xen_vcpu_info, cpu); + + info.mfn = __pa(vcpup) >> PAGE_SHIFT; + info.offset = offset_in_page(vcpup); + + err = HYPERVISOR_vcpu_op(VCPUOP_register_vcpu_info, cpu, &info); + if (err) { + pr_debug("register_vcpu_info failed: err=%d\n", err); + } else { + /* This cpu is using the registered vcpu info, even if + later ones fail to. */ + per_cpu(xen_vcpu, cpu) = vcpup; + } + return 0; +} + /* * see Documentation/devicetree/bindings/arm/xen.txt for the * documentation of the Xen Device Tree format. @@ -163,6 +188,7 @@ static int __init xen_guest_init(void) const char *version = NULL; const char *xen_prefix = "xen,xen-"; struct resource res; + int i; node = of_find_compatible_node(NULL, NULL, "xen,xen"); if (!node) { @@ -209,13 +235,18 @@ static int __init xen_guest_init(void) /* xen_vcpu is a pointer to the vcpu_info struct in the shared_info * page, we use it in the event channel upcall and in some pvclock - * related functions. We don't need the vcpu_info placement - * optimizations because we don't use any pv_mmu or pv_irq op on - * HVM. + * related functions. * The shared info contains exactly 1 CPU (the boot CPU). The guest * is required to use VCPUOP_register_vcpu_info to place vcpu info - * for secondary CPUs as they are brought up. */ - per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0]; + * for secondary CPUs as they are brought up. + * For uniformity we use VCPUOP_register_vcpu_info even on cpu0. + */ + xen_vcpu_info = __alloc_percpu(sizeof(struct vcpu_info), + sizeof(struct vcpu_info)); + if (xen_vcpu_info == NULL) + return -ENOMEM; + for_each_online_cpu(i) + xen_secondary_init(i); gnttab_init(); if (!xen_initial_domain()) @@ -231,6 +262,11 @@ static irqreturn_t xen_arm_callback(int irq, void *arg) return IRQ_HANDLED; } +static __init void xen_percpu_enable_events(void *unused) +{ + enable_percpu_irq(xen_events_irq, 0); +} + static int __init xen_init_events(void) { if (!xen_domain() || xen_events_irq < 0) @@ -244,7 +280,7 @@ static int __init xen_init_events(void) return -EINVAL; } - enable_percpu_irq(xen_events_irq, 0); + on_each_cpu(xen_percpu_enable_events, NULL, 0); return 0; } -- cgit v1.2.3 From cc3d7f70c37641ca417f4c02ecaf12cd9772ffa6 Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Tue, 23 Apr 2013 14:51:11 +0000 Subject: xen: move the xenvm machine to mach-virt xenvm is based on mach-vexpress, move it to mach-virt. Changes in v4: - update the dts Makefile too. Signed-off-by: Stefano Stabellini CC: Marc Zyngier CC: will.deacon@arm.com CC: arnd@arndb.de CC: rob.herring@calxeda.com --- arch/arm/boot/dts/Makefile | 4 ++-- arch/arm/mach-vexpress/v2m.c | 1 - arch/arm/mach-virt/virt.c | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'arch/arm') diff --git a/arch/arm/boot/dts/Makefile b/arch/arm/boot/dts/Makefile index 9c6255884cbb..b6289b765ec3 100644 --- a/arch/arm/boot/dts/Makefile +++ b/arch/arm/boot/dts/Makefile @@ -168,8 +168,8 @@ dtb-$(CONFIG_ARCH_TEGRA) += tegra20-harmony.dtb \ dtb-$(CONFIG_ARCH_VEXPRESS) += vexpress-v2p-ca5s.dtb \ vexpress-v2p-ca9.dtb \ vexpress-v2p-ca15-tc1.dtb \ - vexpress-v2p-ca15_a7.dtb \ - xenvm-4.2.dtb + vexpress-v2p-ca15_a7.dtb +dtb-$(CONFIG_ARCH_VIRT) += xenvm-4.2.dtb dtb-$(CONFIG_ARCH_VT8500) += vt8500-bv07.dtb \ wm8505-ref.dtb \ wm8650-mid.dtb \ diff --git a/arch/arm/mach-vexpress/v2m.c b/arch/arm/mach-vexpress/v2m.c index 915683cb67d6..c43ec789661d 100644 --- a/arch/arm/mach-vexpress/v2m.c +++ b/arch/arm/mach-vexpress/v2m.c @@ -469,7 +469,6 @@ static void __init v2m_dt_init(void) static const char * const v2m_dt_match[] __initconst = { "arm,vexpress", - "xen,xenvm", NULL, }; diff --git a/arch/arm/mach-virt/virt.c b/arch/arm/mach-virt/virt.c index 31666f6b4373..528c05eab3a7 100644 --- a/arch/arm/mach-virt/virt.c +++ b/arch/arm/mach-virt/virt.c @@ -40,6 +40,7 @@ static void __init virt_timer_init(void) static const char *virt_dt_match[] = { "linux,dummy-virt", + "xen,xenvm", NULL }; -- cgit v1.2.3 From 17b7ab80e33dab6b05eaa8332ede8c038fb0d9cb Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Wed, 24 Apr 2013 18:47:18 +0000 Subject: xen/arm: XEN selects ARM_PSCI Signed-off-by: Stefano Stabellini --- arch/arm/Kconfig | 1 + 1 file changed, 1 insertion(+) (limited to 'arch/arm') diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 2c3bdce15134..344e299f1257 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -1892,6 +1892,7 @@ config XEN depends on ARM && AEABI && OF depends on CPU_V7 && !CPU_V6 depends on !GENERIC_ATOMIC64 + select ARM_PSCI help Say Y if you want to run Linux in a Virtual Machine on Xen on ARM. -- cgit v1.2.3 From d37a6e1687303ea0fcea89980373e3017b449963 Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Wed, 24 Apr 2013 19:10:51 +0000 Subject: xenvm: add a simple PSCI node and a second cpu Signed-off-by: Stefano Stabellini Acked-by: Marc Zyngier CC: rob.herring@calxeda.com CC: will.deacon@arm.com CC: arnd@arndb.de --- arch/arm/boot/dts/xenvm-4.2.dts | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'arch/arm') diff --git a/arch/arm/boot/dts/xenvm-4.2.dts b/arch/arm/boot/dts/xenvm-4.2.dts index ec3f9528e180..336915151398 100644 --- a/arch/arm/boot/dts/xenvm-4.2.dts +++ b/arch/arm/boot/dts/xenvm-4.2.dts @@ -29,6 +29,19 @@ compatible = "arm,cortex-a15"; reg = <0>; }; + + cpu@1 { + device_type = "cpu"; + compatible = "arm,cortex-a15"; + reg = <1>; + }; + }; + + psci { + compatible = "arm,psci"; + method = "hvc"; + cpu_off = <1>; + cpu_on = <2>; }; memory@80000000 { -- cgit v1.2.3 From 6abb749e83cf100bc4c71537e4c4e97ccdadcafe Mon Sep 17 00:00:00 2001 From: Stefano Stabellini Date: Thu, 25 Apr 2013 10:23:07 +0000 Subject: xen/arm: use sched_op hypercalls for machine reboot and power off Changes in v5: - set pm_power_off and arm_pm_restart from the Xen specific intialization code. Signed-off-by: Stefano Stabellini --- arch/arm/xen/enlighten.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'arch/arm') diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 6c87d116df63..9a0a917cdeb6 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -10,9 +10,12 @@ #include #include #include +#include +#include #include #include #include +#include #include #include #include @@ -173,6 +176,24 @@ static int __init xen_secondary_init(unsigned int cpu) return 0; } +static void xen_restart(char str, const char *cmd) +{ + struct sched_shutdown r = { .reason = SHUTDOWN_reboot }; + int rc; + rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &r); + if (rc) + BUG(); +} + +static void xen_power_off(void) +{ + struct sched_shutdown r = { .reason = SHUTDOWN_poweroff }; + int rc; + rc = HYPERVISOR_sched_op(SCHEDOP_shutdown, &r); + if (rc) + BUG(); +} + /* * see Documentation/devicetree/bindings/arm/xen.txt for the * documentation of the Xen Device Tree format. @@ -252,6 +273,9 @@ static int __init xen_guest_init(void) if (!xen_initial_domain()) xenbus_probe(NULL); + pm_power_off = xen_power_off; + arm_pm_restart = xen_restart; + return 0; } core_initcall(xen_guest_init); -- cgit v1.2.3 From 9bc25a1d5f95f97e9e378620a46e954d3f842641 Mon Sep 17 00:00:00 2001 From: Wei Yongjun Date: Sat, 27 Apr 2013 14:37:31 +0000 Subject: xen/arm: remove duplicated include from enlighten.c Remove duplicated include. Signed-off-by: Wei Yongjun --- arch/arm/xen/enlighten.c | 1 - 1 file changed, 1 deletion(-) (limited to 'arch/arm') diff --git a/arch/arm/xen/enlighten.c b/arch/arm/xen/enlighten.c index 9a0a917cdeb6..d30042e39974 100644 --- a/arch/arm/xen/enlighten.c +++ b/arch/arm/xen/enlighten.c @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include -- cgit v1.2.3