VirtualBox

source: vbox/trunk/src/VBox/VMM/PGMShw.h@ 872

Last change on this file since 872 was 23, checked in by vboxsync, 18 years ago

string.h & stdio.h + header cleanups.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.6 KB
Line 
1/* $Id: PGMShw.h 23 2007-01-15 14:08:28Z vboxsync $ */
2/** @file
3 * VBox - Page Manager / Monitor, Shadow Paging Template.
4 */
5
6/*
7 * Copyright (C) 2006 InnoTek Systemberatung GmbH
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 as published by the Free Software Foundation,
13 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
14 * distribution. VirtualBox OSE is distributed in the hope that it will
15 * be useful, but WITHOUT ANY WARRANTY of any kind.
16 *
17 * If you received this file as part of a commercial VirtualBox
18 * distribution, then only the terms of your commercial VirtualBox
19 * license agreement apply instead of the previous paragraph.
20 */
21
22/*******************************************************************************
23* Defined Constants And Macros *
24*******************************************************************************/
25#undef SHWPT
26#undef PSHWPT
27#undef SHWPTE
28#undef PSHWPTE
29#undef SHWPD
30#undef PSHWPD
31#undef SHWPDE
32#undef PSHWPDE
33#undef SHW_PDE_PG_MASK
34#undef SHW_PD_SHIFT
35#undef SHW_PD_MASK
36#undef SHW_PTE_PG_MASK
37#undef SHW_PT_SHIFT
38#undef SHW_PT_MASK
39#undef SHW_POOL_ROOT_IDX
40
41#if PGM_SHW_TYPE == PGM_TYPE_32BIT
42# define SHWPT X86PT
43# define PSHWPT PX86PT
44# define SHWPTE X86PTE
45# define PSHWPTE PX86PTE
46# define SHWPD X86PD
47# define PSHWPD PX86PD
48# define SHWPDE X86PDE
49# define PSHWPDE PX86PDE
50# define SHW_PDE_PG_MASK X86_PDE_PG_MASK
51# define SHW_PD_SHIFT X86_PD_SHIFT
52# define SHW_PD_MASK X86_PD_MASK
53# define SHW_PTE_PG_MASK X86_PTE_PG_MASK
54# define SHW_PT_SHIFT X86_PT_SHIFT
55# define SHW_PT_MASK X86_PT_MASK
56# define SHW_POOL_ROOT_IDX PGMPOOL_IDX_PD
57#else
58# define SHWPT X86PTPAE
59# define PSHWPT PX86PTPAE
60# define SHWPTE X86PTEPAE
61# define PSHWPTE PX86PTEPAE
62# define SHWPD X86PDPAE
63# define PSHWPD PX86PDPAE
64# define SHWPDE X86PDEPAE
65# define PSHWPDE PX86PDEPAE
66# define SHW_PDE_PG_MASK X86_PDE_PAE_PG_MASK
67# define SHW_PD_SHIFT X86_PD_PAE_SHIFT
68# define SHW_PD_MASK X86_PD_PAE_MASK
69# define SHW_PTE_PG_MASK X86_PTE_PAE_PG_MASK
70# define SHW_PT_SHIFT X86_PT_PAE_SHIFT
71# define SHW_PT_MASK X86_PT_PAE_MASK
72# define SHW_POOL_ROOT_IDX PGMPOOL_IDX_PAE_PD
73#endif
74
75
76/*******************************************************************************
77* Internal Functions *
78*******************************************************************************/
79__BEGIN_DECLS
80/* r3 */
81PGM_SHW_DECL(int, InitData)(PVM pVM, PPGMMODEDATA pModeData, bool fResolveGCAndR0);
82PGM_SHW_DECL(int, Enter)(PVM pVM);
83PGM_SHW_DECL(int, Relocate)(PVM pVM, RTGCUINTPTR offDelta);
84PGM_SHW_DECL(int, Exit)(PVM pVM);
85
86/* all */
87PGM_SHW_DECL(int, GetPage)(PVM pVM, RTGCUINTPTR GCPtr, uint64_t *pfFlags, PRTHCPHYS pHCPhys);
88PGM_SHW_DECL(int, ModifyPage)(PVM pVM, RTGCUINTPTR GCPtr, size_t cb, uint64_t fFlags, uint64_t fMask);
89PGM_SHW_DECL(int, GetPDEByIndex)(PVM pVM, uint32_t iPD, PX86PDEPAE pPde);
90PGM_SHW_DECL(int, SetPDEByIndex)(PVM pVM, uint32_t iPD, X86PDEPAE Pde);
91PGM_SHW_DECL(int, ModifyPDEByIndex)(PVM pVM, uint32_t iPD, uint64_t fFlags, uint64_t fMask);
92__END_DECLS
93
94
95/**
96 * Initializes the guest bit of the paging mode data.
97 *
98 * @returns VBox status code.
99 * @param pVM The VM handle.
100 * @param fResolveGCAndR0 Indicate whether or not GC and Ring-0 symbols can be resolved now.
101 * This is used early in the init process to avoid trouble with PDM
102 * not being initialized yet.
103 */
104PGM_SHW_DECL(int, InitData)(PVM pVM, PPGMMODEDATA pModeData, bool fResolveGCAndR0)
105{
106 Assert(pModeData->uShwType == PGM_SHW_TYPE);
107
108 /* Ring-3 */
109 pModeData->pfnR3ShwRelocate = PGM_SHW_NAME(Relocate);
110 pModeData->pfnR3ShwExit = PGM_SHW_NAME(Exit);
111 pModeData->pfnR3ShwGetPage = PGM_SHW_NAME(GetPage);
112 pModeData->pfnR3ShwModifyPage = PGM_SHW_NAME(ModifyPage);
113 pModeData->pfnR3ShwGetPDEByIndex = PGM_SHW_NAME(GetPDEByIndex);
114 pModeData->pfnR3ShwSetPDEByIndex = PGM_SHW_NAME(SetPDEByIndex);
115 pModeData->pfnR3ShwModifyPDEByIndex = PGM_SHW_NAME(ModifyPDEByIndex);
116
117 if (fResolveGCAndR0)
118 {
119 int rc;
120
121 /* GC */
122 rc = PDMR3GetSymbolGC(pVM, NULL, PGM_SHW_NAME_GC_STR(GetPage), &pModeData->pfnGCShwGetPage);
123 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_GC_STR(GetPage), rc), rc);
124 rc = PDMR3GetSymbolGC(pVM, NULL, PGM_SHW_NAME_GC_STR(ModifyPage), &pModeData->pfnGCShwModifyPage);
125 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_GC_STR(ModifyPage), rc), rc);
126 rc = PDMR3GetSymbolGC(pVM, NULL, PGM_SHW_NAME_GC_STR(GetPDEByIndex), &pModeData->pfnGCShwGetPDEByIndex);
127 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_GC_STR(GetPDEByIndex), rc), rc);
128 rc = PDMR3GetSymbolGC(pVM, NULL, PGM_SHW_NAME_GC_STR(SetPDEByIndex), &pModeData->pfnGCShwSetPDEByIndex);
129 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_GC_STR(SetPDEByIndex), rc), rc);
130 rc = PDMR3GetSymbolGC(pVM, NULL, PGM_SHW_NAME_GC_STR(ModifyPDEByIndex), &pModeData->pfnGCShwModifyPDEByIndex);
131 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_GC_STR(ModifyPDEByIndex), rc), rc);
132
133 /* Ring-0 */
134 rc = PDMR3GetSymbolR0(pVM, NULL, PGM_SHW_NAME_R0_STR(GetPage), (void **)&pModeData->pfnR0ShwGetPage);
135 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_R0_STR(GetPage), rc), rc);
136 rc = PDMR3GetSymbolR0(pVM, NULL, PGM_SHW_NAME_R0_STR(ModifyPage), (void **)&pModeData->pfnR0ShwModifyPage);
137 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_R0_STR(ModifyPage), rc), rc);
138 rc = PDMR3GetSymbolR0(pVM, NULL, PGM_SHW_NAME_R0_STR(GetPDEByIndex), (void **)&pModeData->pfnR0ShwGetPDEByIndex);
139 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_R0_STR(GetPDEByIndex), rc), rc);
140 rc = PDMR3GetSymbolR0(pVM, NULL, PGM_SHW_NAME_R0_STR(SetPDEByIndex), (void **)&pModeData->pfnR0ShwSetPDEByIndex);
141 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_R0_STR(SetPDEByIndex), rc), rc);
142 rc = PDMR3GetSymbolR0(pVM, NULL, PGM_SHW_NAME_R0_STR(ModifyPDEByIndex), (void **)&pModeData->pfnR0ShwModifyPDEByIndex);
143 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_R0_STR(ModifyPDEByIndex), rc), rc);
144 }
145 return VINF_SUCCESS;
146}
147
148/**
149 * Enters the shadow mode.
150 *
151 * @returns VBox status code.
152 * @param pVM VM handle.
153 */
154PGM_SHW_DECL(int, Enter)(PVM pVM)
155{
156#if PGM_SHW_MODE == PGM_MODE_AMD64
157 /*
158 * Set the RW, US and A flags for the fixed PDPEs.
159 */
160#endif
161 return VINF_SUCCESS;
162}
163
164
165/**
166 * Relocate any GC pointers related to shadow mode paging.
167 *
168 * @returns VBox status code.
169 * @param pVM The VM handle.
170 * @param offDelta The reloation offset.
171 */
172PGM_SHW_DECL(int, Relocate)(PVM pVM, RTGCUINTPTR offDelta)
173{
174 /* nothing special to do here - InitData does the job. */
175 return VINF_SUCCESS;
176}
177
178
179/**
180 * Exits the shadow mode.
181 *
182 * @returns VBox status code.
183 * @param pVM VM handle.
184 */
185PGM_SHW_DECL(int, Exit)(PVM pVM)
186{
187#if PGM_SHW_MODE == PGM_MODE_AMD64
188 /*
189 * Clear the RW, US and A flags for the fixed PDPEs.
190 */
191#endif
192
193 return VINF_SUCCESS;
194}
195
196
197
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