VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMR0/HWVMXR0.h@ 12227

Last change on this file since 12227 was 10502, checked in by vboxsync, 16 years ago

Take precautions for being rescheduled to a different cpu due to long jumps to ring 3. (affects AMD-V only)

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.3 KB
Line 
1/* $Id: HWVMXR0.h 10502 2008-07-11 09:31:15Z vboxsync $ */
2/** @file
3 * HWACCM VT-x - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22#ifndef ___HWVMXR0_h
23#define ___HWVMXR0_h
24
25#include <VBox/cdefs.h>
26#include <VBox/types.h>
27#include <VBox/em.h>
28#include <VBox/stam.h>
29#include <VBox/dis.h>
30#include <VBox/hwaccm.h>
31#include <VBox/pgm.h>
32#include <VBox/hwacc_vmx.h>
33
34__BEGIN_DECLS
35
36/** @defgroup grp_vmx Internal
37 * @ingroup grp_vmx
38 * @internal
39 * @{
40 */
41
42#ifdef IN_RING0
43
44/**
45 * Enters the VT-x session
46 *
47 * @returns VBox status code.
48 * @param pVM The VM to operate on.
49 * @param pCpu CPU info struct
50 */
51HWACCMR0DECL(int) VMXR0Enter(PVM pVMm, PHWACCM_CPUINFO pCpu);
52
53/**
54 * Leaves the VT-x session
55 *
56 * @returns VBox status code.
57 * @param pVM The VM to operate on.
58 */
59HWACCMR0DECL(int) VMXR0Leave(PVM pVM);
60
61
62/**
63 * Sets up and activates VT-x on the current CPU
64 *
65 * @returns VBox status code.
66 * @param pCpu CPU info struct
67 * @param pVM The VM to operate on.
68 * @param pvPageCpu Pointer to the global cpu page
69 * @param pPageCpuPhys Physical address of the global cpu page
70 */
71HWACCMR0DECL(int) VMXR0EnableCpu(PHWACCM_CPUINFO pCpu, PVM pVM, void *pvPageCpu, RTHCPHYS pPageCpuPhys);
72
73/**
74 * Deactivates VT-x on the current CPU
75 *
76 * @returns VBox status code.
77 * @param pCpu CPU info struct
78 * @param pvPageCpu Pointer to the global cpu page
79 * @param pPageCpuPhys Physical address of the global cpu page
80 */
81HWACCMR0DECL(int) VMXR0DisableCpu(PHWACCM_CPUINFO pCpu, void *pvPageCpu, RTHCPHYS pPageCpuPhys);
82
83/**
84 * Does Ring-0 per VM VT-x init.
85 *
86 * @returns VBox status code.
87 * @param pVM The VM to operate on.
88 */
89HWACCMR0DECL(int) VMXR0InitVM(PVM pVM);
90
91/**
92 * Does Ring-0 per VM VT-x termination.
93 *
94 * @returns VBox status code.
95 * @param pVM The VM to operate on.
96 */
97HWACCMR0DECL(int) VMXR0TermVM(PVM pVM);
98
99/**
100 * Sets up VT-x for the specified VM
101 *
102 * @returns VBox status code.
103 * @param pVM The VM to operate on.
104 */
105HWACCMR0DECL(int) VMXR0SetupVM(PVM pVM);
106
107
108/**
109 * Save the host state
110 *
111 * @returns VBox status code.
112 * @param pVM The VM to operate on.
113 */
114HWACCMR0DECL(int) VMXR0SaveHostState(PVM pVM);
115
116/**
117 * Loads the guest state
118 *
119 * @returns VBox status code.
120 * @param pVM The VM to operate on.
121 * @param pCtx Guest context
122 */
123HWACCMR0DECL(int) VMXR0LoadGuestState(PVM pVM, CPUMCTX *pCtx);
124
125
126/**
127 * Runs guest code in a VT-x VM.
128 *
129 * @note NEVER EVER turn on interrupts here. Due to our illegal entry into the kernel, it might mess things up. (XP kernel traps have been frequently observed)
130 *
131 * @returns VBox status code.
132 * @param pVM The VM to operate on.
133 * @param pCtx Guest context
134 */
135HWACCMR0DECL(int) VMXR0RunGuestCode(PVM pVM, CPUMCTX *pCtx);
136
137
138#define VMX_WRITE_SELREG(REG, reg) \
139 rc = VMXWriteVMCS(VMX_VMCS_GUEST_FIELD_##REG, pCtx->reg); \
140 rc |= VMXWriteVMCS(VMX_VMCS_GUEST_##REG##_LIMIT, pCtx->reg##Hid.u32Limit); \
141 rc |= VMXWriteVMCS(VMX_VMCS_GUEST_##REG##_BASE, pCtx->reg##Hid.u64Base); \
142 if (pCtx->eflags.u32 & X86_EFL_VM) \
143 val = pCtx->reg##Hid.Attr.u; \
144 else \
145 if (pCtx->reg && pCtx->reg##Hid.Attr.n.u1Present == 1) \
146 val = pCtx->reg##Hid.Attr.u | X86_SEL_TYPE_ACCESSED; \
147 else \
148 val = 0x10000; /* Invalid guest state error otherwise. (BIT(16) = Unusable) */ \
149 \
150 rc |= VMXWriteVMCS(VMX_VMCS_GUEST_##REG##_ACCESS_RIGHTS, val);
151
152#define VMX_READ_SELREG(REG, reg) \
153 VMXReadVMCS(VMX_VMCS_GUEST_FIELD_##REG, &val); \
154 pCtx->reg = val; \
155 VMXReadVMCS(VMX_VMCS_GUEST_##REG##_LIMIT, &val); \
156 pCtx->reg##Hid.u32Limit = val; \
157 VMXReadVMCS(VMX_VMCS_GUEST_##REG##_BASE, &val); \
158 pCtx->reg##Hid.u64Base = val; \
159 VMXReadVMCS(VMX_VMCS_GUEST_##REG##_ACCESS_RIGHTS, &val); \
160 pCtx->reg##Hid.Attr.u = val;
161
162#define VMX_LOG_SELREG(REG, szSelReg) \
163 VMXReadVMCS(VMX_VMCS_GUEST_FIELD_##REG, &val); \
164 Log(("%s Selector %x\n", szSelReg, val)); \
165 VMXReadVMCS(VMX_VMCS_GUEST_##REG##_LIMIT, &val); \
166 Log(("%s Limit %x\n", szSelReg, val)); \
167 VMXReadVMCS(VMX_VMCS_GUEST_##REG##_BASE, &val); \
168 Log(("%s Base %RX64\n", szSelReg, val)); \
169 VMXReadVMCS(VMX_VMCS_GUEST_##REG##_ACCESS_RIGHTS, &val); \
170 Log(("%s Attributes %x\n", szSelReg, val));
171
172
173
174/**
175 * Prepares for and executes VMLAUNCH (32 bits guest mode)
176 *
177 * @returns VBox status code
178 * @param fResume vmlauch/vmresume
179 * @param pCtx Guest context
180 */
181DECLASM(int) VMXR0StartVM32(RTHCUINT fResume, PCPUMCTX pCtx);
182
183/**
184 * Prepares for and executes VMLAUNCH (64 bits guest mode)
185 *
186 * @returns VBox status code
187 * @param fResume vmlauch/vmresume
188 * @param pCtx Guest context
189 */
190DECLASM(int) VMXR0StartVM64(RTHCUINT fResume, PCPUMCTX pCtx);
191
192#endif /* IN_RING0 */
193
194/** @} */
195
196__END_DECLS
197
198#endif
199
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette