1 | /* $Id: NEMAll.cpp 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * NEM - Native execution manager, R0 and R3 context code.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2018-2024 Oracle and/or its affiliates.
|
---|
8 | *
|
---|
9 | * This file is part of VirtualBox base platform packages, as
|
---|
10 | * available from https://www.virtualbox.org.
|
---|
11 | *
|
---|
12 | * This program is free software; you can redistribute it and/or
|
---|
13 | * modify it under the terms of the GNU General Public License
|
---|
14 | * as published by the Free Software Foundation, in version 3 of the
|
---|
15 | * License.
|
---|
16 | *
|
---|
17 | * This program is distributed in the hope that it will be useful, but
|
---|
18 | * WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
20 | * General Public License for more details.
|
---|
21 | *
|
---|
22 | * You should have received a copy of the GNU General Public License
|
---|
23 | * along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
24 | *
|
---|
25 | * SPDX-License-Identifier: GPL-3.0-only
|
---|
26 | */
|
---|
27 |
|
---|
28 |
|
---|
29 | /*********************************************************************************************************************************
|
---|
30 | * Header Files *
|
---|
31 | *********************************************************************************************************************************/
|
---|
32 | #define LOG_GROUP LOG_GROUP_NEM
|
---|
33 | #include <VBox/vmm/nem.h>
|
---|
34 | #include "NEMInternal.h"
|
---|
35 | #include <VBox/vmm/vmcc.h>
|
---|
36 | #include <VBox/err.h>
|
---|
37 |
|
---|
38 |
|
---|
39 | /**
|
---|
40 | * Checks if this VM is in NEM mode and is long-mode capable.
|
---|
41 | *
|
---|
42 | * Use VMR3IsLongModeAllowed() instead of this, when possible.
|
---|
43 | *
|
---|
44 | * @returns true if long mode is allowed, false otherwise.
|
---|
45 | * @param pVM The cross context VM structure.
|
---|
46 | * @sa VMR3IsLongModeAllowed, HMIsLongModeAllowed
|
---|
47 | */
|
---|
48 | VMM_INT_DECL(bool) NEMHCIsLongModeAllowed(PVMCC pVM)
|
---|
49 | {
|
---|
50 | return pVM->nem.s.fAllow64BitGuests && VM_IS_NEM_ENABLED(pVM);
|
---|
51 | }
|
---|
52 |
|
---|
53 |
|
---|
54 | /**
|
---|
55 | * Physical access handler registration notification.
|
---|
56 | *
|
---|
57 | * @param pVM The cross context VM structure.
|
---|
58 | * @param enmKind The kind of access handler.
|
---|
59 | * @param GCPhys Start of the access handling range.
|
---|
60 | * @param cb Length of the access handling range.
|
---|
61 | *
|
---|
62 | * @note Called while holding down the PGM lock.
|
---|
63 | */
|
---|
64 | VMM_INT_DECL(void) NEMHCNotifyHandlerPhysicalRegister(PVMCC pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb)
|
---|
65 | {
|
---|
66 | #ifdef VBOX_WITH_NATIVE_NEM
|
---|
67 | if (VM_IS_NEM_ENABLED(pVM))
|
---|
68 | nemHCNativeNotifyHandlerPhysicalRegister(pVM, enmKind, GCPhys, cb);
|
---|
69 | #else
|
---|
70 | RT_NOREF(pVM, enmKind, GCPhys, cb);
|
---|
71 | #endif
|
---|
72 | }
|
---|
73 |
|
---|
74 |
|
---|
75 | VMM_INT_DECL(void) NEMHCNotifyHandlerPhysicalModify(PVMCC pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhysOld,
|
---|
76 | RTGCPHYS GCPhysNew, RTGCPHYS cb, bool fRestoreAsRAM)
|
---|
77 | {
|
---|
78 | #ifdef VBOX_WITH_NATIVE_NEM
|
---|
79 | if (VM_IS_NEM_ENABLED(pVM))
|
---|
80 | nemHCNativeNotifyHandlerPhysicalModify(pVM, enmKind, GCPhysOld, GCPhysNew, cb, fRestoreAsRAM);
|
---|
81 | #else
|
---|
82 | RT_NOREF(pVM, enmKind, GCPhysOld, GCPhysNew, cb, fRestoreAsRAM);
|
---|
83 | #endif
|
---|
84 | }
|
---|
85 |
|
---|
86 |
|
---|
87 | VMM_INT_DECL(int) NEMHCNotifyPhysPageAllocated(PVMCC pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhys, uint32_t fPageProt,
|
---|
88 | PGMPAGETYPE enmType, uint8_t *pu2State)
|
---|
89 | {
|
---|
90 | Assert(VM_IS_NEM_ENABLED(pVM));
|
---|
91 | #ifdef VBOX_WITH_NATIVE_NEM
|
---|
92 | return nemHCNativeNotifyPhysPageAllocated(pVM, GCPhys, HCPhys, fPageProt, enmType, pu2State);
|
---|
93 | #else
|
---|
94 | RT_NOREF(pVM, GCPhys, HCPhys, fPageProt, enmType, pu2State);
|
---|
95 | return VINF_SUCCESS;
|
---|
96 | #endif
|
---|
97 | }
|
---|
98 |
|
---|
99 |
|
---|
100 | #ifndef VBOX_WITH_NATIVE_NEM
|
---|
101 | VMM_INT_DECL(uint32_t) NEMHCGetFeatures(PVMCC pVM)
|
---|
102 | {
|
---|
103 | RT_NOREF(pVM);
|
---|
104 | return 0;
|
---|
105 | }
|
---|
106 | #endif
|
---|
107 |
|
---|
108 |
|
---|
109 | #ifndef VBOX_WITH_NATIVE_NEM
|
---|
110 | VMM_INT_DECL(int) NEMImportStateOnDemand(PVMCPUCC pVCpu, uint64_t fWhat)
|
---|
111 | {
|
---|
112 | RT_NOREF(pVCpu, fWhat);
|
---|
113 | return VERR_NEM_IPE_9;
|
---|
114 | }
|
---|
115 | #endif
|
---|
116 |
|
---|
117 |
|
---|
118 | #ifndef VBOX_WITH_NATIVE_NEM
|
---|
119 | VMM_INT_DECL(int) NEMHCQueryCpuTick(PVMCPUCC pVCpu, uint64_t *pcTicks, uint32_t *puAux)
|
---|
120 | {
|
---|
121 | RT_NOREF(pVCpu, pcTicks, puAux);
|
---|
122 | AssertFailed();
|
---|
123 | return VERR_NEM_IPE_9;
|
---|
124 | }
|
---|
125 | #endif
|
---|
126 |
|
---|
127 |
|
---|
128 | #ifndef VBOX_WITH_NATIVE_NEM
|
---|
129 | VMM_INT_DECL(int) NEMHCResumeCpuTickOnAll(PVMCC pVM, PVMCPUCC pVCpu, uint64_t uPausedTscValue)
|
---|
130 | {
|
---|
131 | RT_NOREF(pVM, pVCpu, uPausedTscValue);
|
---|
132 | AssertFailed();
|
---|
133 | return VERR_NEM_IPE_9;
|
---|
134 | }
|
---|
135 | #endif
|
---|
136 |
|
---|