VirtualBox

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

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

Fixed bustage reported in #2799

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 7.7 KB
Line 
1/* $Id: PGMShw.h 8415 2008-04-28 11:20:42Z vboxsync $ */
2/** @file
3 * VBox - Page Manager / Monitor, Shadow Paging Template.
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* 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#if PGM_SHW_TYPE != PGM_TYPE_AMD64 /* No AMD64 for traditional virtualization, only VT-x and AMD-V. */
122 /* GC */
123 rc = PDMR3GetSymbolGC(pVM, NULL, PGM_SHW_NAME_GC_STR(GetPage), &pModeData->pfnGCShwGetPage);
124 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_GC_STR(GetPage), rc), rc);
125 rc = PDMR3GetSymbolGC(pVM, NULL, PGM_SHW_NAME_GC_STR(ModifyPage), &pModeData->pfnGCShwModifyPage);
126 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_GC_STR(ModifyPage), rc), rc);
127 rc = PDMR3GetSymbolGC(pVM, NULL, PGM_SHW_NAME_GC_STR(GetPDEByIndex), &pModeData->pfnGCShwGetPDEByIndex);
128 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_GC_STR(GetPDEByIndex), rc), rc);
129 rc = PDMR3GetSymbolGC(pVM, NULL, PGM_SHW_NAME_GC_STR(SetPDEByIndex), &pModeData->pfnGCShwSetPDEByIndex);
130 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_GC_STR(SetPDEByIndex), rc), rc);
131 rc = PDMR3GetSymbolGC(pVM, NULL, PGM_SHW_NAME_GC_STR(ModifyPDEByIndex), &pModeData->pfnGCShwModifyPDEByIndex);
132 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_GC_STR(ModifyPDEByIndex), rc), rc);
133#endif /* Not AMD64 shadow paging. */
134
135 /* Ring-0 */
136 rc = PDMR3GetSymbolR0(pVM, NULL, PGM_SHW_NAME_R0_STR(GetPage), &pModeData->pfnR0ShwGetPage);
137 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_R0_STR(GetPage), rc), rc);
138 rc = PDMR3GetSymbolR0(pVM, NULL, PGM_SHW_NAME_R0_STR(ModifyPage), &pModeData->pfnR0ShwModifyPage);
139 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_R0_STR(ModifyPage), rc), rc);
140 rc = PDMR3GetSymbolR0(pVM, NULL, PGM_SHW_NAME_R0_STR(GetPDEByIndex), &pModeData->pfnR0ShwGetPDEByIndex);
141 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_R0_STR(GetPDEByIndex), rc), rc);
142 rc = PDMR3GetSymbolR0(pVM, NULL, PGM_SHW_NAME_R0_STR(SetPDEByIndex), &pModeData->pfnR0ShwSetPDEByIndex);
143 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_R0_STR(SetPDEByIndex), rc), rc);
144 rc = PDMR3GetSymbolR0(pVM, NULL, PGM_SHW_NAME_R0_STR(ModifyPDEByIndex), &pModeData->pfnR0ShwModifyPDEByIndex);
145 AssertMsgRCReturn(rc, ("%s -> rc=%Vrc\n", PGM_SHW_NAME_R0_STR(ModifyPDEByIndex), rc), rc);
146 }
147 return VINF_SUCCESS;
148}
149
150/**
151 * Enters the shadow mode.
152 *
153 * @returns VBox status code.
154 * @param pVM VM handle.
155 */
156PGM_SHW_DECL(int, Enter)(PVM pVM)
157{
158#if PGM_SHW_MODE == PGM_MODE_AMD64
159 /*
160 * Set the RW, US and A flags for the fixed PDPEs.
161 */
162#endif
163 return VINF_SUCCESS;
164}
165
166
167/**
168 * Relocate any GC pointers related to shadow mode paging.
169 *
170 * @returns VBox status code.
171 * @param pVM The VM handle.
172 * @param offDelta The reloation offset.
173 */
174PGM_SHW_DECL(int, Relocate)(PVM pVM, RTGCUINTPTR offDelta)
175{
176 /* nothing special to do here - InitData does the job. */
177 return VINF_SUCCESS;
178}
179
180
181/**
182 * Exits the shadow mode.
183 *
184 * @returns VBox status code.
185 * @param pVM VM handle.
186 */
187PGM_SHW_DECL(int, Exit)(PVM pVM)
188{
189#if PGM_SHW_MODE == PGM_MODE_AMD64
190 /*
191 * Clear the RW, US and A flags for the fixed PDPEs.
192 */
193#endif
194
195 return VINF_SUCCESS;
196}
197
198
199
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