1/* 2 * Copyright (c) 2006 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5 * 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. 14 * 15 * Please obtain a copy of the License at 16 * http://www.opensource.apple.com/apsl/ and read it before using this file. 17 * 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. 25 * 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27 */ 28 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 { 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 */ 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 */ 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 */ 56} vmx_specs_t; 57 58typedef 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 */ 61} vmx_cpu_t; 62 63void vmx_init(void); 64void vmx_cpu_init(void); 65void vmx_resume(void); 66void vmx_suspend(void); 67 68#define VMX_BASIC_TRUE_CTLS (1ull << 55) 69#define VMX_TRUE_PROCBASED_SECONDARY_CTLS (1ull << 31) 70#define VMX_PROCBASED_CTLS2_EPT (1ull << 1) 71#define VMX_PROCBASED_CTLS2_UNRESTRICTED (1ull << 7) 72 73#define VMX_CAP(msr, shift, mask) (rdmsr64(msr) & ((mask) << (shift))) 74 75boolean_t vmx_hv_support(void); 76 77/* 78 * __vmxoff -- Leave VMX Operation 79 * 80 */ 81extern int __vmxoff(void); 82 83/* 84 * __vmxon -- Enter VMX Operation 85 * 86 */ 87extern int __vmxon(addr64_t v); 88 89#endif /* _I386_VMX_CPU_H_ */ 90