diff options
author | Juergen Gross <jgross@suse.com> | 2018-02-26 09:08:18 -0500 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2018-02-28 10:03:19 -0500 |
commit | 71c208dd54ab971036d83ff6d9837bae4976e623 (patch) | |
tree | fb1583ab8e295eb344a60c17daf51a397dff9c63 | |
parent | 946fbbc13dce68902f64515b610eeb2a6c3d7a64 (diff) |
x86/xen: Zero MSR_IA32_SPEC_CTRL before suspend
Older Xen versions (4.5 and before) might have problems migrating pv
guests with MSR_IA32_SPEC_CTRL having a non-zero value. So before
suspending zero that MSR and restore it after being resumed.
Signed-off-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
Cc: stable@vger.kernel.org
Cc: xen-devel@lists.xenproject.org
Cc: boris.ostrovsky@oracle.com
Link: https://lkml.kernel.org/r/20180226140818.4849-1-jgross@suse.com
-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) |