VirtualBox

source: vbox/trunk/include/VBox/hwaccm.h@ 11270

Last change on this file since 11270 was 10822, checked in by vboxsync, 16 years ago

Prepare for EPT.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.7 KB
Line 
1/** @file
2 * HWACCM - Intel/AMD VM Hardware Support Manager
3 */
4
5/*
6 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 *
25 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___VBox_hwaccm_h
31#define ___VBox_hwaccm_h
32
33#include <VBox/cdefs.h>
34#include <VBox/types.h>
35#include <VBox/pgm.h>
36#include <iprt/mp.h>
37
38
39/** @defgroup grp_hwaccm The VM Hardware Manager API
40 * @{
41 */
42
43/**
44 * HWACCM state
45 */
46typedef enum HWACCMSTATE
47{
48 /* Not yet set */
49 HWACCMSTATE_UNINITIALIZED = 0,
50 /* Enabled */
51 HWACCMSTATE_ENABLED,
52 /* Disabled */
53 HWACCMSTATE_DISABLED,
54 /** The usual 32-bit hack. */
55 HWACCMSTATE_32BIT_HACK = 0x7fffffff
56} HWACCMSTATE;
57
58__BEGIN_DECLS
59
60/**
61 * Query HWACCM state (enabled/disabled)
62 *
63 * @returns 0 - disabled, 1 - enabled
64 * @param pVM The VM to operate on.
65 */
66#define HWACCMIsEnabled(a) (a->fHWACCMEnabled)
67
68/**
69 * Invalidates a guest page
70 *
71 * @returns VBox status code.
72 * @param pVM The VM to operate on.
73 * @param GCVirt Page to invalidate
74 */
75HWACCMDECL(int) HWACCMInvalidatePage(PVM pVM, RTGCPTR GCVirt);
76
77#ifndef IN_GC
78/**
79 * Flushes the guest TLB
80 *
81 * @returns VBox status code.
82 * @param pVM The VM to operate on.
83 */
84HWACCMDECL(int) HWACCMFlushTLB(PVM pVM);
85
86/**
87 * Invalidates a guest page by physical address
88 *
89 * NOTE: Assumes the current instruction references this physical page though a virtual address!!
90 *
91 * @returns VBox status code.
92 * @param pVM The VM to operate on.
93 * @param GCPhys Page to invalidate
94 */
95HWACCMDECL(int) HWACCMInvalidatePhysPage(PVM pVM, RTGCPHYS GCPhys);
96
97/**
98 * Checks if nested paging is enabled
99 *
100 * @returns boolean
101 * @param pVM The VM to operate on.
102 */
103HWACCMDECL(bool) HWACCMIsNestedPagingActive(PVM pVM);
104
105/**
106 * Return the shadow paging mode for nested paging/ept
107 *
108 * @returns shadow paging mode
109 * @param pVM The VM to operate on.
110 */
111HWACCMDECL(PGMMODE) HWACCMGetPagingMode(PVM pVM);
112
113#else
114/* Nop in GC */
115#define HWACCMFlushTLB(pVM) do { } while (0)
116#define HWACCMIsNestedPagingActive(pVM) false
117#endif
118
119#ifdef IN_RING0
120/** @defgroup grp_hwaccm_r0 The VM Hardware Manager API
121 * @ingroup grp_hwaccm
122 * @{
123 */
124
125/**
126 * Does global Ring-0 HWACCM initialization.
127 *
128 * @returns VBox status code.
129 */
130HWACCMR0DECL(int) HWACCMR0Init();
131
132/**
133 * Does global Ring-0 HWACCM termination.
134 *
135 * @returns VBox status code.
136 */
137HWACCMR0DECL(int) HWACCMR0Term();
138
139/**
140 * Does Ring-0 per VM HWACCM initialization.
141 *
142 * This is mainly to check that the Host CPU mode is compatible
143 * with VMX or SVM.
144 *
145 * @returns VBox status code.
146 * @param pVM The VM to operate on.
147 */
148HWACCMR0DECL(int) HWACCMR0InitVM(PVM pVM);
149
150/**
151 * Does Ring-0 per VM HWACCM termination.
152 *
153 * @returns VBox status code.
154 * @param pVM The VM to operate on.
155 */
156HWACCMR0DECL(int) HWACCMR0TermVM(PVM pVM);
157
158/**
159 * Sets up HWACCM on all cpus.
160 *
161 * @returns VBox status code.
162 * @param pVM The VM to operate on.
163 * @param enmNewHwAccmState New hwaccm state
164 *
165 */
166HWACCMR0DECL(int) HWACCMR0EnableAllCpus(PVM pVM, HWACCMSTATE enmNewHwAccmState);
167
168/** @} */
169#endif
170
171
172#ifdef IN_RING3
173/** @defgroup grp_hwaccm_r3 The VM Hardware Manager API
174 * @ingroup grp_hwaccm
175 * @{
176 */
177
178/**
179 * Checks if internal events are pending
180 *
181 * @returns boolean
182 * @param pVM The VM to operate on.
183 */
184HWACCMR3DECL(bool) HWACCMR3IsEventPending(PVM pVM);
185
186/**
187 * Initializes the HWACCM.
188 *
189 * @returns VBox status code.
190 * @param pVM The VM to operate on.
191 */
192HWACCMR3DECL(int) HWACCMR3Init(PVM pVM);
193
194/**
195 * Initialize VT-x or AMD-V
196 *
197 * @returns VBox status code.
198 * @param pVM The VM handle.
199 */
200HWACCMR3DECL(int) HWACCMR3InitFinalizeR0(PVM pVM);
201
202/**
203 * Applies relocations to data and code managed by this
204 * component. This function will be called at init and
205 * whenever the VMM need to relocate it self inside the GC.
206 *
207 * The HWACCM will update the addresses used by the switcher.
208 *
209 * @param pVM The VM.
210 */
211HWACCMR3DECL(void) HWACCMR3Relocate(PVM pVM);
212
213/**
214 * Terminates the VMXM.
215 *
216 * Termination means cleaning up and freeing all resources,
217 * the VM it self is at this point powered off or suspended.
218 *
219 * @returns VBox status code.
220 * @param pVM The VM to operate on.
221 */
222HWACCMR3DECL(int) HWACCMR3Term(PVM pVM);
223
224/**
225 * VMXM reset callback.
226 *
227 * @param pVM The VM which is reset.
228 */
229HWACCMR3DECL(void) HWACCMR3Reset(PVM pVM);
230
231
232/**
233 * Checks if we can currently use hardware accelerated raw mode.
234 *
235 * @returns boolean
236 * @param pVM The VM to operate on.
237 * @param pCtx Partial VM execution context
238 */
239HWACCMR3DECL(bool) HWACCMR3CanExecuteGuest(PVM pVM, PCPUMCTX pCtx);
240
241
242/**
243 * Checks if we are currently using hardware accelerated raw mode.
244 *
245 * @returns boolean
246 * @param pVM The VM to operate on.
247 */
248HWACCMR3DECL(bool) HWACCMR3IsActive(PVM pVM);
249
250/**
251 * Checks if we are currently using nested paging.
252 *
253 * @returns boolean
254 * @param pVM The VM to operate on.
255 */
256HWACCMR3DECL(bool) HWACCMR3IsNestedPagingActive(PVM pVM);
257
258/**
259 * Checks hardware accelerated raw mode is allowed.
260 *
261 * @returns boolean
262 * @param pVM The VM to operate on.
263 */
264HWACCMR3DECL(bool) HWACCMR3IsAllowed(PVM pVM);
265
266/**
267 * Notification callback which is called whenever there is a chance that a CR3
268 * value might have changed.
269 * This is called by PGM.
270 *
271 * @param pVM The VM to operate on.
272 * @param enmShadowMode New paging mode.
273 */
274HWACCMR3DECL(void) HWACCMR3PagingModeChanged(PVM pVM, PGMMODE enmShadowMode);
275
276/** @} */
277#endif
278
279#ifdef IN_RING0
280/** @addtogroup grp_hwaccm_r0
281 * @{
282 */
283
284/**
285 * Sets up a VT-x or AMD-V session
286 *
287 * @returns VBox status code.
288 * @param pVM The VM to operate on.
289 */
290HWACCMR0DECL(int) HWACCMR0SetupVM(PVM pVM);
291
292
293/**
294 * Runs guest code in a VMX/SVM VM.
295 *
296 * @returns VBox status code.
297 * @param pVM The VM to operate on.
298 */
299HWACCMR0DECL(int) HWACCMR0RunGuestCode(PVM pVM);
300
301/**
302 * Enters the VT-x or AMD-V session
303 *
304 * @returns VBox status code.
305 * @param pVM The VM to operate on.
306 */
307HWACCMR0DECL(int) HWACCMR0Enter(PVM pVM);
308
309
310/**
311 * Leaves the VT-x or AMD-V session
312 *
313 * @returns VBox status code.
314 * @param pVM The VM to operate on.
315 */
316HWACCMR0DECL(int) HWACCMR0Leave(PVM pVM);
317
318/**
319 * Invalidates a guest page
320 *
321 * @returns VBox status code.
322 * @param pVM The VM to operate on.
323 * @param GCVirt Page to invalidate
324 */
325HWACCMR0DECL(int) HWACCMR0InvalidatePage(PVM pVM, RTGCPTR GCVirt);
326
327/**
328 * Flushes the guest TLB
329 *
330 * @returns VBox status code.
331 * @param pVM The VM to operate on.
332 */
333HWACCMR0DECL(int) HWACCMR0FlushTLB(PVM pVM);
334
335/** @} */
336#endif
337
338
339/** @} */
340__END_DECLS
341
342
343#endif
344
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