VirtualBox

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

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

Nested paging updates. Extra paging mode added to prevent illegal changes to the shadow page table.

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