2 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
29 #ifndef _I386_VMX_CPU_H_
30 #define _I386_VMX_CPU_H_
32 #include <mach/machine/vm_types.h>
33 #include <mach/boolean.h>
34 #include <i386/vmx/vmx_asm.h>
37 * Physical CPU's VMX specifications
40 typedef struct vmx_specs
{
41 boolean_t initialized
; /* the specs have already been read */
42 boolean_t vmx_present
; /* VMX feature available and enabled */
43 boolean_t vmx_on
; /* VMX is active */
44 uint32_t vmcs_id
; /* VMCS revision identifier */
46 * Fixed control register bits are specified by a pair of
47 * bitfields: 0-settings contain 0 bits corresponding to
48 * CR bits that may be 0; 1-settings contain 1 bits
49 * corresponding to CR bits that may be 1.
51 uint32_t cr0_fixed_0
; /* allowed 0-settings for CR0 */
52 uint32_t cr0_fixed_1
; /* allowed 1-settings for CR0 */
54 uint32_t cr4_fixed_0
; /* allowed 0-settings for CR4 */
55 uint32_t cr4_fixed_1
; /* allowed 1-settings for CR4 */
58 typedef struct vmx_cpu
{
59 vmx_specs_t specs
; /* this phys CPU's VMX specifications */
60 void *vmxon_region
; /* the logical address of the VMXON region page */
63 void vmx_cpu_init(void);
64 void vmx_resume(boolean_t is_wake_from_hibernate
);
65 void vmx_suspend(void);
67 #define VMX_BASIC_TRUE_CTLS (1ull << 55)
68 #define VMX_TRUE_PROCBASED_SECONDARY_CTLS (1ull << 31)
69 #define VMX_PROCBASED_CTLS2_EPT (1ull << 1)
70 #define VMX_PROCBASED_CTLS2_UNRESTRICTED (1ull << 7)
72 #define VMX_CAP(msr, shift, mask) (rdmsr64(msr) & ((mask) << (shift)))
74 boolean_t
vmx_hv_support(void);
77 * __vmxoff -- Leave VMX Operation
80 extern int __vmxoff(void);
83 * __vmxon -- Enter VMX Operation
86 extern int __vmxon(addr64_t v
);
88 #endif /* _I386_VMX_CPU_H_ */