1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/thread_info.h>
5 #include <xen/events.h>
11 static void __init xen_hvm_smp_prepare_boot_cpu(void)
13 BUG_ON(smp_processor_id() != 0);
14 native_smp_prepare_boot_cpu();
17 * Setup vcpu_info for boot CPU. Secondary CPUs get their vcpu_info
18 * in xen_cpu_up_prepare_hvm().
23 * Called again in case the kernel boots on vcpu >= MAX_VIRT_CPUS.
24 * Refer to comments in xen_hvm_init_time_ops().
26 xen_hvm_init_time_ops();
29 * The alternative logic (which patches the unlock/lock) runs before
30 * the smp bootup up code is activated. Hence we need to set this up
31 * the core kernel is being patched. Otherwise we will have only
32 * modules patched but not core code.
37 static void __init xen_hvm_smp_prepare_cpus(unsigned int max_cpus)
41 native_smp_prepare_cpus(max_cpus);
43 if (xen_have_vector_callback) {
44 WARN_ON(xen_smp_intr_init(0));
48 for_each_possible_cpu(cpu) {
52 /* Set default vcpu_id to make sure that we don't use cpu-0's */
53 per_cpu(xen_vcpu_id, cpu) = XEN_VCPU_ID_INVALID;
57 #ifdef CONFIG_HOTPLUG_CPU
58 static void xen_hvm_cpu_die(unsigned int cpu)
60 if (common_cpu_die(cpu) == 0) {
61 if (xen_have_vector_callback) {
62 xen_smp_intr_free(cpu);
63 xen_uninit_lock_cpu(cpu);
64 xen_teardown_timer(cpu);
69 static void xen_hvm_cpu_die(unsigned int cpu)
75 void __init xen_hvm_smp_init(void)
77 smp_ops.smp_prepare_boot_cpu = xen_hvm_smp_prepare_boot_cpu;
78 smp_ops.smp_prepare_cpus = xen_hvm_smp_prepare_cpus;
79 smp_ops.smp_cpus_done = xen_smp_cpus_done;
80 smp_ops.cpu_die = xen_hvm_cpu_die;
82 if (!xen_have_vector_callback) {
83 #ifdef CONFIG_PARAVIRT_SPINLOCKS
89 smp_ops.smp_send_reschedule = xen_smp_send_reschedule;
90 smp_ops.send_call_func_ipi = xen_smp_send_call_function_ipi;
91 smp_ops.send_call_func_single_ipi = xen_smp_send_call_function_single_ipi;