Merge tag 'sched-urgent-2020-12-27' of git://git.kernel.org/pub/scm/linux/kernel...
[linux/fpc-iii.git] / arch / x86 / xen / smp_hvm.c
blobf5e7db4f82abb63039ce49271ecbe87f857a1655
1 // SPDX-License-Identifier: GPL-2.0
2 #include <linux/thread_info.h>
3 #include <asm/smp.h>
5 #include <xen/events.h>
7 #include "xen-ops.h"
8 #include "smp.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().
20 xen_vcpu_setup(0);
23 * The alternative logic (which patches the unlock/lock) runs before
24 * the smp bootup up code is activated. Hence we need to set this up
25 * the core kernel is being patched. Otherwise we will have only
26 * modules patched but not core code.
28 xen_init_spinlocks();
31 static void __init xen_hvm_smp_prepare_cpus(unsigned int max_cpus)
33 int cpu;
35 native_smp_prepare_cpus(max_cpus);
36 WARN_ON(xen_smp_intr_init(0));
38 xen_init_lock_cpu(0);
40 for_each_possible_cpu(cpu) {
41 if (cpu == 0)
42 continue;
44 /* Set default vcpu_id to make sure that we don't use cpu-0's */
45 per_cpu(xen_vcpu_id, cpu) = XEN_VCPU_ID_INVALID;
49 #ifdef CONFIG_HOTPLUG_CPU
50 static void xen_hvm_cpu_die(unsigned int cpu)
52 if (common_cpu_die(cpu) == 0) {
53 xen_smp_intr_free(cpu);
54 xen_uninit_lock_cpu(cpu);
55 xen_teardown_timer(cpu);
58 #else
59 static void xen_hvm_cpu_die(unsigned int cpu)
61 BUG();
63 #endif
65 void __init xen_hvm_smp_init(void)
67 if (!xen_have_vector_callback)
68 return;
70 smp_ops.smp_prepare_cpus = xen_hvm_smp_prepare_cpus;
71 smp_ops.smp_send_reschedule = xen_smp_send_reschedule;
72 smp_ops.cpu_die = xen_hvm_cpu_die;
73 smp_ops.send_call_func_ipi = xen_smp_send_call_function_ipi;
74 smp_ops.send_call_func_single_ipi = xen_smp_send_call_function_single_ipi;
75 smp_ops.smp_prepare_boot_cpu = xen_hvm_smp_prepare_boot_cpu;
76 smp_ops.smp_cpus_done = xen_smp_cpus_done;