Skip to content

Commit

Permalink
x86: cpu_emergency_vmxoff() function
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Eduardo Habkost authored and Avi Kivity committed Dec 31, 2008
1 parent 710ff4a commit 6aa07a0
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions arch/x86/include/asm/virtext.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

0 comments on commit 6aa07a0

Please sign in to comment.