VirtualBox

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

Last change on this file since 7805 was 5999, checked in by vboxsync, 17 years ago

The Giant CDDL Dual-License Header Change.

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