VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMAll/NEMAll.cpp@ 74121

Last change on this file since 74121 was 72917, checked in by vboxsync, 6 years ago

NEM: Stop passing pCtx around and use pVCpu->cpum.GstCtx instead. bugref:9044

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.0 KB
Line 
1/* $Id: NEMAll.cpp 72917 2018-07-05 13:50:01Z 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 */
37VMM_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 */
53VMM_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
64VMM_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
76VMM_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
88VMM_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
101VMM_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
113VMM_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
126VMM_INT_DECL(int) NEMImportStateOnDemand(PVMCPU pVCpu, uint64_t fWhat)
127{
128 RT_NOREF(pVCpu, fWhat);
129 return VERR_NEM_IPE_9;
130}
131#endif
132
133
134#ifndef VBOX_WITH_NATIVE_NEM
135VMM_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
145VMM_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
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