smp.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. /*
  2. * Xen SMP support
  3. *
  4. * This file implements the Xen versions of smp_ops. SMP under Xen is
  5. * very straightforward. Bringing a CPU up is simply a matter of
  6. * loading its initial context and setting it running.
  7. *
  8. * IPIs are handled through the Xen event mechanism.
  9. *
  10. * Because virtual CPUs can be scheduled onto any real CPU, there's no
  11. * useful topology information for the kernel to make use of. As a
  12. * result, all CPUs are treated as if they're single-core and
  13. * single-threaded.
  14. */
  15. #include <linux/sched.h>
  16. #include <linux/err.h>
  17. #include <linux/slab.h>
  18. #include <linux/smp.h>
  19. #include <linux/irq_work.h>
  20. #include <asm/paravirt.h>
  21. #include <asm/desc.h>
  22. #include <asm/pgtable.h>
  23. #include <asm/cpu.h>
  24. #include <xen/interface/xen.h>
  25. #include <xen/interface/vcpu.h>
  26. #include <asm/xen/interface.h>
  27. #include <asm/xen/hypercall.h>
  28. #include <xen/xen.h>
  29. #include <xen/page.h>
  30. #include <xen/events.h>
  31. #include <xen/hvc-console.h>
  32. #include "xen-ops.h"
  33. #include "mmu.h"
  34. cpumask_var_t xen_cpu_initialized_map;
  35. static DEFINE_PER_CPU(int, xen_resched_irq);
  36. static DEFINE_PER_CPU(int, xen_callfunc_irq);
  37. static DEFINE_PER_CPU(int, xen_callfuncsingle_irq);
  38. static DEFINE_PER_CPU(int, xen_irq_work);
  39. static DEFINE_PER_CPU(int, xen_debug_irq) = -1;
  40. static irqreturn_t xen_call_function_interrupt(int irq, void *dev_id);
  41. static irqreturn_t xen_call_function_single_interrupt(int irq, void *dev_id);
  42. static irqreturn_t xen_irq_work_interrupt(int irq, void *dev_id);
  43. /*
  44. * Reschedule call back.
  45. */
  46. static irqreturn_t xen_reschedule_interrupt(int irq, void *dev_id)
  47. {
  48. inc_irq_stat(irq_resched_count);
  49. scheduler_ipi();
  50. return IRQ_HANDLED;
  51. }
  52. static void __cpuinit cpu_bringup(void)
  53. {
  54. int cpu;
  55. cpu_init();
  56. touch_softlockup_watchdog();
  57. preempt_disable();
  58. xen_enable_sysenter();
  59. xen_enable_syscall();
  60. cpu = smp_processor_id();
  61. smp_store_cpu_info(cpu);
  62. cpu_data(cpu).x86_max_cores = 1;
  63. set_cpu_sibling_map(cpu);
  64. xen_setup_cpu_clockevents();
  65. notify_cpu_starting(cpu);
  66. set_cpu_online(cpu, true);
  67. this_cpu_write(cpu_state, CPU_ONLINE);
  68. wmb();
  69. /* We can take interrupts now: we're officially "up". */
  70. local_irq_enable();
  71. wmb(); /* make sure everything is out */
  72. }
  73. static void __cpuinit cpu_bringup_and_idle(void)
  74. {
  75. cpu_bringup();
  76. cpu_startup_entry(CPUHP_ONLINE);
  77. }
  78. static int xen_smp_intr_init(unsigned int cpu)
  79. {
  80. int rc;
  81. const char *resched_name, *callfunc_name, *debug_name;
  82. resched_name = kasprintf(GFP_KERNEL, "resched%d", cpu);
  83. rc = bind_ipi_to_irqhandler(XEN_RESCHEDULE_VECTOR,
  84. cpu,
  85. xen_reschedule_interrupt,
  86. IRQF_DISABLED|IRQF_PERCPU|IRQF_NOBALANCING,
  87. resched_name,
  88. NULL);
  89. if (rc < 0)
  90. goto fail;
  91. per_cpu(xen_resched_irq, cpu) = rc;
  92. callfunc_name = kasprintf(GFP_KERNEL, "callfunc%d", cpu);
  93. rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_VECTOR,
  94. cpu,
  95. xen_call_function_interrupt,
  96. IRQF_DISABLED|IRQF_PERCPU|IRQF_NOBALANCING,
  97. callfunc_name,
  98. NULL);
  99. if (rc < 0)
  100. goto fail;
  101. per_cpu(xen_callfunc_irq, cpu) = rc;
  102. debug_name = kasprintf(GFP_KERNEL, "debug%d", cpu);
  103. rc = bind_virq_to_irqhandler(VIRQ_DEBUG, cpu, xen_debug_interrupt,
  104. IRQF_DISABLED | IRQF_PERCPU | IRQF_NOBALANCING,
  105. debug_name, NULL);
  106. if (rc < 0)
  107. goto fail;
  108. per_cpu(xen_debug_irq, cpu) = rc;
  109. callfunc_name = kasprintf(GFP_KERNEL, "callfuncsingle%d", cpu);
  110. rc = bind_ipi_to_irqhandler(XEN_CALL_FUNCTION_SINGLE_VECTOR,
  111. cpu,
  112. xen_call_function_single_interrupt,
  113. IRQF_DISABLED|IRQF_PERCPU|IRQF_NOBALANCING,
  114. callfunc_name,
  115. NULL);
  116. if (rc < 0)
  117. goto fail;
  118. per_cpu(xen_callfuncsingle_irq, cpu) = rc;
  119. /*
  120. * The IRQ worker on PVHVM goes through the native path and uses the
  121. * IPI mechanism.
  122. */
  123. if (xen_hvm_domain())
  124. return 0;
  125. callfunc_name = kasprintf(GFP_KERNEL, "irqwork%d", cpu);
  126. rc = bind_ipi_to_irqhandler(XEN_IRQ_WORK_VECTOR,
  127. cpu,
  128. xen_irq_work_interrupt,
  129. IRQF_DISABLED|IRQF_PERCPU|IRQF_NOBALANCING,
  130. callfunc_name,
  131. NULL);
  132. if (rc < 0)
  133. goto fail;
  134. per_cpu(xen_irq_work, cpu) = rc;
  135. return 0;
  136. fail:
  137. if (per_cpu(xen_resched_irq, cpu) >= 0)
  138. unbind_from_irqhandler(per_cpu(xen_resched_irq, cpu), NULL);
  139. if (per_cpu(xen_callfunc_irq, cpu) >= 0)
  140. unbind_from_irqhandler(per_cpu(xen_callfunc_irq, cpu), NULL);
  141. if (per_cpu(xen_debug_irq, cpu) >= 0)
  142. unbind_from_irqhandler(per_cpu(xen_debug_irq, cpu), NULL);
  143. if (per_cpu(xen_callfuncsingle_irq, cpu) >= 0)
  144. unbind_from_irqhandler(per_cpu(xen_callfuncsingle_irq, cpu),
  145. NULL);
  146. if (xen_hvm_domain())
  147. return rc;
  148. if (per_cpu(xen_irq_work, cpu) >= 0)
  149. unbind_from_irqhandler(per_cpu(xen_irq_work, cpu), NULL);
  150. return rc;
  151. }
  152. static void __init xen_fill_possible_map(void)
  153. {
  154. int i, rc;
  155. if (xen_initial_domain())
  156. return;
  157. for (i = 0; i < nr_cpu_ids; i++) {
  158. rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL);
  159. if (rc >= 0) {
  160. num_processors++;
  161. set_cpu_possible(i, true);
  162. }
  163. }
  164. }
  165. static void __init xen_filter_cpu_maps(void)
  166. {
  167. int i, rc;
  168. unsigned int subtract = 0;
  169. if (!xen_initial_domain())
  170. return;
  171. num_processors = 0;
  172. disabled_cpus = 0;
  173. for (i = 0; i < nr_cpu_ids; i++) {
  174. rc = HYPERVISOR_vcpu_op(VCPUOP_is_up, i, NULL);
  175. if (rc >= 0) {
  176. num_processors++;
  177. set_cpu_possible(i, true);
  178. } else {
  179. set_cpu_possible(i, false);
  180. set_cpu_present(i, false);
  181. subtract++;
  182. }
  183. }
  184. #ifdef CONFIG_HOTPLUG_CPU
  185. /* This is akin to using 'nr_cpus' on the Linux command line.
  186. * Which is OK as when we use 'dom0_max_vcpus=X' we can only
  187. * have up to X, while nr_cpu_ids is greater than X. This
  188. * normally is not a problem, except when CPU hotplugging
  189. * is involved and then there might be more than X CPUs
  190. * in the guest - which will not work as there is no
  191. * hypercall to expand the max number of VCPUs an already
  192. * running guest has. So cap it up to X. */
  193. if (subtract)
  194. nr_cpu_ids = nr_cpu_ids - subtract;
  195. #endif
  196. }
  197. static void __init xen_smp_prepare_boot_cpu(void)
  198. {
  199. BUG_ON(smp_processor_id() != 0);
  200. native_smp_prepare_boot_cpu();
  201. /* We've switched to the "real" per-cpu gdt, so make sure the
  202. old memory can be recycled */
  203. make_lowmem_page_readwrite(xen_initial_gdt);
  204. xen_filter_cpu_maps();
  205. xen_setup_vcpu_info_placement();
  206. }
  207. static void __init xen_smp_prepare_cpus(unsigned int max_cpus)
  208. {
  209. unsigned cpu;
  210. unsigned int i;
  211. if (skip_ioapic_setup) {
  212. char *m = (max_cpus == 0) ?
  213. "The nosmp parameter is incompatible with Xen; " \
  214. "use Xen dom0_max_vcpus=1 parameter" :
  215. "The noapic parameter is incompatible with Xen";
  216. xen_raw_printk(m);
  217. panic(m);
  218. }
  219. xen_init_lock_cpu(0);
  220. smp_store_boot_cpu_info();
  221. cpu_data(0).x86_max_cores = 1;
  222. for_each_possible_cpu(i) {
  223. zalloc_cpumask_var(&per_cpu(cpu_sibling_map, i), GFP_KERNEL);
  224. zalloc_cpumask_var(&per_cpu(cpu_core_map, i), GFP_KERNEL);
  225. zalloc_cpumask_var(&per_cpu(cpu_llc_shared_map, i), GFP_KERNEL);
  226. }
  227. set_cpu_sibling_map(0);
  228. if (xen_smp_intr_init(0))
  229. BUG();
  230. if (!alloc_cpumask_var(&xen_cpu_initialized_map, GFP_KERNEL))
  231. panic("could not allocate xen_cpu_initialized_map\n");
  232. cpumask_copy(xen_cpu_initialized_map, cpumask_of(0));
  233. /* Restrict the possible_map according to max_cpus. */
  234. while ((num_possible_cpus() > 1) && (num_possible_cpus() > max_cpus)) {
  235. for (cpu = nr_cpu_ids - 1; !cpu_possible(cpu); cpu--)
  236. continue;
  237. set_cpu_possible(cpu, false);
  238. }
  239. for_each_possible_cpu(cpu)
  240. set_cpu_present(cpu, true);
  241. }
  242. static int __cpuinit
  243. cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
  244. {
  245. struct vcpu_guest_context *ctxt;
  246. struct desc_struct *gdt;
  247. unsigned long gdt_mfn;
  248. if (cpumask_test_and_set_cpu(cpu, xen_cpu_initialized_map))
  249. return 0;
  250. ctxt = kzalloc(sizeof(*ctxt), GFP_KERNEL);
  251. if (ctxt == NULL)
  252. return -ENOMEM;
  253. gdt = get_cpu_gdt_table(cpu);
  254. ctxt->flags = VGCF_IN_KERNEL;
  255. ctxt->user_regs.ss = __KERNEL_DS;
  256. #ifdef CONFIG_X86_32
  257. ctxt->user_regs.fs = __KERNEL_PERCPU;
  258. ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
  259. #else
  260. ctxt->gs_base_kernel = per_cpu_offset(cpu);
  261. #endif
  262. ctxt->user_regs.eip = (unsigned long)cpu_bringup_and_idle;
  263. memset(&ctxt->fpu_ctxt, 0, sizeof(ctxt->fpu_ctxt));
  264. {
  265. ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
  266. ctxt->user_regs.ds = __USER_DS;
  267. ctxt->user_regs.es = __USER_DS;
  268. xen_copy_trap_info(ctxt->trap_ctxt);
  269. ctxt->ldt_ents = 0;
  270. BUG_ON((unsigned long)gdt & ~PAGE_MASK);
  271. gdt_mfn = arbitrary_virt_to_mfn(gdt);
  272. make_lowmem_page_readonly(gdt);
  273. make_lowmem_page_readonly(mfn_to_virt(gdt_mfn));
  274. ctxt->gdt_frames[0] = gdt_mfn;
  275. ctxt->gdt_ents = GDT_ENTRIES;
  276. ctxt->kernel_ss = __KERNEL_DS;
  277. ctxt->kernel_sp = idle->thread.sp0;
  278. #ifdef CONFIG_X86_32
  279. ctxt->event_callback_cs = __KERNEL_CS;
  280. ctxt->failsafe_callback_cs = __KERNEL_CS;
  281. #endif
  282. ctxt->event_callback_eip =
  283. (unsigned long)xen_hypervisor_callback;
  284. ctxt->failsafe_callback_eip =
  285. (unsigned long)xen_failsafe_callback;
  286. }
  287. ctxt->user_regs.cs = __KERNEL_CS;
  288. ctxt->user_regs.esp = idle->thread.sp0 - sizeof(struct pt_regs);
  289. per_cpu(xen_cr3, cpu) = __pa(swapper_pg_dir);
  290. ctxt->ctrlreg[3] = xen_pfn_to_cr3(virt_to_mfn(swapper_pg_dir));
  291. if (HYPERVISOR_vcpu_op(VCPUOP_initialise, cpu, ctxt))
  292. BUG();
  293. kfree(ctxt);
  294. return 0;
  295. }
  296. static int __cpuinit xen_cpu_up(unsigned int cpu, struct task_struct *idle)
  297. {
  298. int rc;
  299. per_cpu(current_task, cpu) = idle;
  300. #ifdef CONFIG_X86_32
  301. irq_ctx_init(cpu);
  302. #else
  303. clear_tsk_thread_flag(idle, TIF_FORK);
  304. per_cpu(kernel_stack, cpu) =
  305. (unsigned long)task_stack_page(idle) -
  306. KERNEL_STACK_OFFSET + THREAD_SIZE;
  307. #endif
  308. xen_setup_runstate_info(cpu);
  309. xen_setup_timer(cpu);
  310. xen_init_lock_cpu(cpu);
  311. per_cpu(cpu_state, cpu) = CPU_UP_PREPARE;
  312. /* make sure interrupts start blocked */
  313. per_cpu(xen_vcpu, cpu)->evtchn_upcall_mask = 1;
  314. rc = cpu_initialize_context(cpu, idle);
  315. if (rc)
  316. return rc;
  317. if (num_online_cpus() == 1)
  318. /* Just in case we booted with a single CPU. */
  319. alternatives_enable_smp();
  320. rc = xen_smp_intr_init(cpu);
  321. if (rc)
  322. return rc;
  323. rc = HYPERVISOR_vcpu_op(VCPUOP_up, cpu, NULL);
  324. BUG_ON(rc);
  325. while(per_cpu(cpu_state, cpu) != CPU_ONLINE) {
  326. HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
  327. barrier();
  328. }
  329. return 0;
  330. }
  331. static void xen_smp_cpus_done(unsigned int max_cpus)
  332. {
  333. }
  334. #ifdef CONFIG_HOTPLUG_CPU
  335. static int xen_cpu_disable(void)
  336. {
  337. unsigned int cpu = smp_processor_id();
  338. if (cpu == 0)
  339. return -EBUSY;
  340. cpu_disable_common();
  341. load_cr3(swapper_pg_dir);
  342. return 0;
  343. }
  344. static void xen_cpu_die(unsigned int cpu)
  345. {
  346. while (xen_pv_domain() && HYPERVISOR_vcpu_op(VCPUOP_is_up, cpu, NULL)) {
  347. current->state = TASK_UNINTERRUPTIBLE;
  348. schedule_timeout(HZ/10);
  349. }
  350. unbind_from_irqhandler(per_cpu(xen_resched_irq, cpu), NULL);
  351. unbind_from_irqhandler(per_cpu(xen_callfunc_irq, cpu), NULL);
  352. unbind_from_irqhandler(per_cpu(xen_debug_irq, cpu), NULL);
  353. unbind_from_irqhandler(per_cpu(xen_callfuncsingle_irq, cpu), NULL);
  354. if (!xen_hvm_domain())
  355. unbind_from_irqhandler(per_cpu(xen_irq_work, cpu), NULL);
  356. xen_uninit_lock_cpu(cpu);
  357. xen_teardown_timer(cpu);
  358. }
  359. static void __cpuinit xen_play_dead(void) /* used only with HOTPLUG_CPU */
  360. {
  361. play_dead_common();
  362. HYPERVISOR_vcpu_op(VCPUOP_down, smp_processor_id(), NULL);
  363. cpu_bringup();
  364. }
  365. #else /* !CONFIG_HOTPLUG_CPU */
  366. static int xen_cpu_disable(void)
  367. {
  368. return -ENOSYS;
  369. }
  370. static void xen_cpu_die(unsigned int cpu)
  371. {
  372. BUG();
  373. }
  374. static void xen_play_dead(void)
  375. {
  376. BUG();
  377. }
  378. #endif
  379. static void stop_self(void *v)
  380. {
  381. int cpu = smp_processor_id();
  382. /* make sure we're not pinning something down */
  383. load_cr3(swapper_pg_dir);
  384. /* should set up a minimal gdt */
  385. set_cpu_online(cpu, false);
  386. HYPERVISOR_vcpu_op(VCPUOP_down, cpu, NULL);
  387. BUG();
  388. }
  389. static void xen_stop_other_cpus(int wait)
  390. {
  391. smp_call_function(stop_self, NULL, wait);
  392. }
  393. static void xen_smp_send_reschedule(int cpu)
  394. {
  395. xen_send_IPI_one(cpu, XEN_RESCHEDULE_VECTOR);
  396. }
  397. static void __xen_send_IPI_mask(const struct cpumask *mask,
  398. int vector)
  399. {
  400. unsigned cpu;
  401. for_each_cpu_and(cpu, mask, cpu_online_mask)
  402. xen_send_IPI_one(cpu, vector);
  403. }
  404. static void xen_smp_send_call_function_ipi(const struct cpumask *mask)
  405. {
  406. int cpu;
  407. __xen_send_IPI_mask(mask, XEN_CALL_FUNCTION_VECTOR);
  408. /* Make sure other vcpus get a chance to run if they need to. */
  409. for_each_cpu(cpu, mask) {
  410. if (xen_vcpu_stolen(cpu)) {
  411. HYPERVISOR_sched_op(SCHEDOP_yield, NULL);
  412. break;
  413. }
  414. }
  415. }
  416. static void xen_smp_send_call_function_single_ipi(int cpu)
  417. {
  418. __xen_send_IPI_mask(cpumask_of(cpu),
  419. XEN_CALL_FUNCTION_SINGLE_VECTOR);
  420. }
  421. static inline int xen_map_vector(int vector)
  422. {
  423. int xen_vector;
  424. switch (vector) {
  425. case RESCHEDULE_VECTOR:
  426. xen_vector = XEN_RESCHEDULE_VECTOR;
  427. break;
  428. case CALL_FUNCTION_VECTOR:
  429. xen_vector = XEN_CALL_FUNCTION_VECTOR;
  430. break;
  431. case CALL_FUNCTION_SINGLE_VECTOR:
  432. xen_vector = XEN_CALL_FUNCTION_SINGLE_VECTOR;
  433. break;
  434. case IRQ_WORK_VECTOR:
  435. xen_vector = XEN_IRQ_WORK_VECTOR;
  436. break;
  437. default:
  438. xen_vector = -1;
  439. printk(KERN_ERR "xen: vector 0x%x is not implemented\n",
  440. vector);
  441. }
  442. return xen_vector;
  443. }
  444. void xen_send_IPI_mask(const struct cpumask *mask,
  445. int vector)
  446. {
  447. int xen_vector = xen_map_vector(vector);
  448. if (xen_vector >= 0)
  449. __xen_send_IPI_mask(mask, xen_vector);
  450. }
  451. void xen_send_IPI_all(int vector)
  452. {
  453. int xen_vector = xen_map_vector(vector);
  454. if (xen_vector >= 0)
  455. __xen_send_IPI_mask(cpu_online_mask, xen_vector);
  456. }
  457. void xen_send_IPI_self(int vector)
  458. {
  459. int xen_vector = xen_map_vector(vector);
  460. if (xen_vector >= 0)
  461. xen_send_IPI_one(smp_processor_id(), xen_vector);
  462. }
  463. void xen_send_IPI_mask_allbutself(const struct cpumask *mask,
  464. int vector)
  465. {
  466. unsigned cpu;
  467. unsigned int this_cpu = smp_processor_id();
  468. if (!(num_online_cpus() > 1))
  469. return;
  470. for_each_cpu_and(cpu, mask, cpu_online_mask) {
  471. if (this_cpu == cpu)
  472. continue;
  473. xen_smp_send_call_function_single_ipi(cpu);
  474. }
  475. }
  476. void xen_send_IPI_allbutself(int vector)
  477. {
  478. int xen_vector = xen_map_vector(vector);
  479. if (xen_vector >= 0)
  480. xen_send_IPI_mask_allbutself(cpu_online_mask, xen_vector);
  481. }
  482. static irqreturn_t xen_call_function_interrupt(int irq, void *dev_id)
  483. {
  484. irq_enter();
  485. generic_smp_call_function_interrupt();
  486. inc_irq_stat(irq_call_count);
  487. irq_exit();
  488. return IRQ_HANDLED;
  489. }
  490. static irqreturn_t xen_call_function_single_interrupt(int irq, void *dev_id)
  491. {
  492. irq_enter();
  493. generic_smp_call_function_single_interrupt();
  494. inc_irq_stat(irq_call_count);
  495. irq_exit();
  496. return IRQ_HANDLED;
  497. }
  498. static irqreturn_t xen_irq_work_interrupt(int irq, void *dev_id)
  499. {
  500. irq_enter();
  501. irq_work_run();
  502. inc_irq_stat(apic_irq_work_irqs);
  503. irq_exit();
  504. return IRQ_HANDLED;
  505. }
  506. static const struct smp_ops xen_smp_ops __initconst = {
  507. .smp_prepare_boot_cpu = xen_smp_prepare_boot_cpu,
  508. .smp_prepare_cpus = xen_smp_prepare_cpus,
  509. .smp_cpus_done = xen_smp_cpus_done,
  510. .cpu_up = xen_cpu_up,
  511. .cpu_die = xen_cpu_die,
  512. .cpu_disable = xen_cpu_disable,
  513. .play_dead = xen_play_dead,
  514. .stop_other_cpus = xen_stop_other_cpus,
  515. .smp_send_reschedule = xen_smp_send_reschedule,
  516. .send_call_func_ipi = xen_smp_send_call_function_ipi,
  517. .send_call_func_single_ipi = xen_smp_send_call_function_single_ipi,
  518. };
  519. void __init xen_smp_init(void)
  520. {
  521. smp_ops = xen_smp_ops;
  522. xen_fill_possible_map();
  523. xen_init_spinlocks();
  524. }
  525. static void __init xen_hvm_smp_prepare_cpus(unsigned int max_cpus)
  526. {
  527. native_smp_prepare_cpus(max_cpus);
  528. WARN_ON(xen_smp_intr_init(0));
  529. xen_init_lock_cpu(0);
  530. }
  531. static int __cpuinit xen_hvm_cpu_up(unsigned int cpu, struct task_struct *tidle)
  532. {
  533. int rc;
  534. rc = native_cpu_up(cpu, tidle);
  535. WARN_ON (xen_smp_intr_init(cpu));
  536. return rc;
  537. }
  538. static void xen_hvm_cpu_die(unsigned int cpu)
  539. {
  540. xen_cpu_die(cpu);
  541. native_cpu_die(cpu);
  542. }
  543. void __init xen_hvm_smp_init(void)
  544. {
  545. if (!xen_have_vector_callback)
  546. return;
  547. smp_ops.smp_prepare_cpus = xen_hvm_smp_prepare_cpus;
  548. smp_ops.smp_send_reschedule = xen_smp_send_reschedule;
  549. smp_ops.cpu_up = xen_hvm_cpu_up;
  550. smp_ops.cpu_die = xen_hvm_cpu_die;
  551. smp_ops.send_call_func_ipi = xen_smp_send_call_function_ipi;
  552. smp_ops.send_call_func_single_ipi = xen_smp_send_call_function_single_ipi;
  553. }