Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 1 | #include <linux/types.h> |
Thomas Gleixner | 4ffee52 | 2015-03-25 13:09:16 +0100 | [diff] [blame] | 2 | #include <linux/tick.h> |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 3 | |
| 4 | #include <xen/interface/xen.h> |
| 5 | #include <xen/grant_table.h> |
| 6 | #include <xen/events.h> |
| 7 | |
| 8 | #include <asm/xen/hypercall.h> |
| 9 | #include <asm/xen/page.h> |
Ingo Molnar | 99d0000 | 2009-01-23 11:09:15 +0100 | [diff] [blame] | 10 | #include <asm/fixmap.h> |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 11 | |
| 12 | #include "xen-ops.h" |
| 13 | #include "mmu.h" |
| 14 | |
David Vrabel | aa8532c | 2014-05-08 11:09:23 +0100 | [diff] [blame] | 15 | static void xen_pv_pre_suspend(void) |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 16 | { |
David Vrabel | aa8532c | 2014-05-08 11:09:23 +0100 | [diff] [blame] | 17 | xen_mm_pin_all(); |
| 18 | |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 19 | xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn); |
| 20 | xen_start_info->console.domU.mfn = |
| 21 | mfn_to_pfn(xen_start_info->console.domU.mfn); |
| 22 | |
| 23 | BUG_ON(!irqs_disabled()); |
| 24 | |
| 25 | HYPERVISOR_shared_info = &xen_dummy_shared_info; |
| 26 | if (HYPERVISOR_update_va_mapping(fix_to_virt(FIX_PARAVIRT_BOOTMAP), |
| 27 | __pte_ma(0), 0)) |
| 28 | BUG(); |
| 29 | } |
| 30 | |
David Vrabel | aa8532c | 2014-05-08 11:09:23 +0100 | [diff] [blame] | 31 | static void xen_hvm_post_suspend(int suspend_cancelled) |
Stefano Stabellini | 016b6f5 | 2010-05-14 12:45:07 +0100 | [diff] [blame] | 32 | { |
Stefano Stabellini | e057a4b | 2011-02-11 17:55:13 +0000 | [diff] [blame] | 33 | #ifdef CONFIG_XEN_PVHVM |
Stefano Stabellini | 409771d | 2010-05-14 12:48:19 +0100 | [diff] [blame] | 34 | int cpu; |
Konrad Rzeszutek Wilk | e9daff2 | 2013-02-14 21:29:31 -0500 | [diff] [blame] | 35 | xen_hvm_init_shared_info(); |
Stefano Stabellini | 016b6f5 | 2010-05-14 12:45:07 +0100 | [diff] [blame] | 36 | xen_callback_vector(); |
Stefano Stabellini | 512b109 | 2010-12-01 14:51:44 +0000 | [diff] [blame] | 37 | xen_unplug_emulated_devices(); |
Stefano Stabellini | 409771d | 2010-05-14 12:48:19 +0100 | [diff] [blame] | 38 | if (xen_feature(XENFEAT_hvm_safe_pvclock)) { |
| 39 | for_each_online_cpu(cpu) { |
| 40 | xen_setup_runstate_info(cpu); |
| 41 | } |
| 42 | } |
Stefano Stabellini | e057a4b | 2011-02-11 17:55:13 +0000 | [diff] [blame] | 43 | #endif |
Stefano Stabellini | 016b6f5 | 2010-05-14 12:45:07 +0100 | [diff] [blame] | 44 | } |
| 45 | |
David Vrabel | aa8532c | 2014-05-08 11:09:23 +0100 | [diff] [blame] | 46 | static void xen_pv_post_suspend(int suspend_cancelled) |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 47 | { |
Ian Campbell | fa24ba6 | 2009-11-21 11:32:49 +0000 | [diff] [blame] | 48 | xen_build_mfn_list_list(); |
| 49 | |
Jeremy Fitzhardinge | 9c7a794 | 2008-05-31 01:33:02 +0100 | [diff] [blame] | 50 | xen_setup_shared_info(); |
| 51 | |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 52 | if (suspend_cancelled) { |
| 53 | xen_start_info->store_mfn = |
| 54 | pfn_to_mfn(xen_start_info->store_mfn); |
| 55 | xen_start_info->console.domU.mfn = |
| 56 | pfn_to_mfn(xen_start_info->console.domU.mfn); |
| 57 | } else { |
| 58 | #ifdef CONFIG_SMP |
Mike Travis | b78936e | 2008-12-16 17:33:57 -0800 | [diff] [blame] | 59 | BUG_ON(xen_cpu_initialized_map == NULL); |
| 60 | cpumask_copy(xen_cpu_initialized_map, cpu_online_mask); |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 61 | #endif |
Jeremy Fitzhardinge | 9c7a794 | 2008-05-31 01:33:02 +0100 | [diff] [blame] | 62 | xen_vcpu_restore(); |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 63 | } |
| 64 | |
David Vrabel | aa8532c | 2014-05-08 11:09:23 +0100 | [diff] [blame] | 65 | xen_mm_unpin_all(); |
| 66 | } |
| 67 | |
| 68 | void xen_arch_pre_suspend(void) |
| 69 | { |
| 70 | if (xen_pv_domain()) |
| 71 | xen_pv_pre_suspend(); |
| 72 | } |
| 73 | |
| 74 | void xen_arch_post_suspend(int cancelled) |
| 75 | { |
| 76 | if (xen_pv_domain()) |
| 77 | xen_pv_post_suspend(cancelled); |
| 78 | else |
| 79 | xen_hvm_post_suspend(cancelled); |
Jeremy Fitzhardinge | 0e91398 | 2008-05-26 23:31:27 +0100 | [diff] [blame] | 80 | } |
| 81 | |
Ian Campbell | f6eafe3 | 2009-11-25 14:12:08 +0000 | [diff] [blame] | 82 | static void xen_vcpu_notify_restore(void *data) |
| 83 | { |
Ian Campbell | f6eafe3 | 2009-11-25 14:12:08 +0000 | [diff] [blame] | 84 | /* Boot processor notified via generic timekeeping_resume() */ |
Thomas Gleixner | 4ffee52 | 2015-03-25 13:09:16 +0100 | [diff] [blame] | 85 | if (smp_processor_id() == 0) |
Ian Campbell | f6eafe3 | 2009-11-25 14:12:08 +0000 | [diff] [blame] | 86 | return; |
| 87 | |
Thomas Gleixner | f46481d | 2015-03-25 13:11:04 +0100 | [diff] [blame] | 88 | tick_resume_local(); |
Ian Campbell | f6eafe3 | 2009-11-25 14:12:08 +0000 | [diff] [blame] | 89 | } |
| 90 | |
Isaku Yamahata | ad55db9 | 2008-07-08 15:06:32 -0700 | [diff] [blame] | 91 | void xen_arch_resume(void) |
| 92 | { |
Thomas Gleixner | 4ffee52 | 2015-03-25 13:09:16 +0100 | [diff] [blame] | 93 | on_each_cpu(xen_vcpu_notify_restore, NULL, 1); |
Isaku Yamahata | ad55db9 | 2008-07-08 15:06:32 -0700 | [diff] [blame] | 94 | } |