x86: cpu_emergency_vmxoff() function
authorEduardo Habkost <ehabkost@redhat.com>
Mon, 17 Nov 2008 21:03:19 +0000 (19:03 -0200)
committerAvi Kivity <avi@redhat.com>
Wed, 31 Dec 2008 14:52:29 +0000 (16:52 +0200)
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>
arch/x86/include/asm/virtext.h

index 7dee5b5..6bcf0ac 100644 (file)
@@ -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 */