suspend.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #include <linux/types.h>
  2. #include <linux/clockchips.h>
  3. #include <xen/interface/xen.h>
  4. #include <xen/grant_table.h>
  5. #include <xen/events.h>
  6. #include <asm/xen/hypercall.h>
  7. #include <asm/xen/page.h>
  8. #include <asm/fixmap.h>
  9. #include "xen-ops.h"
  10. #include "mmu.h"
  11. void xen_pre_suspend(void)
  12. {
  13. xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn);
  14. xen_start_info->console.domU.mfn =
  15. mfn_to_pfn(xen_start_info->console.domU.mfn);
  16. BUG_ON(!irqs_disabled());
  17. HYPERVISOR_shared_info = &xen_dummy_shared_info;
  18. if (HYPERVISOR_update_va_mapping(fix_to_virt(FIX_PARAVIRT_BOOTMAP),
  19. __pte_ma(0), 0))
  20. BUG();
  21. }
  22. void xen_hvm_post_suspend(int suspend_cancelled)
  23. {
  24. int cpu;
  25. xen_hvm_init_shared_info();
  26. xen_callback_vector();
  27. xen_unplug_emulated_devices();
  28. if (xen_feature(XENFEAT_hvm_safe_pvclock)) {
  29. for_each_online_cpu(cpu) {
  30. xen_setup_runstate_info(cpu);
  31. }
  32. }
  33. }
  34. void xen_post_suspend(int suspend_cancelled)
  35. {
  36. xen_build_mfn_list_list();
  37. xen_setup_shared_info();
  38. if (suspend_cancelled) {
  39. xen_start_info->store_mfn =
  40. pfn_to_mfn(xen_start_info->store_mfn);
  41. xen_start_info->console.domU.mfn =
  42. pfn_to_mfn(xen_start_info->console.domU.mfn);
  43. } else {
  44. #ifdef CONFIG_SMP
  45. BUG_ON(xen_cpu_initialized_map == NULL);
  46. cpumask_copy(xen_cpu_initialized_map, cpu_online_mask);
  47. #endif
  48. xen_vcpu_restore();
  49. }
  50. }
  51. static void xen_vcpu_notify_restore(void *data)
  52. {
  53. unsigned long reason = (unsigned long)data;
  54. /* Boot processor notified via generic timekeeping_resume() */
  55. if ( smp_processor_id() == 0)
  56. return;
  57. clockevents_notify(reason, NULL);
  58. }
  59. void xen_arch_resume(void)
  60. {
  61. on_each_cpu(xen_vcpu_notify_restore,
  62. (void *)CLOCK_EVT_NOTIFY_RESUME, 1);
  63. }