1 | /* $Id: NEMAll.cpp 92449 2021-11-16 10:37:10Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * NEM - Native execution manager, R0 and R3 context code.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2018-2020 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 |
|
---|
19 | /*********************************************************************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *********************************************************************************************************************************/
|
---|
22 | #define LOG_GROUP LOG_GROUP_NEM
|
---|
23 | #include <VBox/vmm/nem.h>
|
---|
24 | #include "NEMInternal.h"
|
---|
25 | #include <VBox/vmm/vmcc.h>
|
---|
26 | #include <VBox/err.h>
|
---|
27 |
|
---|
28 |
|
---|
29 | /**
|
---|
30 | * Checks if this VM is in NEM mode and is long-mode capable.
|
---|
31 | *
|
---|
32 | * Use VMR3IsLongModeAllowed() instead of this, when possible.
|
---|
33 | *
|
---|
34 | * @returns true if long mode is allowed, false otherwise.
|
---|
35 | * @param pVM The cross context VM structure.
|
---|
36 | * @sa VMR3IsLongModeAllowed, HMIsLongModeAllowed
|
---|
37 | */
|
---|
38 | VMM_INT_DECL(bool) NEMHCIsLongModeAllowed(PVMCC pVM)
|
---|
39 | {
|
---|
40 | return pVM->nem.s.fAllow64BitGuests && VM_IS_NEM_ENABLED(pVM);
|
---|
41 | }
|
---|
42 |
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * Physical access handler registration notification.
|
---|
46 | *
|
---|
47 | * @param pVM The cross context VM structure.
|
---|
48 | * @param enmKind The kind of access handler.
|
---|
49 | * @param GCPhys Start of the access handling range.
|
---|
50 | * @param cb Length of the access handling range.
|
---|
51 | *
|
---|
52 | * @note Called while holding down the PGM lock.
|
---|
53 | */
|
---|
54 | VMM_INT_DECL(void) NEMHCNotifyHandlerPhysicalRegister(PVMCC pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb)
|
---|
55 | {
|
---|
56 | #ifdef VBOX_WITH_NATIVE_NEM
|
---|
57 | if (VM_IS_NEM_ENABLED(pVM))
|
---|
58 | nemHCNativeNotifyHandlerPhysicalRegister(pVM, enmKind, GCPhys, cb);
|
---|
59 | #else
|
---|
60 | RT_NOREF(pVM, enmKind, GCPhys, cb);
|
---|
61 | #endif
|
---|
62 | }
|
---|
63 |
|
---|
64 |
|
---|
65 | VMM_INT_DECL(void) NEMHCNotifyHandlerPhysicalModify(PVMCC pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhysOld,
|
---|
66 | RTGCPHYS GCPhysNew, RTGCPHYS cb, bool fRestoreAsRAM)
|
---|
67 | {
|
---|
68 | #ifdef VBOX_WITH_NATIVE_NEM
|
---|
69 | if (VM_IS_NEM_ENABLED(pVM))
|
---|
70 | nemHCNativeNotifyHandlerPhysicalModify(pVM, enmKind, GCPhysOld, GCPhysNew, cb, fRestoreAsRAM);
|
---|
71 | #else
|
---|
72 | RT_NOREF(pVM, enmKind, GCPhysOld, GCPhysNew, cb, fRestoreAsRAM);
|
---|
73 | #endif
|
---|
74 | }
|
---|
75 |
|
---|
76 |
|
---|
77 | VMM_INT_DECL(int) NEMHCNotifyPhysPageAllocated(PVMCC pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhys, uint32_t fPageProt,
|
---|
78 | PGMPAGETYPE enmType, uint8_t *pu2State)
|
---|
79 | {
|
---|
80 | Assert(VM_IS_NEM_ENABLED(pVM));
|
---|
81 | #ifdef VBOX_WITH_NATIVE_NEM
|
---|
82 | return nemHCNativeNotifyPhysPageAllocated(pVM, GCPhys, HCPhys, fPageProt, enmType, pu2State);
|
---|
83 | #else
|
---|
84 | RT_NOREF(pVM, GCPhys, HCPhys, fPageProt, enmType, pu2State);
|
---|
85 | return VINF_SUCCESS;
|
---|
86 | #endif
|
---|
87 | }
|
---|
88 |
|
---|
89 |
|
---|
90 | #ifndef VBOX_WITH_NATIVE_NEM
|
---|
91 | VMM_INT_DECL(uint32_t) NEMHCGetFeatures(PVMCC pVM)
|
---|
92 | {
|
---|
93 | RT_NOREF(pVM);
|
---|
94 | return 0;
|
---|
95 | }
|
---|
96 | #endif
|
---|
97 |
|
---|
98 |
|
---|
99 | #ifndef VBOX_WITH_NATIVE_NEM
|
---|
100 | VMM_INT_DECL(int) NEMImportStateOnDemand(PVMCPUCC pVCpu, uint64_t fWhat)
|
---|
101 | {
|
---|
102 | RT_NOREF(pVCpu, fWhat);
|
---|
103 | return VERR_NEM_IPE_9;
|
---|
104 | }
|
---|
105 | #endif
|
---|
106 |
|
---|
107 |
|
---|
108 | #ifndef VBOX_WITH_NATIVE_NEM
|
---|
109 | VMM_INT_DECL(int) NEMHCQueryCpuTick(PVMCPUCC pVCpu, uint64_t *pcTicks, uint32_t *puAux)
|
---|
110 | {
|
---|
111 | RT_NOREF(pVCpu, pcTicks, puAux);
|
---|
112 | AssertFailed();
|
---|
113 | return VERR_NEM_IPE_9;
|
---|
114 | }
|
---|
115 | #endif
|
---|
116 |
|
---|
117 |
|
---|
118 | #ifndef VBOX_WITH_NATIVE_NEM
|
---|
119 | VMM_INT_DECL(int) NEMHCResumeCpuTickOnAll(PVMCC pVM, PVMCPUCC pVCpu, uint64_t uPausedTscValue)
|
---|
120 | {
|
---|
121 | RT_NOREF(pVM, pVCpu, uPausedTscValue);
|
---|
122 | AssertFailed();
|
---|
123 | return VERR_NEM_IPE_9;
|
---|
124 | }
|
---|
125 | #endif
|
---|
126 |
|
---|