VirtualBox

source: vbox/trunk/src/VBox/VMM/include/NEMInternal.h@ 93351

最後變更 在這個檔案從93351是 93351,由 vboxsync 提交於 3 年 前

VMM/NEM-win: Kicked out most of the ring-0 code because bugref:10118 + bugref:10162 means we won't use it again.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 23.1 KB
 
1/* $Id: NEMInternal.h 93351 2022-01-19 23:35:13Z vboxsync $ */
2/** @file
3 * NEM - Internal header file.
4 */
5
6/*
7 * Copyright (C) 2018-2022 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.alldomusa.eu.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef VMM_INCLUDED_SRC_include_NEMInternal_h
19#define VMM_INCLUDED_SRC_include_NEMInternal_h
20#ifndef RT_WITHOUT_PRAGMA_ONCE
21# pragma once
22#endif
23
24#include <VBox/cdefs.h>
25#include <VBox/types.h>
26#include <VBox/vmm/nem.h>
27#include <VBox/vmm/cpum.h> /* For CPUMCPUVENDOR. */
28#include <VBox/vmm/stam.h>
29#include <VBox/vmm/vmapi.h>
30#ifdef RT_OS_WINDOWS
31#include <iprt/nt/hyperv.h>
32#include <iprt/critsect.h>
33#elif defined(RT_OS_DARWIN)
34# include "VMXInternal.h"
35#endif
36
37RT_C_DECLS_BEGIN
38
39
40/** @defgroup grp_nem_int Internal
41 * @ingroup grp_nem
42 * @internal
43 * @{
44 */
45
46#if defined(VBOX_WITH_PGM_NEM_MODE) && !defined(VBOX_WITH_NATIVE_NEM)
47# error "VBOX_WITH_PGM_NEM_MODE requires VBOX_WITH_NATIVE_NEM to be defined"
48#endif
49
50
51#ifdef RT_OS_WINDOWS
52/*
53 * Windows: Code configuration.
54 */
55//# define NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS /**< Applies to ring-3 code only. Useful for testing VID API. */
56//# define NEM_WIN_USE_OUR_OWN_RUN_API /**< Applies to ring-3 code only. Useful for testing VID API. */
57# if defined(NEM_WIN_USE_OUR_OWN_RUN_API) && !defined(NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS)
58# error "NEM_WIN_USE_OUR_OWN_RUN_API requires NEM_WIN_USE_HYPERCALLS_FOR_REGISTERS"
59# endif
60
61/**
62 * Windows VID I/O control information.
63 */
64typedef struct NEMWINIOCTL
65{
66 /** The I/O control function number. */
67 uint32_t uFunction;
68 uint32_t cbInput;
69 uint32_t cbOutput;
70} NEMWINIOCTL;
71
72/** @name Windows: Our two-bit physical page state for PGMPAGE
73 * @{ */
74# define NEM_WIN_PAGE_STATE_NOT_SET 0
75# define NEM_WIN_PAGE_STATE_UNMAPPED 1
76# define NEM_WIN_PAGE_STATE_READABLE 2
77# define NEM_WIN_PAGE_STATE_WRITABLE 3
78/** @} */
79
80/** Windows: Checks if a_GCPhys is subject to the limited A20 gate emulation. */
81# define NEM_WIN_IS_SUBJECT_TO_A20(a_GCPhys) ((RTGCPHYS)((a_GCPhys) - _1M) < (RTGCPHYS)_64K)
82/** Windows: Checks if a_GCPhys is relevant to the limited A20 gate emulation. */
83# define NEM_WIN_IS_RELEVANT_TO_A20(a_GCPhys) \
84 ( ((RTGCPHYS)((a_GCPhys) - _1M) < (RTGCPHYS)_64K) || ((RTGCPHYS)(a_GCPhys) < (RTGCPHYS)_64K) )
85
86/** The CPUMCTX_EXTRN_XXX mask for IEM. */
87# define NEM_WIN_CPUMCTX_EXTRN_MASK_FOR_IEM ( IEM_CPUMCTX_EXTRN_MUST_MASK | CPUMCTX_EXTRN_INHIBIT_INT \
88 | CPUMCTX_EXTRN_INHIBIT_NMI )
89/** The CPUMCTX_EXTRN_XXX mask for IEM when raising exceptions. */
90# define NEM_WIN_CPUMCTX_EXTRN_MASK_FOR_IEM_XCPT (IEM_CPUMCTX_EXTRN_XCPT_MASK | NEM_WIN_CPUMCTX_EXTRN_MASK_FOR_IEM)
91
92/** @name Windows: Interrupt window flags (NEM_WIN_INTW_F_XXX).
93 * @{ */
94# define NEM_WIN_INTW_F_NMI UINT8_C(0x01)
95# define NEM_WIN_INTW_F_REGULAR UINT8_C(0x02)
96# define NEM_WIN_INTW_F_PRIO_MASK UINT8_C(0x3c)
97# define NEM_WIN_INTW_F_PRIO_SHIFT 2
98/** @} */
99
100#endif /* RT_OS_WINDOWS */
101
102
103#ifdef RT_OS_DARWIN
104/** vCPU ID declaration to avoid dragging in HV headers here. */
105typedef unsigned hv_vcpuid_t;
106/** The HV VM memory space ID (ASID). */
107typedef unsigned hv_vm_space_t;
108
109
110/** @name Darwin: Our two-bit physical page state for PGMPAGE
111 * @{ */
112# define NEM_DARWIN_PAGE_STATE_NOT_SET 0
113# define NEM_DARWIN_PAGE_STATE_UNMAPPED 1
114# define NEM_DARWIN_PAGE_STATE_READABLE 2
115# define NEM_DARWIN_PAGE_STATE_WRITABLE 3
116/** @} */
117
118/** The CPUMCTX_EXTRN_XXX mask for IEM. */
119# define NEM_DARWIN_CPUMCTX_EXTRN_MASK_FOR_IEM ( IEM_CPUMCTX_EXTRN_MUST_MASK | CPUMCTX_EXTRN_INHIBIT_INT \
120 | CPUMCTX_EXTRN_INHIBIT_NMI )
121/** The CPUMCTX_EXTRN_XXX mask for IEM when raising exceptions. */
122# define NEM_DARWIN_CPUMCTX_EXTRN_MASK_FOR_IEM_XCPT (IEM_CPUMCTX_EXTRN_XCPT_MASK | NEM_DARWIN_CPUMCTX_EXTRN_MASK_FOR_IEM)
123
124#endif
125
126
127/** Trick to make slickedit see the static functions in the template. */
128#ifndef IN_SLICKEDIT
129# define NEM_TMPL_STATIC static
130#else
131# define NEM_TMPL_STATIC
132#endif
133
134
135/**
136 * Generic NEM exit type enumeration for use with EMHistoryAddExit.
137 *
138 * On windows we've got two different set of exit types and they are both jumping
139 * around the place value wise, so EM can use their values.
140 *
141 * @note We only have exit types for exits not covered by EM here.
142 */
143typedef enum NEMEXITTYPE
144{
145 NEMEXITTYPE_INVALID = 0,
146
147 /* Common: */
148 NEMEXITTYPE_INTTERRUPT_WINDOW,
149 NEMEXITTYPE_HALT,
150
151 /* Windows: */
152 NEMEXITTYPE_UNRECOVERABLE_EXCEPTION,
153 NEMEXITTYPE_INVALID_VP_REGISTER_VALUE,
154 NEMEXITTYPE_XCPT_UD,
155 NEMEXITTYPE_XCPT_DB,
156 NEMEXITTYPE_XCPT_BP,
157 NEMEXITTYPE_CANCELED,
158 NEMEXITTYPE_MEMORY_ACCESS,
159
160 /* Linux: */
161 NEMEXITTYPE_INTERNAL_ERROR_EMULATION,
162 NEMEXITTYPE_INTERNAL_ERROR_FATAL,
163 NEMEXITTYPE_INTERRUPTED,
164 NEMEXITTYPE_FAILED_ENTRY,
165
166 /* End of valid types. */
167 NEMEXITTYPE_END
168} NEMEXITTYPE;
169
170
171/**
172 * NEM VM Instance data.
173 */
174typedef struct NEM
175{
176 /** NEM_MAGIC. */
177 uint32_t u32Magic;
178
179 /** Set if enabled. */
180 bool fEnabled;
181 /** Set if long mode guests are allowed. */
182 bool fAllow64BitGuests;
183
184#if defined(RT_OS_LINUX)
185 /** The '/dev/kvm' file descriptor. */
186 int32_t fdKvm;
187 /** The KVM_CREATE_VM file descriptor. */
188 int32_t fdVm;
189
190 /** KVM_GET_VCPU_MMAP_SIZE. */
191 uint32_t cbVCpuMmap;
192 /** KVM_CAP_NR_MEMSLOTS. */
193 uint32_t cMaxMemSlots;
194 /** KVM_CAP_X86_ROBUST_SINGLESTEP. */
195 bool fRobustSingleStep;
196
197 /** Hint where there might be a free slot. */
198 uint16_t idPrevSlot;
199 /** Memory slot ID allocation bitmap. */
200 uint64_t bmSlotIds[_32K / 8 / sizeof(uint64_t)];
201
202#elif defined(RT_OS_WINDOWS)
203 /** Set if we've created the EMTs. */
204 bool fCreatedEmts : 1;
205 /** WHvRunVpExitReasonX64Cpuid is supported. */
206 bool fExtendedMsrExit : 1;
207 /** WHvRunVpExitReasonX64MsrAccess is supported. */
208 bool fExtendedCpuIdExit : 1;
209 /** WHvRunVpExitReasonException is supported. */
210 bool fExtendedXcptExit : 1;
211# ifndef VBOX_WITH_PGM_NEM_MODE
212 /** Set if we're using the ring-0 API to do the work. */
213 bool fUseRing0Runloop : 1;
214# endif
215# ifdef NEM_WIN_WITH_A20
216 /** Set if we've started more than one CPU and cannot mess with A20. */
217 bool fA20Fixed : 1;
218 /** Set if A20 is enabled. */
219 bool fA20Enabled : 1;
220# endif
221 /** The reported CPU vendor. */
222 CPUMCPUVENDOR enmCpuVendor;
223 /** Cache line flush size as a power of two. */
224 uint8_t cCacheLineFlushShift;
225 /** The result of WHvCapabilityCodeProcessorFeatures. */
226 union
227 {
228 /** 64-bit view. */
229 uint64_t u64;
230# ifdef _WINHVAPIDEFS_H_
231 /** Interpreed features. */
232 WHV_PROCESSOR_FEATURES u;
233# endif
234 } uCpuFeatures;
235
236 /** The partition handle. */
237# ifdef _WINHVAPIDEFS_H_
238 WHV_PARTITION_HANDLE
239# else
240 RTHCUINTPTR
241# endif
242 hPartition;
243 /** The device handle for the partition, for use with Vid APIs or direct I/O
244 * controls. */
245 RTR3PTR hPartitionDevice;
246 /** The Hyper-V partition ID. */
247 uint64_t idHvPartition;
248
249 /** Number of currently mapped pages. */
250 uint32_t volatile cMappedPages;
251 /** Max number of pages we dare map at once. */
252#ifdef VBOX_WITH_PGM_NEM_MODE
253 /** @todo consider removing this. */
254#endif
255 uint32_t cMaxMappedPages;
256 STAMCOUNTER StatMapPage;
257 STAMCOUNTER StatUnmapPage;
258# if !defined(VBOX_WITH_PGM_NEM_MODE)
259 STAMCOUNTER StatUnmapAllPages;
260# endif
261 STAMCOUNTER StatMapPageFailed;
262 STAMCOUNTER StatUnmapPageFailed;
263# ifdef VBOX_WITH_PGM_NEM_MODE
264 STAMPROFILE StatProfMapGpaRange;
265 STAMPROFILE StatProfUnmapGpaRange;
266# endif
267 STAMPROFILE StatProfMapGpaRangePage;
268 STAMPROFILE StatProfUnmapGpaRangePage;
269
270 /** Statistics updated by NEMR0UpdateStatistics. */
271 struct
272 {
273 uint64_t cPagesAvailable;
274 uint64_t cPagesInUse;
275 } R0Stats;
276
277#elif defined(RT_OS_DARWIN)
278 /** Set if we've created the EMTs. */
279 bool fCreatedEmts : 1;
280 /** Set if hv_vm_create() was called successfully. */
281 bool fCreatedVm : 1;
282 /** Set if hv_vm_space_create() was called successfully. */
283 bool fCreatedAsid : 1;
284 /** The ASID for this VM (only valid if fCreatedAsid is true). */
285 hv_vm_space_t uVmAsid;
286 STAMCOUNTER StatMapPage;
287 STAMCOUNTER StatUnmapPage;
288 STAMCOUNTER StatMapPageFailed;
289 STAMCOUNTER StatUnmapPageFailed;
290#endif /* RT_OS_WINDOWS */
291} NEM;
292/** Pointer to NEM VM instance data. */
293typedef NEM *PNEM;
294
295/** NEM::u32Magic value. */
296#define NEM_MAGIC UINT32_C(0x004d454e)
297/** NEM::u32Magic value after termination. */
298#define NEM_MAGIC_DEAD UINT32_C(0xdead1111)
299
300
301/**
302 * NEM VMCPU Instance data.
303 */
304typedef struct NEMCPU
305{
306 /** NEMCPU_MAGIC. */
307 uint32_t u32Magic;
308 /** Whether \#UD needs to be intercepted and presented to GIM. */
309 bool fGIMTrapXcptUD : 1;
310 /** Whether \#GP needs to be intercept for mesa driver workaround. */
311 bool fTrapXcptGpForLovelyMesaDrv: 1;
312
313#if defined(RT_OS_LINUX)
314 uint8_t abPadding[3];
315 /** The KVM VCpu file descriptor. */
316 int32_t fdVCpu;
317 /** Pointer to the KVM_RUN data exchange region. */
318 R3PTRTYPE(struct kvm_run *) pRun;
319 /** The MSR_IA32_APICBASE value known to KVM. */
320 uint64_t uKvmApicBase;
321
322 /** @name Statistics
323 * @{ */
324 STAMCOUNTER StatExitTotal;
325 STAMCOUNTER StatExitIo;
326 STAMCOUNTER StatExitMmio;
327 STAMCOUNTER StatExitSetTpr;
328 STAMCOUNTER StatExitTprAccess;
329 STAMCOUNTER StatExitRdMsr;
330 STAMCOUNTER StatExitWrMsr;
331 STAMCOUNTER StatExitIrqWindowOpen;
332 STAMCOUNTER StatExitHalt;
333 STAMCOUNTER StatExitIntr;
334 STAMCOUNTER StatExitHypercall;
335 STAMCOUNTER StatExitDebug;
336 STAMCOUNTER StatExitBusLock;
337 STAMCOUNTER StatExitInternalErrorEmulation;
338 STAMCOUNTER StatExitInternalErrorFatal;
339# if 0
340 STAMCOUNTER StatExitCpuId;
341 STAMCOUNTER StatExitUnrecoverable;
342 STAMCOUNTER StatGetMsgTimeout;
343 STAMCOUNTER StatStopCpuSuccess;
344 STAMCOUNTER StatStopCpuPending;
345 STAMCOUNTER StatStopCpuPendingAlerts;
346 STAMCOUNTER StatStopCpuPendingOdd;
347 STAMCOUNTER StatCancelChangedState;
348 STAMCOUNTER StatCancelAlertedThread;
349# endif
350 STAMCOUNTER StatBreakOnCancel;
351 STAMCOUNTER StatBreakOnFFPre;
352 STAMCOUNTER StatBreakOnFFPost;
353 STAMCOUNTER StatBreakOnStatus;
354 STAMCOUNTER StatFlushExitOnReturn;
355 STAMCOUNTER StatFlushExitOnReturn1Loop;
356 STAMCOUNTER StatFlushExitOnReturn2Loops;
357 STAMCOUNTER StatFlushExitOnReturn3Loops;
358 STAMCOUNTER StatFlushExitOnReturn4PlusLoops;
359 STAMCOUNTER StatImportOnDemand;
360 STAMCOUNTER StatImportOnReturn;
361 STAMCOUNTER StatImportOnReturnSkipped;
362 STAMCOUNTER StatImportPendingInterrupt;
363 STAMCOUNTER StatExportPendingInterrupt;
364 STAMCOUNTER StatQueryCpuTick;
365 /** @} */
366
367
368#elif defined(RT_OS_WINDOWS)
369 /** The current state of the interrupt windows (NEM_WIN_INTW_F_XXX). */
370 uint8_t fCurrentInterruptWindows;
371 /** The desired state of the interrupt windows (NEM_WIN_INTW_F_XXX). */
372 uint8_t fDesiredInterruptWindows;
373 /** Last copy of HV_X64_VP_EXECUTION_STATE::InterruptShadow. */
374 bool fLastInterruptShadow : 1;
375 uint32_t uPadding;
376 /** The VID_MSHAGN_F_XXX flags.
377 * Either VID_MSHAGN_F_HANDLE_MESSAGE | VID_MSHAGN_F_GET_NEXT_MESSAGE or zero. */
378 uint32_t fHandleAndGetFlags;
379 /** What VidMessageSlotMap returns and is used for passing exit info. */
380 RTR3PTR pvMsgSlotMapping;
381 /** The windows thread handle. */
382 RTR3PTR hNativeThreadHandle;
383 /** Parameters for making Hyper-V hypercalls. */
384 union
385 {
386 uint8_t ab[64];
387 /** Arguments for NEMR0MapPages (HvCallMapGpaPages). */
388 struct
389 {
390 RTGCPHYS GCPhysSrc;
391 RTGCPHYS GCPhysDst; /**< Same as GCPhysSrc except maybe when the A20 gate is disabled. */
392 uint32_t cPages;
393 HV_MAP_GPA_FLAGS fFlags;
394 } MapPages;
395 /** Arguments for NEMR0UnmapPages (HvCallUnmapGpaPages). */
396 struct
397 {
398 RTGCPHYS GCPhys;
399 uint32_t cPages;
400 } UnmapPages;
401 /** Result from NEMR0QueryCpuTick. */
402 struct
403 {
404 uint64_t cTicks;
405 uint32_t uAux;
406 } QueryCpuTick;
407 /** Input and output for NEMR0DoExperiment. */
408 struct
409 {
410 uint32_t uItem;
411 bool fSuccess;
412 uint64_t uStatus;
413 uint64_t uLoValue;
414 uint64_t uHiValue;
415 } Experiment;
416 } Hypercall;
417 /** I/O control buffer, we always use this for I/O controls. */
418 union
419 {
420 uint8_t ab[64];
421 HV_PARTITION_ID idPartition;
422 HV_VP_INDEX idCpu;
423 struct
424 {
425 uint64_t enmProperty;
426 uint64_t uValue;
427 } GetProp;
428# ifdef VID_MSHAGN_F_GET_NEXT_MESSAGE
429 VID_IOCTL_INPUT_MESSAGE_SLOT_HANDLE_AND_GET_NEXT MsgSlotHandleAndGetNext;
430# endif
431 } uIoCtlBuf;
432
433 /** @name Statistics
434 * @{ */
435 STAMCOUNTER StatExitPortIo;
436 STAMCOUNTER StatExitMemUnmapped;
437 STAMCOUNTER StatExitMemIntercept;
438 STAMCOUNTER StatExitHalt;
439 STAMCOUNTER StatExitInterruptWindow;
440 STAMCOUNTER StatExitCpuId;
441 STAMCOUNTER StatExitMsr;
442 STAMCOUNTER StatExitException;
443 STAMCOUNTER StatExitExceptionBp;
444 STAMCOUNTER StatExitExceptionDb;
445 STAMCOUNTER StatExitExceptionGp;
446 STAMCOUNTER StatExitExceptionGpMesa;
447 STAMCOUNTER StatExitExceptionUd;
448 STAMCOUNTER StatExitExceptionUdHandled;
449 STAMCOUNTER StatExitUnrecoverable;
450 STAMCOUNTER StatGetMsgTimeout;
451 STAMCOUNTER StatStopCpuSuccess;
452 STAMCOUNTER StatStopCpuPending;
453 STAMCOUNTER StatStopCpuPendingAlerts;
454 STAMCOUNTER StatStopCpuPendingOdd;
455 STAMCOUNTER StatCancelChangedState;
456 STAMCOUNTER StatCancelAlertedThread;
457 STAMCOUNTER StatBreakOnCancel;
458 STAMCOUNTER StatBreakOnFFPre;
459 STAMCOUNTER StatBreakOnFFPost;
460 STAMCOUNTER StatBreakOnStatus;
461 STAMCOUNTER StatImportOnDemand;
462 STAMCOUNTER StatImportOnReturn;
463 STAMCOUNTER StatImportOnReturnSkipped;
464 STAMCOUNTER StatQueryCpuTick;
465 /** @} */
466
467#elif defined(RT_OS_DARWIN)
468 /** The vCPU handle associated with the EMT executing this vCPU. */
469 hv_vcpuid_t hVCpuId;
470
471 /** @name State shared with the VT-x code.
472 * @{ */
473 /** Whether we should use the debug loop because of single stepping or special
474 * debug breakpoints / events are armed. */
475 bool fUseDebugLoop;
476 /** Whether we're executing a single instruction. */
477 bool fSingleInstruction;
478
479 bool afAlignment0[2];
480
481 /** An additional error code used for some gurus. */
482 uint32_t u32HMError;
483 /** The last exit-to-ring-3 reason. */
484 int32_t rcLastExitToR3;
485 /** CPU-context changed flags (see HM_CHANGED_xxx). */
486 uint64_t fCtxChanged;
487
488 /** The guest VMCS information. */
489 VMXVMCSINFO VmcsInfo;
490
491 /** VT-x data. */
492 struct HMCPUVMX
493 {
494 /** @name Guest information.
495 * @{ */
496 /** Guest VMCS information shared with ring-3. */
497 VMXVMCSINFOSHARED VmcsInfo;
498 /** Nested-guest VMCS information shared with ring-3. */
499 VMXVMCSINFOSHARED VmcsInfoNstGst;
500 /** Whether the nested-guest VMCS was the last current VMCS (shadow copy for ring-3).
501 * @see HMR0PERVCPU::vmx.fSwitchedToNstGstVmcs */
502 bool fSwitchedToNstGstVmcsCopyForRing3;
503 /** Whether the static guest VMCS controls has been merged with the
504 * nested-guest VMCS controls. */
505 bool fMergedNstGstCtls;
506 /** Whether the nested-guest VMCS has been copied to the shadow VMCS. */
507 bool fCopiedNstGstToShadowVmcs;
508 /** Whether flushing the TLB is required due to switching to/from the
509 * nested-guest. */
510 bool fSwitchedNstGstFlushTlb;
511 /** Alignment. */
512 bool afAlignment0[4];
513 /** Cached guest APIC-base MSR for identifying when to map the APIC-access page. */
514 uint64_t u64GstMsrApicBase;
515 /** @} */
516
517 /** @name Error reporting and diagnostics.
518 * @{ */
519 /** VT-x error-reporting (mainly for ring-3 propagation). */
520 struct
521 {
522 RTCPUID idCurrentCpu;
523 RTCPUID idEnteredCpu;
524 RTHCPHYS HCPhysCurrentVmcs;
525 uint32_t u32VmcsRev;
526 uint32_t u32InstrError;
527 uint32_t u32ExitReason;
528 uint32_t u32GuestIntrState;
529 } LastError;
530 /** @} */
531 } vmx;
532
533 /** Event injection state. */
534 HMEVENT Event;
535
536 /** Current shadow paging mode for updating CR4.
537 * @todo move later (@bugref{9217}). */
538 PGMMODE enmShadowMode;
539 uint32_t u32TemporaryPadding;
540
541 /** The PAE PDPEs used with Nested Paging (only valid when
542 * VMCPU_FF_HM_UPDATE_PAE_PDPES is set). */
543 X86PDPE aPdpes[4];
544 /** Pointer to the VMX statistics. */
545 PVMXSTATISTICS pVmxStats;
546
547 /** @name Statistics
548 * @{ */
549 STAMCOUNTER StatExitAll;
550 STAMCOUNTER StatBreakOnCancel;
551 STAMCOUNTER StatBreakOnFFPre;
552 STAMCOUNTER StatBreakOnFFPost;
553 STAMCOUNTER StatBreakOnStatus;
554 STAMCOUNTER StatImportOnDemand;
555 STAMCOUNTER StatImportOnReturn;
556 STAMCOUNTER StatImportOnReturnSkipped;
557 STAMCOUNTER StatQueryCpuTick;
558#ifdef VBOX_WITH_STATISTICS
559 STAMPROFILEADV StatProfGstStateImport;
560 STAMPROFILEADV StatProfGstStateExport;
561#endif
562 /** @} */
563
564 /** @} */
565#endif /* RT_OS_DARWIN */
566} NEMCPU;
567/** Pointer to NEM VMCPU instance data. */
568typedef NEMCPU *PNEMCPU;
569
570/** NEMCPU::u32Magic value. */
571#define NEMCPU_MAGIC UINT32_C(0x4d454e20)
572/** NEMCPU::u32Magic value after termination. */
573#define NEMCPU_MAGIC_DEAD UINT32_C(0xdead2222)
574
575
576#ifdef IN_RING0
577# ifdef RT_OS_WINDOWS
578/**
579 * Windows: Hypercall input/ouput page info.
580 */
581typedef struct NEMR0HYPERCALLDATA
582{
583 /** Host physical address of the hypercall input/output page. */
584 RTHCPHYS HCPhysPage;
585 /** Pointer to the hypercall input/output page. */
586 uint8_t *pbPage;
587 /** Handle to the memory object of the hypercall input/output page. */
588 RTR0MEMOBJ hMemObj;
589} NEMR0HYPERCALLDATA;
590/** Pointer to a Windows hypercall input/output page info. */
591typedef NEMR0HYPERCALLDATA *PNEMR0HYPERCALLDATA;
592# endif /* RT_OS_WINDOWS */
593
594/**
595 * NEM GVMCPU instance data.
596 */
597typedef struct NEMR0PERVCPU
598{
599 uint32_t uDummy;
600} NEMR0PERVCPU;
601
602/**
603 * NEM GVM instance data.
604 */
605typedef struct NEMR0PERVM
606{
607 uint32_t uDummy;
608} NEMR0PERVM;
609
610#endif /* IN_RING*/
611
612
613#ifdef IN_RING3
614int nemR3NativeInit(PVM pVM, bool fFallback, bool fForced);
615int nemR3NativeInitAfterCPUM(PVM pVM);
616int nemR3NativeInitCompleted(PVM pVM, VMINITCOMPLETED enmWhat);
617int nemR3NativeTerm(PVM pVM);
618void nemR3NativeReset(PVM pVM);
619void nemR3NativeResetCpu(PVMCPU pVCpu, bool fInitIpi);
620VBOXSTRICTRC nemR3NativeRunGC(PVM pVM, PVMCPU pVCpu);
621bool nemR3NativeCanExecuteGuest(PVM pVM, PVMCPU pVCpu);
622bool nemR3NativeSetSingleInstruction(PVM pVM, PVMCPU pVCpu, bool fEnable);
623void nemR3NativeNotifyFF(PVM pVM, PVMCPU pVCpu, uint32_t fFlags);
624#endif
625
626void nemHCNativeNotifyHandlerPhysicalRegister(PVMCC pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb);
627void nemHCNativeNotifyHandlerPhysicalModify(PVMCC pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhysOld,
628 RTGCPHYS GCPhysNew, RTGCPHYS cb, bool fRestoreAsRAM);
629int nemHCNativeNotifyPhysPageAllocated(PVMCC pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhys, uint32_t fPageProt,
630 PGMPAGETYPE enmType, uint8_t *pu2State);
631
632
633#ifdef RT_OS_WINDOWS
634/** Maximum number of pages we can map in a single NEMR0MapPages call. */
635# define NEM_MAX_MAP_PAGES ((PAGE_SIZE - RT_UOFFSETOF(HV_INPUT_MAP_GPA_PAGES, PageList)) / sizeof(HV_SPA_PAGE_NUMBER))
636/** Maximum number of pages we can unmap in a single NEMR0UnmapPages call. */
637# define NEM_MAX_UNMAP_PAGES 4095
638
639#endif
640/** @} */
641
642RT_C_DECLS_END
643
644#endif /* !VMM_INCLUDED_SRC_include_NEMInternal_h */
645
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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