X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/b0d623f7f2ae71ed96e60569f61f9a9a27016e80..4d15aeb193b2c68f1d38666c317f8d3734f5f083:/osfmk/i386/vmx/vmx_asm.h diff --git a/osfmk/i386/vmx/vmx_asm.h b/osfmk/i386/vmx/vmx_asm.h index bd0de4688..51a18b29d 100644 --- a/osfmk/i386/vmx/vmx_asm.h +++ b/osfmk/i386/vmx/vmx_asm.h @@ -28,111 +28,11 @@ #ifndef _I386_VMX_ASM_H_ #define _I386_VMX_ASM_H_ - -#include -#include -#include -#include -#include #define VMX_FAIL_INVALID -1 #define VMX_FAIL_VALID -2 #define VMX_SUCCEED 0 -static inline void enter_64bit_mode(void) { - __asm__ __volatile__ ( - ".byte 0xea /* far jump longmode */ \n\t" - ".long 1f \n\t" - ".word %P0 \n\t" - ".code64 \n\t" - "1:" - :: "i" (KERNEL64_CS) - ); -} -static inline void enter_compat_mode(void) { - asm( - "ljmp *4f \n\t" - "4: \n\t" - ".long 5f \n\t" - ".word %P0 \n\t" - ".code32 \n\t" - "5:" - :: "i" (KERNEL32_CS) - ); -} - -#define __VMXOFF(res) \ - __asm__ __volatile__ ( \ - "vmxoff \n\t" \ - "cmovcl %2, %0 \n\t" /* CF = 1, ZF = 0 */ \ - "cmovzl %3, %0" /* CF = 0, ZF = 1 */ \ - : "=&r" (res) \ - : "0" (VMX_SUCCEED), \ - "r" (VMX_FAIL_INVALID), \ - "r" (VMX_FAIL_VALID) \ - : "memory", "cc" \ - ) - -#define __VMXON(addr, res) \ - __asm__ __volatile__ ( \ - "vmxon %4 \n\t" \ - "cmovcl %2, %0 \n\t" /* CF = 1, ZF = 0 */ \ - "cmovzl %3, %0" /* CF = 0, ZF = 1 */ \ - : "=&r" (res) \ - : "0" (VMX_SUCCEED), \ - "r" (VMX_FAIL_INVALID), \ - "r" (VMX_FAIL_VALID), \ - "m" (*addr) \ - : "memory", "cc" \ - ); - - -/* - * __vmxoff -- Leave VMX Operation - * - */ -static inline int -__vmxoff(void) -{ - int result; -#if defined (__x86_64__) - __VMXOFF(result); -#else - if (ml_is64bit()) { - /* don't put anything between these lines! */ - enter_64bit_mode(); - __VMXOFF(result); - enter_compat_mode(); - } else { - __VMXOFF(result); - } -#endif - return result; -} - -/* - * __vmxon -- Enter VMX Operation - * - */ - static inline int -__vmxon(addr64_t *v) - { - int result; -#if defined (__x86_64__) - __VMXON(v, result); -#else - if (ml_is64bit()) { - /* don't put anything between these lines! */ - enter_64bit_mode(); - __VMXON(v, result); - enter_compat_mode(); - } else { - __VMXON(v, result); - } -#endif - return result; -} - /* * VMX Capability Registers (VCR) *