0001
0002 #include <linux/thread_info.h>
0003 #include <asm/smp.h>
0004
0005 #include <xen/events.h>
0006
0007 #include "xen-ops.h"
0008 #include "smp.h"
0009
0010
0011 static void __init xen_hvm_smp_prepare_boot_cpu(void)
0012 {
0013 BUG_ON(smp_processor_id() != 0);
0014 native_smp_prepare_boot_cpu();
0015
0016
0017
0018
0019
0020 xen_vcpu_setup(0);
0021
0022
0023
0024
0025
0026 xen_hvm_init_time_ops();
0027
0028
0029
0030
0031
0032
0033
0034 xen_init_spinlocks();
0035 }
0036
0037 static void __init xen_hvm_smp_prepare_cpus(unsigned int max_cpus)
0038 {
0039 int cpu;
0040
0041 native_smp_prepare_cpus(max_cpus);
0042
0043 if (xen_have_vector_callback) {
0044 WARN_ON(xen_smp_intr_init(0));
0045 xen_init_lock_cpu(0);
0046 }
0047
0048 for_each_possible_cpu(cpu) {
0049 if (cpu == 0)
0050 continue;
0051
0052
0053 per_cpu(xen_vcpu_id, cpu) = XEN_VCPU_ID_INVALID;
0054 }
0055 }
0056
0057 #ifdef CONFIG_HOTPLUG_CPU
0058 static void xen_hvm_cpu_die(unsigned int cpu)
0059 {
0060 if (common_cpu_die(cpu) == 0) {
0061 if (xen_have_vector_callback) {
0062 xen_smp_intr_free(cpu);
0063 xen_uninit_lock_cpu(cpu);
0064 xen_teardown_timer(cpu);
0065 }
0066 }
0067 }
0068 #else
0069 static void xen_hvm_cpu_die(unsigned int cpu)
0070 {
0071 BUG();
0072 }
0073 #endif
0074
0075 void __init xen_hvm_smp_init(void)
0076 {
0077 smp_ops.smp_prepare_boot_cpu = xen_hvm_smp_prepare_boot_cpu;
0078 smp_ops.smp_prepare_cpus = xen_hvm_smp_prepare_cpus;
0079 smp_ops.smp_cpus_done = xen_smp_cpus_done;
0080 smp_ops.cpu_die = xen_hvm_cpu_die;
0081
0082 if (!xen_have_vector_callback) {
0083 #ifdef CONFIG_PARAVIRT_SPINLOCKS
0084 nopvspin = true;
0085 #endif
0086 return;
0087 }
0088
0089 smp_ops.smp_send_reschedule = xen_smp_send_reschedule;
0090 smp_ops.send_call_func_ipi = xen_smp_send_call_function_ipi;
0091 smp_ops.send_call_func_single_ipi = xen_smp_send_call_function_single_ipi;
0092 }