xref: /linux/arch/x86/xen/suspend.c (revision d39d0ed196aa1685bb24771e92f78633c66ac9cb)
1 #include <linux/types.h>
2 #include <linux/clockchips.h>
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>
10 #include <asm/fixmap.h>
11 
12 #include "xen-ops.h"
13 #include "mmu.h"
14 
15 void xen_pre_suspend(void)
16 {
17 	xen_start_info->store_mfn = mfn_to_pfn(xen_start_info->store_mfn);
18 	xen_start_info->console.domU.mfn =
19 		mfn_to_pfn(xen_start_info->console.domU.mfn);
20 
21 	BUG_ON(!irqs_disabled());
22 
23 	HYPERVISOR_shared_info = &xen_dummy_shared_info;
24 	if (HYPERVISOR_update_va_mapping(fix_to_virt(FIX_PARAVIRT_BOOTMAP),
25 					 __pte_ma(0), 0))
26 		BUG();
27 }
28 
29 void xen_hvm_post_suspend(int suspend_cancelled)
30 {
31 	int cpu;
32 	xen_hvm_init_shared_info();
33 	xen_callback_vector();
34 	if (xen_feature(XENFEAT_hvm_safe_pvclock)) {
35 		for_each_online_cpu(cpu) {
36 			xen_setup_runstate_info(cpu);
37 		}
38 	}
39 }
40 
41 void xen_post_suspend(int suspend_cancelled)
42 {
43 	xen_build_mfn_list_list();
44 
45 	xen_setup_shared_info();
46 
47 	if (suspend_cancelled) {
48 		xen_start_info->store_mfn =
49 			pfn_to_mfn(xen_start_info->store_mfn);
50 		xen_start_info->console.domU.mfn =
51 			pfn_to_mfn(xen_start_info->console.domU.mfn);
52 	} else {
53 #ifdef CONFIG_SMP
54 		BUG_ON(xen_cpu_initialized_map == NULL);
55 		cpumask_copy(xen_cpu_initialized_map, cpu_online_mask);
56 #endif
57 		xen_vcpu_restore();
58 	}
59 
60 }
61 
62 static void xen_vcpu_notify_restore(void *data)
63 {
64 	unsigned long reason = (unsigned long)data;
65 
66 	/* Boot processor notified via generic timekeeping_resume() */
67 	if ( smp_processor_id() == 0)
68 		return;
69 
70 	clockevents_notify(reason, NULL);
71 }
72 
73 void xen_arch_resume(void)
74 {
75 	on_each_cpu(xen_vcpu_notify_restore,
76 		    (void *)CLOCK_EVT_NOTIFY_RESUME, 1);
77 }
78