aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/include/asm/virtext.h14
-rw-r--r--arch/x86/kvm/svm.c6
2 files changed, 15 insertions, 5 deletions
diff --git a/arch/x86/include/asm/virtext.h b/arch/x86/include/asm/virtext.h
index 6f0d409c3682..2cfe363729c3 100644
--- a/arch/x86/include/asm/virtext.h
+++ b/arch/x86/include/asm/virtext.h
@@ -107,4 +107,18 @@ static inline int cpu_has_svm(const char **msg)
107 return 1; 107 return 1;
108} 108}
109 109
110
111/** Disable SVM on the current CPU
112 *
113 * You should call this only if cpu_has_svm() returned true.
114 */
115static inline void cpu_svm_disable(void)
116{
117 uint64_t efer;
118
119 wrmsrl(MSR_VM_HSAVE_PA, 0);
120 rdmsrl(MSR_EFER, efer);
121 wrmsrl(MSR_EFER, efer & ~MSR_EFER_SVME_MASK);
122}
123
110#endif /* _ASM_X86_VIRTEX_H */ 124#endif /* _ASM_X86_VIRTEX_H */
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 0667c6d13d30..1452851ae258 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -259,11 +259,7 @@ static int has_svm(void)
259 259
260static void svm_hardware_disable(void *garbage) 260static void svm_hardware_disable(void *garbage)
261{ 261{
262 uint64_t efer; 262 cpu_svm_disable();
263
264 wrmsrl(MSR_VM_HSAVE_PA, 0);
265 rdmsrl(MSR_EFER, efer);
266 wrmsrl(MSR_EFER, efer & ~MSR_EFER_SVME_MASK);
267} 263}
268 264
269static void svm_hardware_enable(void *garbage) 265static void svm_hardware_enable(void *garbage)