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