]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/i386/vmx/vmx_asm.h
xnu-3789.70.16.tar.gz
[apple/xnu.git] / osfmk / i386 / vmx / vmx_asm.h
index bd0de468858bbdfc4fe02be103584ca5500bbf7c..51a18b29dcd7454005dd8b3b1550cb15403ca2ec 100644 (file)
  
 #ifndef _I386_VMX_ASM_H_
 #define _I386_VMX_ASM_H_
-#include <mach/machine/vm_types.h>
-#include <mach/boolean.h>
-#include <kern/assert.h>
-#include <i386/eflags.h>
-#include <i386/seg.h>
 
 #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)
  *