VirtualBox

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

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

VMM + VBox/cdefs.h: consolidated all the XYZ*DECLS of the VMM into VMM*DECL. Removed dead DECL and IN_XYZ* macros.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 6.0 KB
Line 
1/* $Id: REMAll.cpp 12989 2008-10-06 02:15:39Z 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/**
38 * Records a invlpg instruction for replaying upon REM entry.
39 *
40 * @returns VINF_SUCCESS on success.
41 * @returns VERR_REM_FLUSHED_PAGES_OVERFLOW if a return to HC for flushing of
42 * recorded pages is required before the call can succeed.
43 * @param pVM The VM handle.
44 * @param GCPtrPage The
45 */
46VMMDECL(int) REMNotifyInvalidatePage(PVM pVM, RTGCPTR GCPtrPage)
47{
48 if (pVM->rem.s.cInvalidatedPages < RT_ELEMENTS(pVM->rem.s.aGCPtrInvalidatedPages))
49 {
50 /*
51 * We sync them back in REMR3State.
52 */
53 pVM->rem.s.aGCPtrInvalidatedPages[pVM->rem.s.cInvalidatedPages++] = GCPtrPage;
54 }
55 else
56 {
57 /* Tell the recompiler to flush its TLB. */
58 CPUMSetChangedFlags(pVM, CPUM_CHANGED_GLOBAL_TLB_FLUSH);
59 pVM->rem.s.cInvalidatedPages = 0;
60 }
61
62 return VINF_SUCCESS;
63}
64
65
66/**
67 * Flushes the handler notifications by calling the host.
68 *
69 * @param pVM The VM handle.
70 */
71static void remFlushHandlerNotifications(PVM pVM)
72{
73#ifdef IN_GC
74 VMMGCCallHost(pVM, VMMCALLHOST_REM_REPLAY_HANDLER_NOTIFICATIONS, 0);
75#elif defined(IN_RING0)
76 /** @todo necessary? */
77 VMMR0CallHost(pVM, VMMCALLHOST_REM_REPLAY_HANDLER_NOTIFICATIONS, 0);
78#else
79 AssertReleaseMsgFailed(("Ring 3 call????.\n"));
80#endif
81 Assert(pVM->rem.s.cHandlerNotifications == 0);
82}
83
84
85/**
86 * Notification about a successful PGMR3HandlerPhysicalRegister() call.
87 *
88 * @param pVM VM Handle.
89 * @param enmType Handler type.
90 * @param GCPhys Handler range address.
91 * @param cb Size of the handler range.
92 * @param fHasHCHandler Set if the handler have a HC callback function.
93 */
94VMMDECL(void) REMNotifyHandlerPhysicalRegister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS cb, bool fHasHCHandler)
95{
96 if (pVM->rem.s.cHandlerNotifications >= RT_ELEMENTS(pVM->rem.s.aHandlerNotifications))
97 remFlushHandlerNotifications(pVM);
98 PREMHANDLERNOTIFICATION pRec = &pVM->rem.s.aHandlerNotifications[pVM->rem.s.cHandlerNotifications++];
99 pRec->enmKind = REMHANDLERNOTIFICATIONKIND_PHYSICAL_REGISTER;
100 pRec->u.PhysicalRegister.enmType = enmType;
101 pRec->u.PhysicalRegister.GCPhys = GCPhys;
102 pRec->u.PhysicalRegister.cb = cb;
103 pRec->u.PhysicalRegister.fHasHCHandler = fHasHCHandler;
104 VM_FF_SET(pVM, VM_FF_REM_HANDLER_NOTIFY);
105}
106
107
108/**
109 * Notification about a successful PGMR3HandlerPhysicalDeregister() operation.
110 *
111 * @param pVM VM Handle.
112 * @param enmType Handler type.
113 * @param GCPhys Handler range address.
114 * @param cb Size of the handler range.
115 * @param fHasHCHandler Set if the handler have a HC callback function.
116 * @param fRestoreAsRAM Whether the to restore it as normal RAM or as unassigned memory.
117 */
118VMMDECL(void) REMNotifyHandlerPhysicalDeregister(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhys, RTGCPHYS cb, bool fHasHCHandler, bool fRestoreAsRAM)
119{
120 if (pVM->rem.s.cHandlerNotifications >= RT_ELEMENTS(pVM->rem.s.aHandlerNotifications))
121 remFlushHandlerNotifications(pVM);
122 PREMHANDLERNOTIFICATION pRec = &pVM->rem.s.aHandlerNotifications[pVM->rem.s.cHandlerNotifications++];
123 pRec->enmKind = REMHANDLERNOTIFICATIONKIND_PHYSICAL_DEREGISTER;
124 pRec->u.PhysicalDeregister.enmType = enmType;
125 pRec->u.PhysicalDeregister.GCPhys = GCPhys;
126 pRec->u.PhysicalDeregister.cb = cb;
127 pRec->u.PhysicalDeregister.fHasHCHandler = fHasHCHandler;
128 pRec->u.PhysicalDeregister.fRestoreAsRAM = fRestoreAsRAM;
129 VM_FF_SET(pVM, VM_FF_REM_HANDLER_NOTIFY);
130}
131
132
133/**
134 * Notification about a successful PGMR3HandlerPhysicalModify() call.
135 *
136 * @param pVM VM Handle.
137 * @param enmType Handler type.
138 * @param GCPhysOld Old handler range address.
139 * @param GCPhysNew New handler range address.
140 * @param cb Size of the handler range.
141 * @param fHasHCHandler Set if the handler have a HC callback function.
142 * @param fRestoreAsRAM Whether the to restore it as normal RAM or as unassigned memory.
143 */
144VMMDECL(void) REMNotifyHandlerPhysicalModify(PVM pVM, PGMPHYSHANDLERTYPE enmType, RTGCPHYS GCPhysOld, RTGCPHYS GCPhysNew, RTGCPHYS cb, bool fHasHCHandler, bool fRestoreAsRAM)
145{
146 if (pVM->rem.s.cHandlerNotifications >= RT_ELEMENTS(pVM->rem.s.aHandlerNotifications))
147 remFlushHandlerNotifications(pVM);
148 PREMHANDLERNOTIFICATION pRec = &pVM->rem.s.aHandlerNotifications[pVM->rem.s.cHandlerNotifications++];
149 pRec->enmKind = REMHANDLERNOTIFICATIONKIND_PHYSICAL_MODIFY;
150 pRec->u.PhysicalModify.enmType = enmType;
151 pRec->u.PhysicalModify.GCPhysOld = GCPhysOld;
152 pRec->u.PhysicalModify.GCPhysNew = GCPhysNew;
153 pRec->u.PhysicalModify.cb = cb;
154 pRec->u.PhysicalModify.fHasHCHandler = fHasHCHandler;
155 pRec->u.PhysicalModify.fRestoreAsRAM = fRestoreAsRAM;
156 VM_FF_SET(pVM, VM_FF_REM_HANDLER_NOTIFY);
157}
158
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