smp_hvm.c 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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.
  11. */
  12. xen_vcpu_setup(0);
  13. /*
  14. * The alternative logic (which patches the unlock/lock) runs before
  15. * the smp bootup up code is activated. Hence we need to set this up
  16. * the core kernel is being patched. Otherwise we will have only
  17. * modules patched but not core code.
  18. */
  19. xen_init_spinlocks();
  20. }
  21. static void __init xen_hvm_smp_prepare_cpus(unsigned int max_cpus)
  22. {
  23. native_smp_prepare_cpus(max_cpus);
  24. WARN_ON(xen_smp_intr_init(0));
  25. xen_init_lock_cpu(0);
  26. }
  27. #ifdef CONFIG_HOTPLUG_CPU
  28. static void xen_hvm_cpu_die(unsigned int cpu)
  29. {
  30. if (common_cpu_die(cpu) == 0) {
  31. xen_smp_intr_free(cpu);
  32. xen_uninit_lock_cpu(cpu);
  33. xen_teardown_timer(cpu);
  34. }
  35. }
  36. #else
  37. static void xen_hvm_cpu_die(unsigned int cpu)
  38. {
  39. BUG();
  40. }
  41. #endif
  42. void __init xen_hvm_smp_init(void)
  43. {
  44. if (!xen_have_vector_callback)
  45. return;
  46. smp_ops.smp_prepare_cpus = xen_hvm_smp_prepare_cpus;
  47. smp_ops.smp_send_reschedule = xen_smp_send_reschedule;
  48. smp_ops.cpu_die = xen_hvm_cpu_die;
  49. smp_ops.send_call_func_ipi = xen_smp_send_call_function_ipi;
  50. smp_ops.send_call_func_single_ipi = xen_smp_send_call_function_single_ipi;
  51. smp_ops.smp_prepare_boot_cpu = xen_hvm_smp_prepare_boot_cpu;
  52. }