VirtualBox

source: vbox/trunk/src/VBox/VMM/VMMAll/REMAll.cpp@ 19395

Last change on this file since 19395 was 19395, checked in by vboxsync, 16 years ago

GVMM,VM: Register the other EMTs or we assert painfully in gvmmR0ByVMAndEMT. A couple of todos and stuff.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.5 KB
Line 
1/* $Id: REMAll.cpp 19395 2009-05-05 20:28:42Z vboxsync $ */
2/** @file
3 * REM - Recompiled Execution Monitor, all Contexts part.
4 */
5
6/*
7 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
18 * Clara, CA 95054 USA or visit http://www.sun.com if you need
19 * additional information or have any questions.
20 */
21
22
23/*******************************************************************************
24* Global Variables *
25*******************************************************************************/
26#define LOG_GROUP LOG_GROUP_REM
27#include <VBox/rem.h>
28#include <VBox/vmm.h>
29#include "REMInternal.h"
30#include <VBox/vm.h>
31#include <VBox/err.h>
32#include <VBox/log.h>
33
34#include <iprt/assert.h>
35
36
37#ifndef IN_RING3
38
39/**
40 * Records a invlpg instruction for replaying upon REM entry.
41 *
42 * @returns VINF_SUCCESS on success.
43 * @returns VERR_REM_FLUSHED_PAGES_OVERFLOW if a return to HC for flushing of
44 * recorded pages is required before the call can succeed.
45 * @param pVM The VM handle.
46 * @param GCPtrPage The
47 */
48VMMDECL(int) REMNotifyInvalidatePage(PVM pVM, RTGCPTR GCPtrPage)
49{
50 if (pVM->rem.s.cInvalidatedPages < RT_ELEMENTS(pVM->rem.s.aGCPtrInvalidatedPages))
51 {
52 /*
53 * We sync them back in REMR3State.
54 */
55 pVM->rem.s.aGCPtrInvalidatedPages[pVM->rem.s.cInvalidatedPages++] = GCPtrPage;
56 }
57 else
58 {
59 /* Tell the recompiler to flush its TLB. */
60#ifndef DEBUG_bird /* temporary */
61 Assert(pVM->cCPUs == 1); /* @todo SMP */
62#endif
63 CPUMSetChangedFlags(VMMGetCpu(pVM), CPUM_CHANGED_GLOBAL_TLB_FLUSH);
64 pVM->rem.s.cInvalidatedPages = 0;
65 }
66
67 return VINF_SUCCESS;
68}
69
70
71/**
72 * Flushes the handler notifications by calling the host.
73 *
74 * @param pVM The VM handle.
75 */
76static void remFlushHandlerNotifications(PVM pVM)
77{
78#ifdef IN_RC
79 VMMGCCallHost(pVM, VMMCALLHOST_REM_REPLAY_HANDLER_NOTIFICATIONS, 0);
80#elif defined(IN_RING0)
81 /** @todo necessary? */
82 VMMR0CallHost(pVM, VMMCALLHOST_REM_REPLAY_HANDLER_NOTIFICATIONS, 0);
83#else
84 AssertReleaseMsgFailed(("Ring 3 call????.\n"));
85#endif
86 Assert(pVM->rem.s.cHandlerNotifications == 0);
87}
88
89
90/**
91 * Notification about a successful PGMR3HandlerPhysicalRegister() call.
92 *
93 * @param pVM VM Handle.
94 * @param enmType Handler type.
95 * @param GCPhys Handler range address.
96 * @param cb Size of the handler range.
97 * @param fHasHCHandler Set if the handler have a HC callback function.
98 */
99VMMDECL(void) REMNotifyHandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS cb, bool fHasHCHandler)
100{
101 if (pVM->rem.s.cHandlerNotifications >= RT_ELEMENTS(pVM->rem.s.aHandlerNotifications))
102 remFlushHandlerNotifications(pVM);
103 PREMHANDLERNOTIFICATION pRec = &pVM->rem.s.aHandlerNotifications[pVM->rem.s.cHandlerNotifications++];
104 pRec->enmKind = REMHANDLERNOTIFICATIONKIND_PHYSICAL_REGISTER;
105 pRec->u.PhysicalRegister.enmType = enmType;
106 pRec->u.PhysicalRegister.GCPhys = GCPhys;
107 pRec->u.PhysicalRegister.cb = cb;
108 pRec->u.PhysicalRegister.fHasHCHandler = fHasHCHandler;
109 VM_FF_SET(pVM, VM_FF_REM_HANDLER_NOTIFY);
110}
111
112
113/**
114 * Notification about a successful PGMR3HandlerPhysicalDeregister() operation.
115 *
116 * @param pVM VM Handle.
117 * @param enmType Handler type.
118 * @param GCPhys Handler range address.
119 * @param cb Size of the handler range.
120 * @param fHasHCHandler Set if the handler have a HC callback function.
121 * @param fRestoreAsRAM Whether the to restore it as normal RAM or as unassigned memory.
122 */
123VMMDECL(void) REMNotifyHandlerPhysicalDeregister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS cb, bool fHasHCHandler, bool fRestoreAsRAM)
124{
125 if (pVM->rem.s.cHandlerNotifications >= RT_ELEMENTS(pVM->rem.s.aHandlerNotifications))
126 remFlushHandlerNotifications(pVM);
127 PREMHANDLERNOTIFICATION pRec = &pVM->rem.s.aHandlerNotifications[pVM->rem.s.cHandlerNotifications++];
128 pRec->enmKind = REMHANDLERNOTIFICATIONKIND_PHYSICAL_DEREGISTER;
129 pRec->u.PhysicalDeregister.enmType = enmType;
130 pRec->u.PhysicalDeregister.GCPhys = GCPhys;
131 pRec->u.PhysicalDeregister.cb = cb;
132 pRec->u.PhysicalDeregister.fHasHCHandler = fHasHCHandler;
133 pRec->u.PhysicalDeregister.fRestoreAsRAM = fRestoreAsRAM;
134 VM_FF_SET(pVM, VM_FF_REM_HANDLER_NOTIFY);
135}
136
137
138/**
139 * Notification about a successful PGMR3HandlerPhysicalModify() call.
140 *
141 * @param pVM VM Handle.
142 * @param enmType Handler type.
143 * @param GCPhysOld Old handler range address.
144 * @param GCPhysNew New handler range address.
145 * @param cb Size of the handler range.
146 * @param fHasHCHandler Set if the handler have a HC callback function.
147 * @param fRestoreAsRAM Whether the to restore it as normal RAM or as unassigned memory.
148 */
149VMMDECL(void) REMNotifyHandlerPhysicalModify(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhysOld, RTGCPHYS GCPhysNew, RTGCPHYS cb, bool fHasHCHandler, bool fRestoreAsRAM)
150{
151 if (pVM->rem.s.cHandlerNotifications >= RT_ELEMENTS(pVM->rem.s.aHandlerNotifications))
152 remFlushHandlerNotifications(pVM);
153 PREMHANDLERNOTIFICATION pRec = &pVM->rem.s.aHandlerNotifications[pVM->rem.s.cHandlerNotifications++];
154 pRec->enmKind = REMHANDLERNOTIFICATIONKIND_PHYSICAL_MODIFY;
155 pRec->u.PhysicalModify.enmType = enmType;
156 pRec->u.PhysicalModify.GCPhysOld = GCPhysOld;
157 pRec->u.PhysicalModify.GCPhysNew = GCPhysNew;
158 pRec->u.PhysicalModify.cb = cb;
159 pRec->u.PhysicalModify.fHasHCHandler = fHasHCHandler;
160 pRec->u.PhysicalModify.fRestoreAsRAM = fRestoreAsRAM;
161 VM_FF_SET(pVM, VM_FF_REM_HANDLER_NOTIFY);
162}
163
164#endif /* !IN_RING3 */
165
166/**
167 * Make REM flush all translation block upon the next call to REMR3State().
168 *
169 * @param pVM Pointer to the shared VM structure.
170 */
171VMMDECL(void) REMFlushTBs(PVM pVM)
172{
173 LogFlow(("REMFlushTBs: fFlushTBs=%RTbool fInREM=%RTbool fInStateSync=%RTbool\n",
174 pVM->rem.s.fFlushTBs, pVM->rem.s.fInREM, pVM->rem.s.fInStateSync));
175 pVM->rem.s.fFlushTBs = true;
176}
177
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