VirtualBox

source: vbox/trunk/include/VBox/vmm/nem.h

最後變更 在這個檔案是 108386,由 vboxsync 提交於 2 週 前

VMMR3/VMEmt.cpp,VMMR3/TM.cpp,VMMR3/NEMR3Native-win-armv8.cpp: Workaround for Windows/ARM hosts to allow for guests to use more than 1 vCPU, bugref:10392

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 11.7 KB
 
1/** @file
2 * NEM - The Native Execution Manager.
3 */
4
5/*
6 * Copyright (C) 2018-2024 Oracle and/or its affiliates.
7 *
8 * This file is part of VirtualBox base platform packages, as
9 * available from https://www.alldomusa.eu.org.
10 *
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation, in version 3 of the
14 * License.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, see <https://www.gnu.org/licenses>.
23 *
24 * The contents of this file may alternatively be used under the terms
25 * of the Common Development and Distribution License Version 1.0
26 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
27 * in the VirtualBox distribution, in which case the provisions of the
28 * CDDL are applicable instead of those of the GPL.
29 *
30 * You may elect to license modified versions of this file under the
31 * terms and conditions of either the GPL or the CDDL or both.
32 *
33 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
34 */
35
36#ifndef VBOX_INCLUDED_vmm_nem_h
37#define VBOX_INCLUDED_vmm_nem_h
38#ifndef RT_WITHOUT_PRAGMA_ONCE
39# pragma once
40#endif
41
42#include <VBox/types.h>
43#include <VBox/vmm/vmapi.h>
44#include <VBox/vmm/pgm.h>
45
46
47RT_C_DECLS_BEGIN
48
49/** @defgroup grp_nem The Native Execution Manager API
50 * @ingroup grp_vmm
51 * @{
52 */
53
54/** @defgroup grp_nem_r3 The NEM ring-3 Context API
55 * @{
56 */
57VMMR3_INT_DECL(int) NEMR3InitConfig(PVM pVM);
58VMMR3_INT_DECL(int) NEMR3Init(PVM pVM, bool fFallback, bool fForced);
59VMMR3_INT_DECL(int) NEMR3InitAfterCPUM(PVM pVM);
60#ifdef IN_RING3
61VMMR3_INT_DECL(int) NEMR3InitCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
62#endif
63VMMR3_INT_DECL(int) NEMR3Term(PVM pVM);
64VMMR3DECL(bool) NEMR3IsEnabled(PUVM pVM);
65VMMR3_INT_DECL(bool) NEMR3NeedSpecialTscMode(PVM pVM);
66VMMR3_INT_DECL(void) NEMR3Reset(PVM pVM);
67VMMR3_INT_DECL(void) NEMR3ResetCpu(PVMCPU pVCpu, bool fInitIpi);
68VMMR3DECL(const char *) NEMR3GetExitName(uint32_t uExit);
69VMMR3_INT_DECL(VBOXSTRICTRC) NEMR3RunGC(PVM pVM, PVMCPU pVCpu);
70VMMR3_INT_DECL(bool) NEMR3CanExecuteGuest(PVM pVM, PVMCPU pVCpu);
71VMMR3_INT_DECL(bool) NEMR3SetSingleInstruction(PVM pVM, PVMCPU pVCpu, bool fEnable);
72VMMR3_INT_DECL(void) NEMR3NotifyFF(PVM pVM, PVMCPU pVCpu, uint32_t fFlags);
73#if defined(VBOX_VMM_TARGET_ARMV8) && defined(RT_OS_WINDOWS)
74VMMR3_INT_DECL(int) NEMR3Halt(PVM pVM, PVMCPU pVCpu);
75#endif
76
77/**
78 * Checks if dirty page tracking for MMIO2 ranges is supported.
79 *
80 * If it is, PGM will not install a physical write access handler for the MMIO2
81 * region and instead just forward dirty bit queries NEMR3QueryMmio2DirtyBits.
82 * The enable/disable control of the tracking will be ignored, and PGM will
83 * always set NEM_NOTIFY_PHYS_MMIO_EX_F_TRACK_DIRTY_PAGES for such ranges.
84 *
85 * @retval true if supported.
86 * @retval false if not.
87 * @param pVM The cross context VM structure.
88 */
89VMMR3_INT_DECL(bool) NEMR3IsMmio2DirtyPageTrackingSupported(PVM pVM);
90
91/**
92 * Worker for PGMR3PhysMmio2QueryAndResetDirtyBitmap.
93 *
94 * @returns VBox status code.
95 * @param pVM The cross context VM structure.
96 * @param GCPhys The address of the MMIO2 range.
97 * @param cb The size of the MMIO2 range.
98 * @param uNemRange The NEM internal range number.
99 * @param pvBitmap The output bitmap. Must be 8-byte aligned. Ignored
100 * when @a cbBitmap is zero.
101 * @param cbBitmap The size of the bitmap. Must be the size of the whole
102 * MMIO2 range, rounded up to the nearest 8 bytes.
103 * When zero only a reset is done.
104 */
105VMMR3_INT_DECL(int) NEMR3PhysMmio2QueryAndResetDirtyBitmap(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, uint32_t uNemRange,
106 void *pvBitmap, size_t cbBitmap);
107
108VMMR3_INT_DECL(int) NEMR3NotifyPhysRamRegister(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, void *pvR3,
109 uint8_t *pu2State, uint32_t *puNemRange);
110VMMR3_INT_DECL(int) NEMR3NotifyPhysMmioExMapEarly(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, uint32_t fFlags,
111 void *pvRam, void *pvMmio2, uint8_t *pu2State, uint32_t *puNemRange);
112VMMR3_INT_DECL(int) NEMR3NotifyPhysMmioExMapLate(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, uint32_t fFlags,
113 void *pvRam, void *pvMmio2, uint32_t *puNemRange);
114VMMR3_INT_DECL(int) NEMR3NotifyPhysMmioExUnmap(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, uint32_t fFlags,
115 void *pvRam, void *pvMmio2, uint8_t *pu2State, uint32_t *puNemRange);
116/** @name Flags for NEMR3NotifyPhysMmioExMap and NEMR3NotifyPhysMmioExUnmap.
117 * @{ */
118/** Set if the range is replacing RAM rather that unused space. */
119#define NEM_NOTIFY_PHYS_MMIO_EX_F_REPLACE RT_BIT(0)
120/** Set if it's MMIO2 being mapped or unmapped. */
121#define NEM_NOTIFY_PHYS_MMIO_EX_F_MMIO2 RT_BIT(1)
122/** Set if MMIO2 and dirty page tracking is configured. */
123#define NEM_NOTIFY_PHYS_MMIO_EX_F_TRACK_DIRTY_PAGES RT_BIT(2)
124/** @} */
125
126/**
127 * Called very early during ROM registration, basically so an existing RAM range
128 * can be adjusted if desired.
129 *
130 * It will be succeeded by a number of NEMHCNotifyPhysPageProtChanged()
131 * calls and finally a call to NEMR3NotifyPhysRomRegisterLate().
132 *
133 * @returns VBox status code
134 * @param pVM The cross context VM structure.
135 * @param GCPhys The ROM address (page aligned).
136 * @param cb The size (page aligned).
137 * @param pvPages Pointer to the ROM (RAM) pages in simplified mode
138 * when NEM_NOTIFY_PHYS_ROM_F_REPLACE is set, otherwise
139 * NULL.
140 * @param fFlags NEM_NOTIFY_PHYS_ROM_F_XXX.
141 * @param pu2State New page state or UINT8_MAX to leave as-is.
142 * @param puNemRange Access to the relevant PGMRAMRANGE::uNemRange field.
143 */
144VMMR3_INT_DECL(int) NEMR3NotifyPhysRomRegisterEarly(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, void *pvPages,
145 uint32_t fFlags, uint8_t *pu2State, uint32_t *puNemRange);
146
147/**
148 * Called after the ROM range has been fully completed.
149 *
150 * This will be preceeded by a NEMR3NotifyPhysRomRegisterEarly() call as well a
151 * number of NEMHCNotifyPhysPageProtChanged calls.
152 *
153 * @returns VBox status code
154 * @param pVM The cross context VM structure.
155 * @param GCPhys The ROM address (page aligned).
156 * @param cb The size (page aligned).
157 * @param pvPages Pointer to the ROM pages.
158 * @param fFlags NEM_NOTIFY_PHYS_ROM_F_XXX.
159 * @param pu2State Where to return the new NEM page state, UINT8_MAX
160 * for unchanged.
161 * @param puNemRange Access to the relevant PGMRAMRANGE::uNemRange field.
162 */
163VMMR3_INT_DECL(int) NEMR3NotifyPhysRomRegisterLate(PVM pVM, RTGCPHYS GCPhys, RTGCPHYS cb, void *pvPages,
164 uint32_t fFlags, uint8_t *pu2State, uint32_t *puNemRange);
165
166/** @name Flags for NEMR3NotifyPhysRomRegisterEarly and NEMR3NotifyPhysRomRegisterLate.
167 * @{ */
168/** Set if the range is replacing RAM rather that unused space. */
169#define NEM_NOTIFY_PHYS_ROM_F_REPLACE RT_BIT(1)
170/** Set if it's MMIO2 being mapped or unmapped. */
171#define NEM_NOTIFY_PHYS_ROM_F_SHADOW RT_BIT(2)
172/** @} */
173
174/**
175 * Called when the A20 state changes.
176 *
177 * Windows: Hyper-V doesn't seem to offer a simple way of implementing the A20
178 * line features of PCs. So, we do a very minimal emulation of the HMA to make
179 * DOS happy.
180 *
181 * @param pVCpu The CPU the A20 state changed on.
182 * @param fEnabled Whether it was enabled (true) or disabled.
183 */
184VMMR3_INT_DECL(void) NEMR3NotifySetA20(PVMCPU pVCpu, bool fEnabled);
185VMMR3_INT_DECL(void) NEMR3NotifyDebugEventChanged(PVM pVM);
186VMMR3_INT_DECL(void) NEMR3NotifyDebugEventChangedPerCpu(PVM pVM, PVMCPU pVCpu);
187/** @} */
188
189
190/** @defgroup grp_nem_r0 The NEM ring-0 Context API
191 * @{ */
192VMMR0_INT_DECL(int) NEMR0Init(void);
193VMMR0_INT_DECL(void) NEMR0Term(void);
194VMMR0_INT_DECL(int) NEMR0InitVM(PGVM pGVM);
195VMMR0_INT_DECL(int) NEMR0InitVMPart2(PGVM pGVM);
196VMMR0_INT_DECL(void) NEMR0CleanupVM(PGVM pGVM);
197VMMR0_INT_DECL(int) NEMR0MapPages(PGVM pGVM, VMCPUID idCpu);
198VMMR0_INT_DECL(int) NEMR0UnmapPages(PGVM pGVM, VMCPUID idCpu);
199VMMR0_INT_DECL(int) NEMR0ExportState(PGVM pGVM, VMCPUID idCpu);
200VMMR0_INT_DECL(int) NEMR0ImportState(PGVM pGVM, VMCPUID idCpu, uint64_t fWhat);
201VMMR0_INT_DECL(int) NEMR0QueryCpuTick(PGVM pGVM, VMCPUID idCpu);
202VMMR0_INT_DECL(int) NEMR0ResumeCpuTickOnAll(PGVM pGVM, VMCPUID idCpu, uint64_t uPausedTscValue);
203VMMR0_INT_DECL(VBOXSTRICTRC) NEMR0RunGuestCode(PGVM pGVM, VMCPUID idCpu);
204VMMR0_INT_DECL(int) NEMR0UpdateStatistics(PGVM pGVM, VMCPUID idCpu);
205VMMR0_INT_DECL(int) NEMR0DoExperiment(PGVM pGVM, VMCPUID idCpu, uint64_t u64Arg);
206#ifdef RT_OS_WINDOWS
207VMMR0_INT_DECL(int) NEMR0WinGetPartitionId(PGVM pGVM, uintptr_t uHandle);
208#endif
209/** @} */
210
211
212/** @defgroup grp_nem_hc The NEM Host Context API
213 * @{
214 */
215VMM_INT_DECL(bool) NEMHCIsLongModeAllowed(PVMCC pVM);
216VMM_INT_DECL(uint32_t) NEMHCGetFeatures(PVMCC pVM);
217VMM_INT_DECL(int) NEMImportStateOnDemand(PVMCPUCC pVCpu, uint64_t fWhat);
218
219/** @name NEM_FEAT_F_XXX - Features supported by the NEM backend
220 * @{ */
221/** NEM backend uses nested paging for the guest. */
222#define NEM_FEAT_F_NESTED_PAGING RT_BIT(0)
223/** NEM backend uses full (unrestricted) guest execution. */
224#define NEM_FEAT_F_FULL_GST_EXEC RT_BIT(1)
225/** NEM backend offers an xsave/xrstor interface. */
226#define NEM_FEAT_F_XSAVE_XRSTOR RT_BIT(2)
227/** @} */
228
229VMM_INT_DECL(void) NEMHCNotifyHandlerPhysicalRegister(PVMCC pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb);
230VMM_INT_DECL(void) NEMHCNotifyHandlerPhysicalDeregister(PVMCC pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb,
231 RTR3PTR pvMemR3, uint8_t *pu2State);
232VMM_INT_DECL(void) NEMHCNotifyHandlerPhysicalModify(PVMCC pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhysOld,
233 RTGCPHYS GCPhysNew, RTGCPHYS cb, bool fRestoreAsRAM);
234
235VMM_INT_DECL(int) NEMHCNotifyPhysPageAllocated(PVMCC pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhys, uint32_t fPageProt,
236 PGMPAGETYPE enmType, uint8_t *pu2State);
237VMM_INT_DECL(void) NEMHCNotifyPhysPageProtChanged(PVMCC pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhys, RTR3PTR pvR3, uint32_t fPageProt,
238 PGMPAGETYPE enmType, uint8_t *pu2State);
239VMM_INT_DECL(void) NEMHCNotifyPhysPageChanged(PVMCC pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhysPrev, RTHCPHYS HCPhysNew,
240 RTR3PTR pvNewR3, uint32_t fPageProt, PGMPAGETYPE enmType, uint8_t *pu2State);
241/** @name NEM_PAGE_PROT_XXX - Page protection
242 * @{ */
243#define NEM_PAGE_PROT_NONE UINT32_C(0) /**< All access causes VM exits. */
244#define NEM_PAGE_PROT_READ RT_BIT(0) /**< Read access. */
245#define NEM_PAGE_PROT_EXECUTE RT_BIT(1) /**< Execute access. */
246#define NEM_PAGE_PROT_WRITE RT_BIT(2) /**< write access. */
247/** @} */
248
249VMM_INT_DECL(int) NEMHCQueryCpuTick(PVMCPUCC pVCpu, uint64_t *pcTicks, uint32_t *puAux);
250VMM_INT_DECL(int) NEMHCResumeCpuTickOnAll(PVMCC pVM, PVMCPUCC pVCpu, uint64_t uPausedTscValue);
251
252/** @} */
253
254/** @} */
255RT_C_DECLS_END
256
257
258#endif /* !VBOX_INCLUDED_vmm_nem_h */
259
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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