1 | /* $Id: NEMAll.cpp 72546 2018-06-13 15:45:39Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * NEM - Native execution manager, R0 and R3 context code.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2018 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 |
|
---|
27 |
|
---|
28 | /**
|
---|
29 | * Checks if this VM is in NEM mode and is long-mode capable.
|
---|
30 | *
|
---|
31 | * Use VMR3IsLongModeAllowed() instead of this, when possible.
|
---|
32 | *
|
---|
33 | * @returns true if long mode is allowed, false otherwise.
|
---|
34 | * @param pVM The cross context VM structure.
|
---|
35 | * @sa VMR3IsLongModeAllowed, HMIsLongModeAllowed
|
---|
36 | */
|
---|
37 | VMM_INT_DECL(bool) NEMHCIsLongModeAllowed(PVM pVM)
|
---|
38 | {
|
---|
39 | return pVM->nem.s.fAllow64BitGuests && VM_IS_NEM_ENABLED(pVM);
|
---|
40 | }
|
---|
41 |
|
---|
42 |
|
---|
43 | /**
|
---|
44 | * Physical access handler registration notification.
|
---|
45 | *
|
---|
46 | * @param pVM The cross context VM structure.
|
---|
47 | * @param enmKind The kind of access handler.
|
---|
48 | * @param GCPhys Start of the access handling range.
|
---|
49 | * @param cb Length of the access handling range.
|
---|
50 | *
|
---|
51 | * @note Called while holding down the PGM lock.
|
---|
52 | */
|
---|
53 | VMM_INT_DECL(void) NEMHCNotifyHandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb)
|
---|
54 | {
|
---|
55 | #ifdef VBOX_WITH_NATIVE_NEM
|
---|
56 | if (VM_IS_NEM_ENABLED(pVM))
|
---|
57 | nemHCNativeNotifyHandlerPhysicalRegister(pVM, enmKind, GCPhys, cb);
|
---|
58 | #else
|
---|
59 | RT_NOREF(pVM, enmKind, GCPhys, cb);
|
---|
60 | #endif
|
---|
61 | }
|
---|
62 |
|
---|
63 |
|
---|
64 | VMM_INT_DECL(void) NEMHCNotifyHandlerPhysicalDeregister(PVM pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb,
|
---|
65 | int fRestoreAsRAM, bool fRestoreAsRAM2)
|
---|
66 | {
|
---|
67 | #ifdef VBOX_WITH_NATIVE_NEM
|
---|
68 | if (VM_IS_NEM_ENABLED(pVM))
|
---|
69 | nemHCNativeNotifyHandlerPhysicalDeregister(pVM, enmKind, GCPhys, cb, fRestoreAsRAM, fRestoreAsRAM2);
|
---|
70 | #else
|
---|
71 | RT_NOREF(pVM, enmKind, GCPhys, cb, fRestoreAsRAM, fRestoreAsRAM2);
|
---|
72 | #endif
|
---|
73 | }
|
---|
74 |
|
---|
75 |
|
---|
76 | VMM_INT_DECL(void) NEMHCNotifyHandlerPhysicalModify(PVM pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhysOld,
|
---|
77 | RTGCPHYS GCPhysNew, RTGCPHYS cb, bool fRestoreAsRAM)
|
---|
78 | {
|
---|
79 | #ifdef VBOX_WITH_NATIVE_NEM
|
---|
80 | if (VM_IS_NEM_ENABLED(pVM))
|
---|
81 | nemHCNativeNotifyHandlerPhysicalModify(pVM, enmKind, GCPhysOld, GCPhysNew, cb, fRestoreAsRAM);
|
---|
82 | #else
|
---|
83 | RT_NOREF(pVM, enmKind, GCPhysOld, GCPhysNew, cb, fRestoreAsRAM);
|
---|
84 | #endif
|
---|
85 | }
|
---|
86 |
|
---|
87 |
|
---|
88 | VMM_INT_DECL(int) NEMHCNotifyPhysPageAllocated(PVM pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhys, uint32_t fPageProt,
|
---|
89 | PGMPAGETYPE enmType, uint8_t *pu2State)
|
---|
90 | {
|
---|
91 | Assert(VM_IS_NEM_ENABLED(pVM));
|
---|
92 | #ifdef VBOX_WITH_NATIVE_NEM
|
---|
93 | return nemHCNativeNotifyPhysPageAllocated(pVM, GCPhys, HCPhys, fPageProt, enmType, pu2State);
|
---|
94 | #else
|
---|
95 | RT_NOREF(pVM, GCPhys, HCPhys, fPageProt, enmType, pu2State);
|
---|
96 | return VINF_SUCCESS;
|
---|
97 | #endif
|
---|
98 | }
|
---|
99 |
|
---|
100 |
|
---|
101 | VMM_INT_DECL(void) NEMHCNotifyPhysPageProtChanged(PVM pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhys, uint32_t fPageProt,
|
---|
102 | PGMPAGETYPE enmType, uint8_t *pu2State)
|
---|
103 | {
|
---|
104 | Assert(VM_IS_NEM_ENABLED(pVM));
|
---|
105 | #ifdef VBOX_WITH_NATIVE_NEM
|
---|
106 | nemHCNativeNotifyPhysPageProtChanged(pVM, GCPhys, HCPhys, fPageProt, enmType, pu2State);
|
---|
107 | #else
|
---|
108 | RT_NOREF(pVM, GCPhys, HCPhys, fPageProt, enmType, pu2State);
|
---|
109 | #endif
|
---|
110 | }
|
---|
111 |
|
---|
112 |
|
---|
113 | VMM_INT_DECL(void) NEMHCNotifyPhysPageChanged(PVM pVM, RTGCPHYS GCPhys, RTHCPHYS HCPhysPrev, RTHCPHYS HCPhysNew,
|
---|
114 | uint32_t fPageProt, PGMPAGETYPE enmType, uint8_t *pu2State)
|
---|
115 | {
|
---|
116 | Assert(VM_IS_NEM_ENABLED(pVM));
|
---|
117 | #ifdef VBOX_WITH_NATIVE_NEM
|
---|
118 | nemHCNativeNotifyPhysPageChanged(pVM, GCPhys, HCPhysPrev, HCPhysNew, fPageProt, enmType, pu2State);
|
---|
119 | #else
|
---|
120 | RT_NOREF(pVM, GCPhys, HCPhysPrev, HCPhysNew, fPageProt, enmType, pu2State);
|
---|
121 | #endif
|
---|
122 | }
|
---|
123 |
|
---|
124 |
|
---|
125 | #ifndef VBOX_WITH_NATIVE_NEM
|
---|
126 | VMM_INT_DECL(int) NEMImportStateOnDemand(PVMCPU pVCpu, PCPUMCTX pCtx, uint64_t fWhat)
|
---|
127 | {
|
---|
128 | RT_NOREF(pVCpu, pCtx, fWhat);
|
---|
129 | return VERR_NEM_IPE_9;
|
---|
130 | }
|
---|
131 | #endif
|
---|
132 |
|
---|
133 |
|
---|
134 | #ifndef VBOX_WITH_NATIVE_NEM
|
---|
135 | VMM_INT_DECL(int) NEMHCQueryCpuTick(PVMCPU pVCpu, uint64_t *pcTicks, uint32_t *puAux)
|
---|
136 | {
|
---|
137 | RT_NOREF(pVCpu, pcTicks, puAux);
|
---|
138 | AssertFailed();
|
---|
139 | return VERR_NEM_IPE_9;
|
---|
140 | }
|
---|
141 | #endif
|
---|
142 |
|
---|
143 |
|
---|
144 | #ifndef VBOX_WITH_NATIVE_NEM
|
---|
145 | VMM_INT_DECL(int) NEMHCResumeCpuTickOnAll(PVM pVM, PVMCPU pVCpu, uint64_t uPausedTscValue)
|
---|
146 | {
|
---|
147 | RT_NOREF(pVM, pVCpu, uPausedTscValue);
|
---|
148 | AssertFailed();
|
---|
149 | return VERR_NEM_IPE_9;
|
---|
150 | }
|
---|
151 | #endif
|
---|
152 |
|
---|