]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | // SPDX-License-Identifier: GPL-2.0 |
0e91398f | 2 | #include <linux/types.h> |
4ffee521 | 3 | #include <linux/tick.h> |
71c208dd | 4 | #include <linux/percpu-defs.h> |
0e91398f | 5 | |
facca616 | 6 | #include <xen/xen.h> |
0e91398f JF |
7 | #include <xen/interface/xen.h> |
8 | #include <xen/grant_table.h> | |
9 | #include <xen/events.h> | |
10 | ||
71c208dd JG |
11 | #include <asm/cpufeatures.h> |
12 | #include <asm/msr-index.h> | |
0e91398f JF |
13 | #include <asm/xen/hypercall.h> |
14 | #include <asm/xen/page.h> | |
99d0000f | 15 | #include <asm/fixmap.h> |
0e91398f JF |
16 | |
17 | #include "xen-ops.h" | |
18 | #include "mmu.h" | |
65d0cf0b | 19 | #include "pmu.h" |
0e91398f | 20 | |
71c208dd JG |
21 | static DEFINE_PER_CPU(u64, spec_ctrl); |
22 | ||
aa8532c3 DV |
23 | void xen_arch_pre_suspend(void) |
24 | { | |
2229f70b JM |
25 | xen_save_time_memory_area(); |
26 | ||
65d0cf0b BO |
27 | if (xen_pv_domain()) |
28 | xen_pv_pre_suspend(); | |
aa8532c3 DV |
29 | } |
30 | ||
31 | void xen_arch_post_suspend(int cancelled) | |
32 | { | |
65d0cf0b BO |
33 | if (xen_pv_domain()) |
34 | xen_pv_post_suspend(cancelled); | |
35 | else | |
36 | xen_hvm_post_suspend(cancelled); | |
2229f70b JM |
37 | |
38 | xen_restore_time_memory_area(); | |
0e91398f JF |
39 | } |
40 | ||
f6eafe36 IC |
41 | static void xen_vcpu_notify_restore(void *data) |
42 | { | |
71c208dd JG |
43 | if (xen_pv_domain() && boot_cpu_has(X86_FEATURE_SPEC_CTRL)) |
44 | wrmsrl(MSR_IA32_SPEC_CTRL, this_cpu_read(spec_ctrl)); | |
45 | ||
f6eafe36 | 46 | /* Boot processor notified via generic timekeeping_resume() */ |
4ffee521 | 47 | if (smp_processor_id() == 0) |
f6eafe36 IC |
48 | return; |
49 | ||
f46481d0 | 50 | tick_resume_local(); |
f6eafe36 IC |
51 | } |
52 | ||
2b953a5e BO |
53 | static void xen_vcpu_notify_suspend(void *data) |
54 | { | |
71c208dd JG |
55 | u64 tmp; |
56 | ||
2b953a5e | 57 | tick_suspend_local(); |
71c208dd JG |
58 | |
59 | if (xen_pv_domain() && boot_cpu_has(X86_FEATURE_SPEC_CTRL)) { | |
60 | rdmsrl(MSR_IA32_SPEC_CTRL, tmp); | |
61 | this_cpu_write(spec_ctrl, tmp); | |
62 | wrmsrl(MSR_IA32_SPEC_CTRL, 0); | |
63 | } | |
2b953a5e BO |
64 | } |
65 | ||
ad55db9f IY |
66 | void xen_arch_resume(void) |
67 | { | |
de0afc9b BO |
68 | int cpu; |
69 | ||
4ffee521 | 70 | on_each_cpu(xen_vcpu_notify_restore, NULL, 1); |
de0afc9b BO |
71 | |
72 | for_each_online_cpu(cpu) | |
73 | xen_pmu_init(cpu); | |
ad55db9f | 74 | } |
2b953a5e BO |
75 | |
76 | void xen_arch_suspend(void) | |
77 | { | |
de0afc9b BO |
78 | int cpu; |
79 | ||
80 | for_each_online_cpu(cpu) | |
81 | xen_pmu_finish(cpu); | |
82 | ||
2b953a5e BO |
83 | on_each_cpu(xen_vcpu_notify_suspend, NULL, 1); |
84 | } |