VirtualBox

source: vbox/trunk/include/VBox/vmm/hm.h@ 45749

Last change on this file since 45749 was 45749, checked in by vboxsync, 12 years ago

VMM: Introduced VMCPUSTATE_STARTED_HM for indicating that we're between HMR3Enter and HMR3Leave. Added HMIsInHwVirtCtx and VMMIsLongJumpArmed methods/macros.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 KB
Line 
1/** @file
2 * HM - Intel/AMD VM Hardware Assisted Virtualization Manager (VMM)
3 */
4
5/*
6 * Copyright (C) 2006-2013 Oracle Corporation
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
26#ifndef ___VBox_vmm_hm_h
27#define ___VBox_vmm_hm_h
28
29#include <VBox/vmm/pgm.h>
30#include <VBox/vmm/cpum.h>
31#include <VBox/vmm/vmm.h>
32#include <iprt/mp.h>
33
34
35/** @defgroup grp_hm The VM Hardware Manager API
36 * @{
37 */
38
39RT_C_DECLS_BEGIN
40
41/**
42 * Checks whether HM (VT-x/AMD-V) is being used by this VM.
43 *
44 * @retval @c true if used.
45 * @retval @c false if software virtualization (raw-mode) is used.
46 *
47 * @param a_pVM The cross context VM structure.
48 * @sa HMIsEnabledNotMacro, HMR3IsEnabled
49 * @internal
50 */
51#if defined(VBOX_STRICT) && defined(IN_RING3)
52# define HMIsEnabled(a_pVM) HMIsEnabledNotMacro(a_pVM)
53#else
54# define HMIsEnabled(a_pVM) ((a_pVM)->fHMEnabled)
55#endif
56
57/**
58 * Checks whether raw-mode context is required for any purpose.
59 *
60 * @retval @c true if required either by raw-mode itself or by HM for doing
61 * switching the cpu to 64-bit mode.
62 * @retval @c false if not required.
63 *
64 * @param a_pVM The cross context VM structure.
65 * @internal
66 */
67#if HC_ARCH_BITS == 64
68# define HMIsRawModeCtxNeeded(a_pVM) (!HMIsEnabled(a_pVM))
69#else
70# define HMIsRawModeCtxNeeded(a_pVM) (!HMIsEnabled(a_pVM) || (a_pVM)->fHMNeedRawModeCtx)
71#endif
72
73 /**
74 * Check if the current CPU state is valid for emulating IO blocks in the recompiler
75 *
76 * @returns boolean
77 * @param a_pVCpu Pointer to the shared virtual CPU structure.
78 * @internal
79 */
80#define HMCanEmulateIoBlock(a_pVCpu) (!CPUMIsGuestInPagedProtectedMode(a_pVCpu))
81
82 /**
83 * Check if the current CPU state is valid for emulating IO blocks in the recompiler
84 *
85 * @returns boolean
86 * @param a_pCtx Pointer to the CPU context (within PVM).
87 * @internal
88 */
89#define HMCanEmulateIoBlockEx(a_pCtx) (!CPUMIsGuestInPagedProtectedModeEx(a_pCtx))
90
91/**
92 * Checks whether we're in the special hardware virtualization context.
93 * @returns true / false.
94 * @param a_pVCpu The caller's cross context virtual CPU structure.
95 * @thread EMT
96 */
97#ifdef IN_RING0
98# define HMIsInHwVirtCtx(a_pVCpu) (VMCPU_GET_STATE(a_pVCpu) == VMCPUSTATE_STARTED_HM)
99#else
100# define HMIsInHwVirtCtx(a_pVCpu) (false)
101#endif
102
103
104VMMDECL(bool) HMIsEnabledNotMacro(PVM pVM);
105VMM_INT_DECL(int) HMInvalidatePage(PVMCPU pVCpu, RTGCPTR GCVirt);
106VMM_INT_DECL(bool) HMHasPendingIrq(PVM pVM);
107VMM_INT_DECL(PX86PDPE) HMGetPaePdpes(PVMCPU pVCpu);
108
109#ifndef IN_RC
110VMM_INT_DECL(int) HMFlushTLB(PVMCPU pVCpu);
111VMM_INT_DECL(int) HMFlushTLBOnAllVCpus(PVM pVM);
112VMM_INT_DECL(int) HMInvalidatePageOnAllVCpus(PVM pVM, RTGCPTR GCVirt);
113VMM_INT_DECL(int) HMInvalidatePhysPage(PVM pVM, RTGCPHYS GCPhys);
114VMM_INT_DECL(bool) HMIsNestedPagingActive(PVM pVM);
115VMM_INT_DECL(PGMMODE) HMGetShwPagingMode(PVM pVM);
116#else /* Nops in RC: */
117# define HMFlushTLB(pVCpu) do { } while (0)
118# define HMIsNestedPagingActive(pVM) false
119# define HMFlushTLBOnAllVCpus(pVM) do { } while (0)
120#endif
121
122#ifdef IN_RING0
123/** @defgroup grp_hm_r0 The VM Hardware Manager API
124 * @ingroup grp_hm
125 * @{
126 */
127VMMR0_INT_DECL(int) HMR0Init(void);
128VMMR0_INT_DECL(int) HMR0Term(void);
129VMMR0_INT_DECL(int) HMR0InitVM(PVM pVM);
130VMMR0_INT_DECL(int) HMR0TermVM(PVM pVM);
131VMMR0_INT_DECL(int) HMR0EnableAllCpus(PVM pVM);
132VMMR0_INT_DECL(int) HMR0EnterSwitcher(PVM pVM, VMMSWITCHER enmSwitcher, bool *pfVTxDisabled);
133VMMR0_INT_DECL(void) HMR0LeaveSwitcher(PVM pVM, bool fVTxDisabled);
134
135VMMR0_INT_DECL(void) HMR0SavePendingIOPortWrite(PVMCPU pVCpu, RTGCPTR GCPtrRip, RTGCPTR GCPtrRipNext,
136 unsigned uPort, unsigned uAndVal, unsigned cbSize);
137VMMR0_INT_DECL(void) HMR0SavePendingIOPortRead(PVMCPU pVCpu, RTGCPTR GCPtrRip, RTGCPTR GCPtrRipNext,
138 unsigned uPort, unsigned uAndVal, unsigned cbSize);
139
140/** @} */
141#endif /* IN_RING0 */
142
143
144#ifdef IN_RING3
145/** @defgroup grp_hm_r3 The VM Hardware Manager API
146 * @ingroup grp_hm
147 * @{
148 */
149VMMR3DECL(bool) HMR3IsEnabled(PUVM pUVM);
150VMMR3DECL(bool) HMR3IsNestedPagingActive(PUVM pUVM);
151VMMR3DECL(bool) HMR3IsVpidActive(PUVM pVUM);
152
153VMMR3_INT_DECL(bool) HMR3IsEventPending(PVMCPU pVCpu);
154VMMR3_INT_DECL(int) HMR3Init(PVM pVM);
155VMMR3_INT_DECL(int) HMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
156VMMR3_INT_DECL(void) HMR3Relocate(PVM pVM);
157VMMR3_INT_DECL(int) HMR3Term(PVM pVM);
158VMMR3_INT_DECL(void) HMR3Reset(PVM pVM);
159VMMR3_INT_DECL(void) HMR3ResetCpu(PVMCPU pVCpu);
160VMMR3_INT_DECL(void) HMR3CheckError(PVM pVM, int iStatusCode);
161VMMR3DECL(bool) HMR3CanExecuteGuest(PVM pVM, PCPUMCTX pCtx);
162VMMR3_INT_DECL(void) HMR3NotifyScheduled(PVMCPU pVCpu);
163VMMR3_INT_DECL(void) HMR3NotifyEmulated(PVMCPU pVCpu);
164VMMR3_INT_DECL(bool) HMR3IsActive(PVMCPU pVCpu);
165VMMR3_INT_DECL(void) HMR3PagingModeChanged(PVM pVM, PVMCPU pVCpu, PGMMODE enmShadowMode, PGMMODE enmGuestMode);
166VMMR3_INT_DECL(int) HMR3EmulateIoBlock(PVM pVM, PCPUMCTX pCtx);
167VMMR3_INT_DECL(VBOXSTRICTRC) HMR3RestartPendingIOInstr(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
168VMMR3_INT_DECL(int) HMR3EnablePatching(PVM pVM, RTGCPTR pPatchMem, unsigned cbPatchMem);
169VMMR3_INT_DECL(int) HMR3DisablePatching(PVM pVM, RTGCPTR pPatchMem, unsigned cbPatchMem);
170VMMR3_INT_DECL(int) HMR3PatchTprInstr(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
171VMMR3_INT_DECL(bool) HMR3IsRescheduleRequired(PVM pVM, PCPUMCTX pCtx);
172VMMR3_INT_DECL(bool) HMR3IsVmxPreemptionTimerUsed(PVM pVM);
173
174/** @} */
175#endif /* IN_RING3 */
176
177#ifdef IN_RING0
178/** @addtogroup grp_hm_r0
179 * @{
180 */
181VMMR0_INT_DECL(int) HMR0SetupVM(PVM pVM);
182VMMR0_INT_DECL(int) HMR0RunGuestCode(PVM pVM, PVMCPU pVCpu);
183VMMR0_INT_DECL(int) HMR0Enter(PVM pVM, PVMCPU pVCpu);
184VMMR0_INT_DECL(int) HMR0Leave(PVM pVM, PVMCPU pVCpu);
185VMMR0_INT_DECL(bool) HMR0SuspendPending(void);
186
187# if HC_ARCH_BITS == 32 && defined(VBOX_WITH_64_BITS_GUESTS)
188VMMR0_INT_DECL(int) HMR0SaveFPUState(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
189VMMR0_INT_DECL(int) HMR0SaveDebugState(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
190VMMR0_INT_DECL(int) HMR0TestSwitcher3264(PVM pVM);
191# endif
192
193/** @} */
194#endif /* IN_RING0 */
195
196
197/** @} */
198RT_C_DECLS_END
199
200
201#endif
202
Note: See TracBrowser for help on using the repository browser.

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