smp_hvm.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #include <asm/smp.h>
  2. #include <xen/events.h>
  3. #include "xen-ops.h"
  4. #include "smp.h"
  5. static void __init xen_hvm_smp_prepare_boot_cpu(void)
  6. {
  7. BUG_ON(smp_processor_id() != 0);
  8. native_smp_prepare_boot_cpu();
  9. /*
  10. * Setup vcpu_info for boot CPU. Secondary CPUs get their vcpu_info
  11. * in xen_cpu_up_prepare_hvm().
  12. */
  13. xen_vcpu_setup(0);
  14. /*
  15. * The alternative logic (which patches the unlock/lock) runs before
  16. * the smp bootup up code is activated. Hence we need to set this up
  17. * the core kernel is being patched. Otherwise we will have only
  18. * modules patched but not core code.
  19. */
  20. xen_init_spinlocks();
  21. }
  22. static void __init xen_hvm_smp_prepare_cpus(unsigned int max_cpus)
  23. {
  24. int cpu;
  25. native_smp_prepare_cpus(max_cpus);
  26. WARN_ON(xen_smp_intr_init(0));
  27. xen_init_lock_cpu(0);
  28. for_each_possible_cpu(cpu) {
  29. if (cpu == 0)
  30. continue;
  31. /* Set default vcpu_id to make sure that we don't use cpu-0's */
  32. per_cpu(xen_vcpu_id, cpu) = XEN_VCPU_ID_INVALID;
  33. }
  34. }
  35. #ifdef CONFIG_HOTPLUG_CPU
  36. static void xen_hvm_cpu_die(unsigned int cpu)
  37. {
  38. if (common_cpu_die(cpu) == 0) {
  39. xen_smp_intr_free(cpu);
  40. xen_uninit_lock_cpu(cpu);
  41. xen_teardown_timer(cpu);
  42. }
  43. }
  44. #else
  45. static void xen_hvm_cpu_die(unsigned int cpu)
  46. {
  47. BUG();
  48. }
  49. #endif
  50. void __init xen_hvm_smp_init(void)
  51. {
  52. if (!xen_have_vector_callback)
  53. return;
  54. smp_ops.smp_prepare_cpus = xen_hvm_smp_prepare_cpus;
  55. smp_ops.smp_send_reschedule = xen_smp_send_reschedule;
  56. smp_ops.cpu_die = xen_hvm_cpu_die;
  57. smp_ops.send_call_func_ipi = xen_smp_send_call_function_ipi;
  58. smp_ops.send_call_func_single_ipi = xen_smp_send_call_function_single_ipi;
  59. smp_ops.smp_prepare_boot_cpu = xen_hvm_smp_prepare_boot_cpu;
  60. smp_ops.smp_cpus_done = xen_smp_cpus_done;
  61. }