summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorEduardo Habkost <ehabkost@redhat.com>2008-11-17 19:03:19 -0200
committerAvi Kivity <avi@redhat.com>2008-12-31 16:52:29 +0200
commit6aa07a0d77f6aafbe69e4e8609ffaf2b7ee1b591 (patch)
tree02b6a3a17840804fd3331e1920cdb671a63f4169 /arch
parent710ff4a855d0f3bf74b5b4a20328e2858a8a2968 (diff)
x86: cpu_emergency_vmxoff() function
Add cpu_emergency_vmxoff() and its friends: cpu_vmx_enabled() and __cpu_emergency_vmxoff(). Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/include/asm/virtext.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/arch/x86/include/asm/virtext.h b/arch/x86/include/asm/virtext.h
index 7dee5b59930e..6bcf0acb4ef1 100644
--- a/arch/x86/include/asm/virtext.h
+++ b/arch/x86/include/asm/virtext.h
@@ -43,4 +43,27 @@ static inline void cpu_vmxoff(void)
write_cr4(read_cr4() & ~X86_CR4_VMXE);
}
+static inline int cpu_vmx_enabled(void)
+{
+ return read_cr4() & X86_CR4_VMXE;
+}
+
+/** Disable VMX if it is enabled on the current CPU
+ *
+ * You shouldn't call this if cpu_has_vmx() returns 0.
+ */
+static inline void __cpu_emergency_vmxoff(void)
+{
+ if (cpu_vmx_enabled())
+ cpu_vmxoff();
+}
+
+/** Disable VMX if it is supported and enabled on the current CPU
+ */
+static inline void cpu_emergency_vmxoff(void)
+{
+ if (cpu_has_vmx())
+ __cpu_emergency_vmxoff();
+}
+
#endif /* _ASM_X86_VIRTEX_H */