]> git.saurik.com Git - apple/xnu.git/blame - osfmk/i386/vmx/vmx_cpu.h
xnu-7195.101.1.tar.gz
[apple/xnu.git] / osfmk / i386 / vmx / vmx_cpu.h
CommitLineData
2d21ac55
A
1/*
2 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
0a7de745 5 *
2d21ac55
A
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.
0a7de745 14 *
2d21ac55
A
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
0a7de745 17 *
2d21ac55
A
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.
0a7de745 25 *
2d21ac55
A
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
0a7de745 28
2d21ac55
A
29#ifndef _I386_VMX_CPU_H_
30#define _I386_VMX_CPU_H_
31
32#include <mach/machine/vm_types.h>
33#include <mach/boolean.h>
34#include <i386/vmx/vmx_asm.h>
35
36/*
37 * Physical CPU's VMX specifications
38 *
39 */
40typedef struct vmx_specs {
0a7de745
A
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 */
2d21ac55
A
45 /*
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.
50 */
0a7de745
A
51 uint32_t cr0_fixed_0; /* allowed 0-settings for CR0 */
52 uint32_t cr0_fixed_1; /* allowed 1-settings for CR0 */
53
54 uint32_t cr4_fixed_0; /* allowed 0-settings for CR4 */
55 uint32_t cr4_fixed_1; /* allowed 1-settings for CR4 */
2d21ac55
A
56} vmx_specs_t;
57
58typedef struct vmx_cpu {
0a7de745
A
59 vmx_specs_t specs; /* this phys CPU's VMX specifications */
60 void *vmxon_region; /* the logical address of the VMXON region page */
2d21ac55
A
61} vmx_cpu_t;
62
fe8ab488 63void vmx_cpu_init(void);
490019cf 64void vmx_resume(boolean_t is_wake_from_hibernate);
2d21ac55
A
65void vmx_suspend(void);
66
0a7de745
A
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)
fe8ab488
A
71
72#define VMX_CAP(msr, shift, mask) (rdmsr64(msr) & ((mask) << (shift)))
73
74boolean_t vmx_hv_support(void);
75
316670eb
A
76/*
77 * __vmxoff -- Leave VMX Operation
78 *
79 */
80extern int __vmxoff(void);
81
82/*
83 * __vmxon -- Enter VMX Operation
84 *
85 */
86extern int __vmxon(addr64_t v);
87
0a7de745 88#endif /* _I386_VMX_CPU_H_ */