diff options
| -rw-r--r-- | arch/x86/xen/suspend.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/arch/x86/xen/suspend.c b/arch/x86/xen/suspend.c index d9f96cc5d743..1d83152c761b 100644 --- a/arch/x86/xen/suspend.c +++ b/arch/x86/xen/suspend.c | |||
| @@ -1,12 +1,15 @@ | |||
| 1 | // SPDX-License-Identifier: GPL-2.0 | 1 | // SPDX-License-Identifier: GPL-2.0 |
| 2 | #include <linux/types.h> | 2 | #include <linux/types.h> |
| 3 | #include <linux/tick.h> | 3 | #include <linux/tick.h> |
| 4 | #include <linux/percpu-defs.h> | ||
| 4 | 5 | ||
| 5 | #include <xen/xen.h> | 6 | #include <xen/xen.h> |
| 6 | #include <xen/interface/xen.h> | 7 | #include <xen/interface/xen.h> |
| 7 | #include <xen/grant_table.h> | 8 | #include <xen/grant_table.h> |
| 8 | #include <xen/events.h> | 9 | #include <xen/events.h> |
| 9 | 10 | ||
| 11 | #include <asm/cpufeatures.h> | ||
| 12 | #include <asm/msr-index.h> | ||
| 10 | #include <asm/xen/hypercall.h> | 13 | #include <asm/xen/hypercall.h> |
| 11 | #include <asm/xen/page.h> | 14 | #include <asm/xen/page.h> |
| 12 | #include <asm/fixmap.h> | 15 | #include <asm/fixmap.h> |
| @@ -15,6 +18,8 @@ | |||
| 15 | #include "mmu.h" | 18 | #include "mmu.h" |
| 16 | #include "pmu.h" | 19 | #include "pmu.h" |
| 17 | 20 | ||
| 21 | static DEFINE_PER_CPU(u64, spec_ctrl); | ||
| 22 | |||
| 18 | void xen_arch_pre_suspend(void) | 23 | void xen_arch_pre_suspend(void) |
| 19 | { | 24 | { |
| 20 | xen_save_time_memory_area(); | 25 | xen_save_time_memory_area(); |
| @@ -35,6 +40,9 @@ void xen_arch_post_suspend(int cancelled) | |||
| 35 | 40 | ||
| 36 | static void xen_vcpu_notify_restore(void *data) | 41 | static void xen_vcpu_notify_restore(void *data) |
| 37 | { | 42 | { |
| 43 | if (xen_pv_domain() && boot_cpu_has(X86_FEATURE_SPEC_CTRL)) | ||
| 44 | wrmsrl(MSR_IA32_SPEC_CTRL, this_cpu_read(spec_ctrl)); | ||
| 45 | |||
| 38 | /* Boot processor notified via generic timekeeping_resume() */ | 46 | /* Boot processor notified via generic timekeeping_resume() */ |
| 39 | if (smp_processor_id() == 0) | 47 | if (smp_processor_id() == 0) |
| 40 | return; | 48 | return; |
| @@ -44,7 +52,15 @@ static void xen_vcpu_notify_restore(void *data) | |||
| 44 | 52 | ||
| 45 | static void xen_vcpu_notify_suspend(void *data) | 53 | static void xen_vcpu_notify_suspend(void *data) |
| 46 | { | 54 | { |
| 55 | u64 tmp; | ||
| 56 | |||
| 47 | tick_suspend_local(); | 57 | tick_suspend_local(); |
| 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 | } | ||
| 48 | } | 64 | } |
| 49 | 65 | ||
| 50 | void xen_arch_resume(void) | 66 | void xen_arch_resume(void) |
