1 | /* $Id: NEMAll.cpp 76553 2019-01-01 01:45:53Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * NEM - Native execution manager, R0 and R3 context code.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2018-2019 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/vm.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(PVM 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(PVM 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) NEMHCNotifyHandlerPhysicalDeregister(PVM pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb,
|
---|
66 | int fRestoreAsRAM, bool fRestoreAsRAM2)
|
---|
67 | {
|
---|
68 | #ifdef VBOX_WITH_NATIVE_NEM
|
---|
69 | if (VM_IS_NEM_ENABLED(pVM))
|
---|
70 | nemHCNativeNotifyHandlerPhysicalDeregister(pVM, enmKind, GCPhys, cb, fRestoreAsRAM, fRestoreAsRAM2);
|
---|
71 | #else
|
---|
72 | RT_NOREF(pVM, enmKind, GCPhys, cb, fRestoreAsRAM, fRestoreAsRAM2);
|
---|
73 | #endif
|
---|
74 | }
|
---|
75 |
|
---|
76 |
|
---|
77 | VMM_INT_DECL(void) NEMHCNotifyHandlerPhysicalModify(PVM pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhysOld,
|
---|
78 | RTGCPHYS GCPhysNew, RTGCPHYS cb, bool fRestoreAsRAM)
|
---|
79 | {
|
---|
80 | #ifdef VBOX_WITH_NATIVE_NEM
|
---|
81 | if (VM_IS_NEM_ENABLED(pVM))
|
---|
82 | nemHCNativeNotifyHandlerPhysicalModify(pVM, enmKind, GCPhysOld, GCPhysNew, cb, fRestoreAsRAM);
|
---|
83 | #else
|
---|
84 | RT_NOREF(pVM, enmKind, GCPhysOld, GCPhysNew, cb, fRestoreAsRAM);
|
---|
85 | #endif
|
---|
86 | }
|
---|
87 |
|
---|
88 |
|
---|
89 | VMM_INT_DECL(int) NEMHCNotifyPhysPageAllocated(PVM pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhys, uint32_t fPageProt,
|
---|
90 | PGMPAGETYPE enmType, uint8_t *pu2State)
|
---|
91 | {
|
---|
92 | Assert(VM_IS_NEM_ENABLED(pVM));
|
---|
93 | #ifdef VBOX_WITH_NATIVE_NEM
|
---|
94 | return nemHCNativeNotifyPhysPageAllocated(pVM, GCPhys, HCPhys, fPageProt, enmType, pu2State);
|
---|
95 | #else
|
---|
96 | RT_NOREF(pVM, GCPhys, HCPhys, fPageProt, enmType, pu2State);
|
---|
97 | return VINF_SUCCESS;
|
---|
98 | #endif
|
---|
99 | }
|
---|
100 |
|
---|
101 |
|
---|
102 | VMM_INT_DECL(void) NEMHCNotifyPhysPageProtChanged(PVM pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhys, uint32_t fPageProt,
|
---|
103 | PGMPAGETYPE enmType, uint8_t *pu2State)
|
---|
104 | {
|
---|
105 | Assert(VM_IS_NEM_ENABLED(pVM));
|
---|
106 | #ifdef VBOX_WITH_NATIVE_NEM
|
---|
107 | nemHCNativeNotifyPhysPageProtChanged(pVM, GCPhys, HCPhys, fPageProt, enmType, pu2State);
|
---|
108 | #else
|
---|
109 | RT_NOREF(pVM, GCPhys, HCPhys, fPageProt, enmType, pu2State);
|
---|
110 | #endif
|
---|
111 | }
|
---|
112 |
|
---|
113 |
|
---|
114 | VMM_INT_DECL(void) NEMHCNotifyPhysPageChanged(PVM pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhysPrev, RTHCPHYS HCPhysNew,
|
---|
115 | uint32_t fPageProt, PGMPAGETYPE enmType, uint8_t *pu2State)
|
---|
116 | {
|
---|
117 | Assert(VM_IS_NEM_ENABLED(pVM));
|
---|
118 | #ifdef VBOX_WITH_NATIVE_NEM
|
---|
119 | nemHCNativeNotifyPhysPageChanged(pVM, GCPhys, HCPhysPrev, HCPhysNew, fPageProt, enmType, pu2State);
|
---|
120 | #else
|
---|
121 | RT_NOREF(pVM, GCPhys, HCPhysPrev, HCPhysNew, fPageProt, enmType, pu2State);
|
---|
122 | #endif
|
---|
123 | }
|
---|
124 |
|
---|
125 |
|
---|
126 | #ifndef VBOX_WITH_NATIVE_NEM
|
---|
127 | VMM_INT_DECL(int) NEMImportStateOnDemand(PVMCPU pVCpu, uint64_t fWhat)
|
---|
128 | {
|
---|
129 | RT_NOREF(pVCpu, fWhat);
|
---|
130 | return VERR_NEM_IPE_9;
|
---|
131 | }
|
---|
132 | #endif
|
---|
133 |
|
---|
134 |
|
---|
135 | #ifndef VBOX_WITH_NATIVE_NEM
|
---|
136 | VMM_INT_DECL(int) NEMHCQueryCpuTick(PVMCPU pVCpu, uint64_t *pcTicks, uint32_t *puAux)
|
---|
137 | {
|
---|
138 | RT_NOREF(pVCpu, pcTicks, puAux);
|
---|
139 | AssertFailed();
|
---|
140 | return VERR_NEM_IPE_9;
|
---|
141 | }
|
---|
142 | #endif
|
---|
143 |
|
---|
144 |
|
---|
145 | #ifndef VBOX_WITH_NATIVE_NEM
|
---|
146 | VMM_INT_DECL(int) NEMHCResumeCpuTickOnAll(PVM pVM, PVMCPU pVCpu, uint64_t uPausedTscValue)
|
---|
147 | {
|
---|
148 | RT_NOREF(pVM, pVCpu, uPausedTscValue);
|
---|
149 | AssertFailed();
|
---|
150 | return VERR_NEM_IPE_9;
|
---|
151 | }
|
---|
152 | #endif
|
---|
153 |
|
---|