VirtualBox

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

Last change on this file since 93732 was 93728, checked in by vboxsync, 3 years ago

VMM/NEMR3Native-darwin: Apple requires to bind to all MSRs related to the LBR feature if it is enabled, this includes the INFO MSRs as well as the MSR_LER_{TO,FROM}_IP MSRs, bugref:9044

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