blob: 45329c8c226e4c4070f16a791b300265a0bf472b [file] [log] [blame]
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +01001#include <linux/types.h>
Ian Campbellf6eafe32009-11-25 14:12:08 +00002#include <linux/clockchips.h>
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +01003
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 Molnar99d00002009-01-23 11:09:15 +010010#include <asm/fixmap.h>
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +010011
12#include "xen-ops.h"
13#include "mmu.h"
14
Ian Campbell03c81422011-02-17 11:04:20 +000015void xen_arch_pre_suspend(void)
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +010016{
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
Ian Campbell03c81422011-02-17 11:04:20 +000029void xen_arch_hvm_post_suspend(int suspend_cancelled)
Stefano Stabellini016b6f52010-05-14 12:45:07 +010030{
Stefano Stabellinie057a4b2011-02-11 17:55:13 +000031#ifdef CONFIG_XEN_PVHVM
Stefano Stabellini409771d2010-05-14 12:48:19 +010032 int cpu;
Stefano Stabellini016b6f52010-05-14 12:45:07 +010033 xen_hvm_init_shared_info();
34 xen_callback_vector();
Stefano Stabellini512b1092010-12-01 14:51:44 +000035 xen_unplug_emulated_devices();
Stefano Stabellini409771d2010-05-14 12:48:19 +010036 if (xen_feature(XENFEAT_hvm_safe_pvclock)) {
37 for_each_online_cpu(cpu) {
38 xen_setup_runstate_info(cpu);
39 }
40 }
Stefano Stabellinie057a4b2011-02-11 17:55:13 +000041#endif
Stefano Stabellini016b6f52010-05-14 12:45:07 +010042}
43
Ian Campbell03c81422011-02-17 11:04:20 +000044void xen_arch_post_suspend(int suspend_cancelled)
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +010045{
Ian Campbellfa24ba62009-11-21 11:32:49 +000046 xen_build_mfn_list_list();
47
Jeremy Fitzhardinge9c7a7942008-05-31 01:33:02 +010048 xen_setup_shared_info();
49
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +010050 if (suspend_cancelled) {
51 xen_start_info->store_mfn =
52 pfn_to_mfn(xen_start_info->store_mfn);
53 xen_start_info->console.domU.mfn =
54 pfn_to_mfn(xen_start_info->console.domU.mfn);
55 } else {
56#ifdef CONFIG_SMP
Mike Travisb78936e2008-12-16 17:33:57 -080057 BUG_ON(xen_cpu_initialized_map == NULL);
58 cpumask_copy(xen_cpu_initialized_map, cpu_online_mask);
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +010059#endif
Jeremy Fitzhardinge9c7a7942008-05-31 01:33:02 +010060 xen_vcpu_restore();
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +010061 }
62
Jeremy Fitzhardinge0e913982008-05-26 23:31:27 +010063}
64
Ian Campbellf6eafe32009-11-25 14:12:08 +000065static void xen_vcpu_notify_restore(void *data)
66{
67 unsigned long reason = (unsigned long)data;
68
69 /* Boot processor notified via generic timekeeping_resume() */
70 if ( smp_processor_id() == 0)
71 return;
72
73 clockevents_notify(reason, NULL);
74}
75
Isaku Yamahataad55db92008-07-08 15:06:32 -070076void xen_arch_resume(void)
77{
Ian Campbellcd52e172010-05-19 16:19:25 +010078 on_each_cpu(xen_vcpu_notify_restore,
79 (void *)CLOCK_EVT_NOTIFY_RESUME, 1);
Isaku Yamahataad55db92008-07-08 15:06:32 -070080}