blob: 8bed434cd7d799a603a07c8e71ada3181d9d3b4b [file] [log] [blame]
Vitaly Kuznetsova52482d2017-03-14 18:35:45 +01001#include <asm/smp.h>
2
3#include "xen-ops.h"
4#include "smp.h"
5
6
7static void __init xen_hvm_smp_prepare_boot_cpu(void)
8{
9 BUG_ON(smp_processor_id() != 0);
10 native_smp_prepare_boot_cpu();
11
12 /*
13 * Setup vcpu_info for boot CPU.
14 */
15 xen_vcpu_setup(0);
16
17 /*
18 * The alternative logic (which patches the unlock/lock) runs before
19 * the smp bootup up code is activated. Hence we need to set this up
20 * the core kernel is being patched. Otherwise we will have only
21 * modules patched but not core code.
22 */
23 xen_init_spinlocks();
24}
25
26static void __init xen_hvm_smp_prepare_cpus(unsigned int max_cpus)
27{
28 native_smp_prepare_cpus(max_cpus);
29 WARN_ON(xen_smp_intr_init(0));
30
31 xen_init_lock_cpu(0);
32}
33
34#ifdef CONFIG_HOTPLUG_CPU
35static void xen_hvm_cpu_die(unsigned int cpu)
36{
37 if (common_cpu_die(cpu) == 0) {
38 xen_smp_intr_free(cpu);
39 xen_uninit_lock_cpu(cpu);
40 xen_teardown_timer(cpu);
41 }
42}
43#else
44static void xen_hvm_cpu_die(unsigned int cpu)
45{
46 BUG();
47}
48#endif
49
50void __init xen_hvm_smp_init(void)
51{
52 smp_ops.smp_prepare_cpus = xen_hvm_smp_prepare_cpus;
53 smp_ops.smp_send_reschedule = xen_smp_send_reschedule;
54 smp_ops.cpu_die = xen_hvm_cpu_die;
55 smp_ops.send_call_func_ipi = xen_smp_send_call_function_ipi;
56 smp_ops.send_call_func_single_ipi = xen_smp_send_call_function_single_ipi;
57 smp_ops.smp_prepare_boot_cpu = xen_hvm_smp_prepare_boot_cpu;
58}