1 | /** @file
|
---|
2 | * HM - Intel/AMD VM Hardware Support Manager (VMM)
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2010 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 |
|
---|
39 | RT_C_DECLS_BEGIN
|
---|
40 |
|
---|
41 | /**
|
---|
42 | * Query HM state (enabled/disabled)
|
---|
43 | *
|
---|
44 | * @returns 0 - disabled, 1 - enabled
|
---|
45 | * @param pVM The VM to operate on.
|
---|
46 | */
|
---|
47 | #define HMIsEnabled(pVM) ((pVM)->fHMEnabled)
|
---|
48 |
|
---|
49 | /**
|
---|
50 | * Check if the current CPU state is valid for emulating IO blocks in the recompiler
|
---|
51 | *
|
---|
52 | * @returns boolean
|
---|
53 | * @param pCtx CPU context
|
---|
54 | */
|
---|
55 | #define HMCanEmulateIoBlock(pVCpu) (!CPUMIsGuestInPagedProtectedMode(pVCpu))
|
---|
56 | #define HMCanEmulateIoBlockEx(pCtx) (!CPUMIsGuestInPagedProtectedModeEx(pCtx))
|
---|
57 |
|
---|
58 | VMMDECL(int) HMInvalidatePage(PVMCPU pVCpu, RTGCPTR GCVirt);
|
---|
59 | VMMDECL(bool) HMHasPendingIrq(PVM pVM);
|
---|
60 |
|
---|
61 | #ifndef IN_RC
|
---|
62 | VMMDECL(int) HMFlushTLB(PVMCPU pVCpu);
|
---|
63 | VMMDECL(int) HMFlushTLBOnAllVCpus(PVM pVM);
|
---|
64 | VMMDECL(int) HMInvalidatePageOnAllVCpus(PVM pVM, RTGCPTR GCVirt);
|
---|
65 | VMMDECL(int) HMInvalidatePhysPage(PVM pVM, RTGCPHYS GCPhys);
|
---|
66 | VMMDECL(bool) HMIsNestedPagingActive(PVM pVM);
|
---|
67 | VMMDECL(PGMMODE) HMGetShwPagingMode(PVM pVM);
|
---|
68 | #else
|
---|
69 | /* Nop in GC */
|
---|
70 | # define HMFlushTLB(pVCpu) do { } while (0)
|
---|
71 | # define HMIsNestedPagingActive(pVM) false
|
---|
72 | # define HMFlushTLBOnAllVCpus(pVM) do { } while (0)
|
---|
73 | #endif
|
---|
74 |
|
---|
75 | #ifdef IN_RING0
|
---|
76 | /** @defgroup grp_hm_r0 The VM Hardware Manager API
|
---|
77 | * @ingroup grp_hm
|
---|
78 | * @{
|
---|
79 | */
|
---|
80 | VMMR0DECL(int) HMR0Init(void);
|
---|
81 | VMMR0DECL(int) HMR0Term(void);
|
---|
82 | VMMR0DECL(int) HMR0InitVM(PVM pVM);
|
---|
83 | VMMR0DECL(int) HMR0TermVM(PVM pVM);
|
---|
84 | VMMR0DECL(int) HMR0EnableAllCpus(PVM pVM);
|
---|
85 | VMMR0DECL(int) HMR0EnterSwitcher(PVM pVM, VMMSWITCHER enmSwitcher, bool *pfVTxDisabled);
|
---|
86 | VMMR0DECL(void) HMR0LeaveSwitcher(PVM pVM, bool fVTxDisabled);
|
---|
87 |
|
---|
88 | VMMR0DECL(void) HMR0SavePendingIOPortWrite(PVMCPU pVCpu, RTGCPTR GCPtrRip, RTGCPTR GCPtrRipNext, unsigned uPort, unsigned uAndVal, unsigned cbSize);
|
---|
89 | VMMR0DECL(void) HMR0SavePendingIOPortRead(PVMCPU pVCpu, RTGCPTR GCPtrRip, RTGCPTR GCPtrRipNext, unsigned uPort, unsigned uAndVal, unsigned cbSize);
|
---|
90 |
|
---|
91 | /** @} */
|
---|
92 | #endif /* IN_RING0 */
|
---|
93 |
|
---|
94 |
|
---|
95 | #ifdef IN_RING3
|
---|
96 | /** @defgroup grp_hm_r3 The VM Hardware Manager API
|
---|
97 | * @ingroup grp_hm
|
---|
98 | * @{
|
---|
99 | */
|
---|
100 | VMMR3DECL(bool) HMR3IsEventPending(PVMCPU pVCpu);
|
---|
101 | VMMR3DECL(int) HMR3Init(PVM pVM);
|
---|
102 | VMMR3_INT_DECL(int) HMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
|
---|
103 | VMMR3DECL(void) HMR3Relocate(PVM pVM);
|
---|
104 | VMMR3DECL(int) HMR3Term(PVM pVM);
|
---|
105 | VMMR3DECL(void) HMR3Reset(PVM pVM);
|
---|
106 | VMMR3DECL(void) HMR3ResetCpu(PVMCPU pVCpu);
|
---|
107 | VMMR3DECL(void) HMR3CheckError(PVM pVM, int iStatusCode);
|
---|
108 | VMMR3DECL(bool) HMR3CanExecuteGuest(PVM pVM, PCPUMCTX pCtx);
|
---|
109 | VMMR3DECL(void) HMR3NotifyScheduled(PVMCPU pVCpu);
|
---|
110 | VMMR3DECL(void) HMR3NotifyEmulated(PVMCPU pVCpu);
|
---|
111 | VMMR3DECL(bool) HMR3IsActive(PVMCPU pVCpu);
|
---|
112 | VMMR3DECL(bool) HMR3IsNestedPagingActive(PVM pVM);
|
---|
113 | VMMR3DECL(bool) HMR3IsAllowed(PVM pVM);
|
---|
114 | VMMR3DECL(void) HMR3PagingModeChanged(PVM pVM, PVMCPU pVCpu, PGMMODE enmShadowMode, PGMMODE enmGuestMode);
|
---|
115 | VMMR3DECL(bool) HMR3IsVPIDActive(PVM pVM);
|
---|
116 | VMMR3DECL(int) HMR3InjectNMI(PVM pVM);
|
---|
117 | VMMR3DECL(int) HMR3EmulateIoBlock(PVM pVM, PCPUMCTX pCtx);
|
---|
118 | VMMR3DECL(VBOXSTRICTRC) HMR3RestartPendingIOInstr(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
|
---|
119 | VMMR3DECL(int) HMR3EnablePatching(PVM pVM, RTGCPTR pPatchMem, unsigned cbPatchMem);
|
---|
120 | VMMR3DECL(int) HMR3DisablePatching(PVM pVM, RTGCPTR pPatchMem, unsigned cbPatchMem);
|
---|
121 | VMMR3DECL(int) HMR3PatchTprInstr(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
|
---|
122 | VMMR3DECL(bool) HMR3IsRescheduleRequired(PVM pVM, PCPUMCTX pCtx);
|
---|
123 | VMMR3DECL(bool) HMR3IsVmxPreemptionTimerUsed(PVM pVM);
|
---|
124 |
|
---|
125 | /** @} */
|
---|
126 | #endif /* IN_RING3 */
|
---|
127 |
|
---|
128 | #ifdef IN_RING0
|
---|
129 | /** @addtogroup grp_hm_r0
|
---|
130 | * @{
|
---|
131 | */
|
---|
132 | VMMR0DECL(int) HMR0SetupVM(PVM pVM);
|
---|
133 | VMMR0DECL(int) HMR0RunGuestCode(PVM pVM, PVMCPU pVCpu);
|
---|
134 | VMMR0DECL(int) HMR0Enter(PVM pVM, PVMCPU pVCpu);
|
---|
135 | VMMR0DECL(int) HMR0Leave(PVM pVM, PVMCPU pVCpu);
|
---|
136 | VMMR0DECL(int) HMR0InvalidatePage(PVM pVM, PVMCPU pVCpu);
|
---|
137 | VMMR0DECL(int) HMR0FlushTLB(PVM pVM);
|
---|
138 | VMMR0DECL(bool) HMR0SuspendPending(void);
|
---|
139 |
|
---|
140 | # if HC_ARCH_BITS == 32 && defined(VBOX_WITH_64_BITS_GUESTS)
|
---|
141 | VMMR0DECL(int) HMR0SaveFPUState(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
|
---|
142 | VMMR0DECL(int) HMR0SaveDebugState(PVM pVM, PVMCPU pVCpu, PCPUMCTX pCtx);
|
---|
143 | VMMR0DECL(int) HMR0TestSwitcher3264(PVM pVM);
|
---|
144 | # endif
|
---|
145 |
|
---|
146 | /** @} */
|
---|
147 | #endif /* IN_RING0 */
|
---|
148 |
|
---|
149 |
|
---|
150 | /** @} */
|
---|
151 | RT_C_DECLS_END
|
---|
152 |
|
---|
153 |
|
---|
154 | #endif
|
---|
155 |
|
---|