VirtualBox

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

Last change on this file since 10518 was 9115, checked in by vboxsync, 17 years ago

HWACCM: Invalidate pages changed by PGMHandlerPhysicalPageTempOff.
Note that PGMHandlerPhysicalPageReset will trigger a TLB flush.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.3 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#else
106/* Nop in GC */
107#define HWACCMFlushTLB(pVM) do { } while (0)
108#define HWACCMIsNestedPagingActive(pVM) false
109#endif
110
111#ifdef IN_RING0
112/** @defgroup grp_hwaccm_r0 The VM Hardware Manager API
113 * @ingroup grp_hwaccm
114 * @{
115 */
116
117/**
118 * Does global Ring-0 HWACCM initialization.
119 *
120 * @returns VBox status code.
121 */
122HWACCMR0DECL(int) HWACCMR0Init();
123
124/**
125 * Does global Ring-0 HWACCM termination.
126 *
127 * @returns VBox status code.
128 */
129HWACCMR0DECL(int) HWACCMR0Term();
130
131/**
132 * Does Ring-0 per VM HWACCM initialization.
133 *
134 * This is mainly to check that the Host CPU mode is compatible
135 * with VMX or SVM.
136 *
137 * @returns VBox status code.
138 * @param pVM The VM to operate on.
139 */
140HWACCMR0DECL(int) HWACCMR0InitVM(PVM pVM);
141
142/**
143 * Does Ring-0 per VM HWACCM termination.
144 *
145 * @returns VBox status code.
146 * @param pVM The VM to operate on.
147 */
148HWACCMR0DECL(int) HWACCMR0TermVM(PVM pVM);
149
150/**
151 * Sets up HWACCM on all cpus.
152 *
153 * @returns VBox status code.
154 * @param pVM The VM to operate on.
155 * @param enmNewHwAccmState New hwaccm state
156 *
157 */
158HWACCMR0DECL(int) HWACCMR0EnableAllCpus(PVM pVM, HWACCMSTATE enmNewHwAccmState);
159
160/** @} */
161#endif
162
163
164#ifdef IN_RING3
165/** @defgroup grp_hwaccm_r3 The VM Hardware Manager API
166 * @ingroup grp_hwaccm
167 * @{
168 */
169
170/**
171 * Checks if internal events are pending
172 *
173 * @returns boolean
174 * @param pVM The VM to operate on.
175 */
176HWACCMR3DECL(bool) HWACCMR3IsEventPending(PVM pVM);
177
178/**
179 * Initializes the HWACCM.
180 *
181 * @returns VBox status code.
182 * @param pVM The VM to operate on.
183 */
184HWACCMR3DECL(int) HWACCMR3Init(PVM pVM);
185
186/**
187 * Initialize VT-x or AMD-V
188 *
189 * @returns VBox status code.
190 * @param pVM The VM handle.
191 */
192HWACCMR3DECL(int) HWACCMR3InitFinalizeR0(PVM pVM);
193
194/**
195 * Applies relocations to data and code managed by this
196 * component. This function will be called at init and
197 * whenever the VMM need to relocate it self inside the GC.
198 *
199 * The HWACCM will update the addresses used by the switcher.
200 *
201 * @param pVM The VM.
202 */
203HWACCMR3DECL(void) HWACCMR3Relocate(PVM pVM);
204
205/**
206 * Terminates the VMXM.
207 *
208 * Termination means cleaning up and freeing all resources,
209 * the VM it self is at this point powered off or suspended.
210 *
211 * @returns VBox status code.
212 * @param pVM The VM to operate on.
213 */
214HWACCMR3DECL(int) HWACCMR3Term(PVM pVM);
215
216/**
217 * VMXM reset callback.
218 *
219 * @param pVM The VM which is reset.
220 */
221HWACCMR3DECL(void) HWACCMR3Reset(PVM pVM);
222
223
224/**
225 * Checks if we can currently use hardware accelerated raw mode.
226 *
227 * @returns boolean
228 * @param pVM The VM to operate on.
229 * @param pCtx Partial VM execution context
230 */
231HWACCMR3DECL(bool) HWACCMR3CanExecuteGuest(PVM pVM, PCPUMCTX pCtx);
232
233
234/**
235 * Checks if we are currently using hardware accelerated raw mode.
236 *
237 * @returns boolean
238 * @param pVM The VM to operate on.
239 */
240HWACCMR3DECL(bool) HWACCMR3IsActive(PVM pVM);
241
242/**
243 * Checks hardware accelerated raw mode is allowed.
244 *
245 * @returns boolean
246 * @param pVM The VM to operate on.
247 */
248HWACCMR3DECL(bool) HWACCMR3IsAllowed(PVM pVM);
249
250/**
251 * Notification callback which is called whenever there is a chance that a CR3
252 * value might have changed.
253 * This is called by PGM.
254 *
255 * @param pVM The VM to operate on.
256 * @param enmShadowMode New paging mode.
257 */
258HWACCMR3DECL(void) HWACCMR3PagingModeChanged(PVM pVM, PGMMODE enmShadowMode);
259
260/** @} */
261#endif
262
263#ifdef IN_RING0
264/** @addtogroup grp_hwaccm_r0
265 * @{
266 */
267
268/**
269 * Sets up a VT-x or AMD-V session
270 *
271 * @returns VBox status code.
272 * @param pVM The VM to operate on.
273 */
274HWACCMR0DECL(int) HWACCMR0SetupVM(PVM pVM);
275
276
277/**
278 * Runs guest code in a VMX/SVM VM.
279 *
280 * @returns VBox status code.
281 * @param pVM The VM to operate on.
282 */
283HWACCMR0DECL(int) HWACCMR0RunGuestCode(PVM pVM);
284
285/**
286 * Enters the VT-x or AMD-V session
287 *
288 * @returns VBox status code.
289 * @param pVM The VM to operate on.
290 */
291HWACCMR0DECL(int) HWACCMR0Enter(PVM pVM);
292
293
294/**
295 * Leaves the VT-x or AMD-V session
296 *
297 * @returns VBox status code.
298 * @param pVM The VM to operate on.
299 */
300HWACCMR0DECL(int) HWACCMR0Leave(PVM pVM);
301
302/**
303 * Invalidates a guest page
304 *
305 * @returns VBox status code.
306 * @param pVM The VM to operate on.
307 * @param GCVirt Page to invalidate
308 */
309HWACCMR0DECL(int) HWACCMR0InvalidatePage(PVM pVM, RTGCPTR GCVirt);
310
311/**
312 * Flushes the guest TLB
313 *
314 * @returns VBox status code.
315 * @param pVM The VM to operate on.
316 */
317HWACCMR0DECL(int) HWACCMR0FlushTLB(PVM pVM);
318
319/** @} */
320#endif
321
322
323/** @} */
324__END_DECLS
325
326
327#endif
328
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