VirtualBox

source: vbox/trunk/src/VBox/VMM/include/PGMGstDefs.h@ 96860

Last change on this file since 96860 was 96760, checked in by vboxsync, 21 months ago

VMM/PGM: Nested VMX: bugref:100092 Don't confuse PGM_GST_TYPE with PGM_SLAT_TYPE.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id Revision
File size: 13.3 KB
Line 
1/* $Id: PGMGstDefs.h 96760 2022-09-16 04:08:22Z vboxsync $ */
2/** @file
3 * VBox - Page Manager, Guest Paging Template - All context code.
4 */
5
6/*
7 * Copyright (C) 2006-2022 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * SPDX-License-Identifier: GPL-3.0-only
26 */
27
28
29/*******************************************************************************
30* Defined Constants And Macros *
31*******************************************************************************/
32#undef GST_ATOMIC_OR
33#undef GSTPT
34#undef PGSTPT
35#undef GSTPTE
36#undef PGSTPTE
37#undef GSTPD
38#undef PGSTPD
39#undef GSTPDE
40#undef PGSTPDE
41#undef GSTPTWALK
42#undef PGSTPTWALK
43#undef PCGSTPTWALK
44#undef GST_BIG_PAGE_SIZE
45#undef GST_BIG_PAGE_OFFSET_MASK
46#undef GST_GIGANT_PAGE_SIZE
47#undef GST_GIGANT_PAGE_OFFSET_MASK
48#undef GST_PDPE_BIG_PG_MASK
49#undef GST_PDE_PG_MASK
50#undef GST_PDE_BIG_PG_MASK
51#undef GST_PD_SHIFT
52#undef GST_PD_MASK
53#undef GST_PTE_PG_MASK
54#undef GST_GET_PTE_SHW_FLAGS
55#undef GST_PT_SHIFT
56#undef GST_PT_MASK
57#undef GST_CR3_PAGE_MASK
58#undef GST_PDPE_ENTRIES
59#undef GST_PDPT_SHIFT
60#undef GST_PDPT_MASK
61#undef GST_PDPE_PG_MASK
62#undef GST_GET_PTE_GCPHYS
63#undef GST_GET_PDE_GCPHYS
64#undef GST_GET_BIG_PDE_GCPHYS
65#undef GST_GET_BIG_PDPE_GCPHYS
66#undef GST_GET_PDE_SHW_FLAGS
67#undef GST_GET_BIG_PDE_SHW_FLAGS
68#undef GST_GET_BIG_PDE_SHW_FLAGS_4_PTE
69#undef GST_IS_PTE_VALID
70#undef GST_IS_PDE_VALID
71#undef GST_IS_BIG_PDE_VALID
72#undef GST_IS_PDPE_VALID
73#undef GST_IS_BIG_PDPE_VALID
74#undef GST_IS_PML4E_VALID
75#undef GST_IS_PGENTRY_PRESENT
76#undef GST_IS_PSE_ACTIVE
77#undef GST_IS_NX_ACTIVE
78#undef BTH_IS_NP_ACTIVE
79
80#if PGM_GST_TYPE == PGM_TYPE_REAL \
81 || PGM_GST_TYPE == PGM_TYPE_PROT
82
83# if PGM_SHW_TYPE == PGM_TYPE_EPT
84# define GST_ATOMIC_OR(a_pu, a_fFlags) ASMAtomicOrU64((a_pu), (a_fFlags))
85# define GSTPT X86PTPAE
86# define PGSTPT PX86PTPAE
87# define GSTPTE X86PTEPAE
88# define PGSTPTE PX86PTEPAE
89# define GSTPD X86PDPAE
90# define PGSTPD PX86PDPAE
91# define GSTPDE X86PDEPAE
92# define PGSTPDE PX86PDEPAE
93# define GST_PTE_PG_MASK X86_PTE_PAE_PG_MASK
94# define GST_IS_NX_ACTIVE(pVCpu) (true && This_should_perhaps_not_be_used_in_this_context)
95# define BTH_IS_NP_ACTIVE(pVM) (true)
96# else
97# if PGM_SHW_TYPE == PGM_TYPE_32BIT /* Same as shadow paging, but no PGMSHWPTEPAE. */
98# define GST_ATOMIC_OR(a_pu, a_fFlags) ASMAtomicOrU32((a_pu), (a_fFlags))
99# define GSTPT X86PT
100# define PGSTPT PX86PT
101# define GSTPTE X86PTE
102# define PGSTPTE PX86PTE
103# define GSTPD X86PD
104# define PGSTPD PX86PD
105# define GSTPDE X86PDE
106# define PGSTPDE PX86PDE
107# define GST_PTE_PG_MASK X86_PTE_PG_MASK
108# else
109# define GST_ATOMIC_OR(a_pu, a_fFlags) ASMAtomicOrU64((a_pu), (a_fFlags))
110# define GSTPT X86PTPAE
111# define PGSTPT PX86PTPAE
112# define GSTPTE X86PTEPAE
113# define PGSTPTE PX86PTEPAE
114# define GSTPD X86PDPAE
115# define PGSTPD PX86PDPAE
116# define GSTPDE X86PDEPAE
117# define PGSTPDE PX86PDEPAE
118# define GST_PTE_PG_MASK X86_PTE_PAE_PG_MASK
119# endif
120# define GST_IS_NX_ACTIVE(pVCpu) (pgmGstIsNoExecuteActive(pVCpu))
121# if PGM_GST_TYPE == PGM_TYPE_PROT /* (comment at top of PGMAllBth.h) */
122# define BTH_IS_NP_ACTIVE(pVM) (pVM->pgm.s.fNestedPaging)
123# else
124# define BTH_IS_NP_ACTIVE(pVM) (false)
125# endif
126# endif
127# define GST_GET_PTE_GCPHYS(Pte) PGM_A20_APPLY(pVCpu, ((Pte).u & GST_PTE_PG_MASK))
128# define GST_GET_PDE_GCPHYS(Pde) (true && This_should_perhaps_not_be_used_in_this_context) //??
129# define GST_GET_BIG_PDE_GCPHYS(Pde) (true && This_should_perhaps_not_be_used_in_this_context) //??
130# define GST_GET_PTE_SHW_FLAGS(pVCpu, Pte) ((Pte).u & (X86_PTE_P | X86_PTE_RW | X86_PTE_US | X86_PTE_A | X86_PTE_D | X86_PTE_G)) /**< @todo Could return P|RW|US|A|D here without consulting the PTE. */
131# define GST_GET_PDE_SHW_FLAGS(pVCpu, Pde) (true && This_should_perhaps_not_be_used_in_this_context) //??
132# define GST_GET_BIG_PDE_SHW_FLAGS(pVCpu, Pde) (true && This_should_perhaps_not_be_used_in_this_context) //??
133# define GST_GET_BIG_PDE_SHW_FLAGS_4_PTE(pVCpu, Pde) (true && This_should_perhaps_not_be_used_in_this_context) //??
134# define GST_IS_PTE_VALID(pVCpu, Pte) (true)
135# define GST_IS_PDE_VALID(pVCpu, Pde) (true)
136# define GST_IS_BIG_PDE_VALID(pVCpu, Pde) (true)
137# define GST_IS_PDPE_VALID(pVCpu, Pdpe) (true)
138# define GST_IS_BIG_PDPE_VALID(pVCpu, Pdpe) (true)
139# define GST_IS_PML4E_VALID(pVCpu, Pml4e) (true)
140# define GST_IS_PGENTRY_PRESENT(pVCpu, Pge) ((Pge.u) & X86_PTE_P)
141# define GST_IS_PSE_ACTIVE(pVCpu) (false && This_should_not_be_used_in_this_context)
142
143#elif PGM_GST_TYPE == PGM_TYPE_32BIT
144# define GST_ATOMIC_OR(a_pu, a_fFlags) ASMAtomicOrU32((a_pu), (a_fFlags))
145# define GSTPT X86PT
146# define PGSTPT PX86PT
147# define GSTPTE X86PTE
148# define PGSTPTE PX86PTE
149# define GSTPD X86PD
150# define PGSTPD PX86PD
151# define GSTPDE X86PDE
152# define PGSTPDE PX86PDE
153# define GSTPTWALK PGMPTWALKGST32BIT
154# define PGSTPTWALK PPGMPTWALKGST32BIT
155# define PCGSTPTWALK PCPGMPTWALKGST32BIT
156# define GST_BIG_PAGE_SIZE X86_PAGE_4M_SIZE
157# define GST_BIG_PAGE_OFFSET_MASK X86_PAGE_4M_OFFSET_MASK
158# define GST_PDE_PG_MASK X86_PDE_PG_MASK
159# define GST_PDE_BIG_PG_MASK X86_PDE4M_PG_MASK
160# define GST_GET_PTE_GCPHYS(Pte) PGM_A20_APPLY(pVCpu, ((Pte).u & GST_PDE_PG_MASK))
161# define GST_GET_PDE_GCPHYS(Pde) PGM_A20_APPLY(pVCpu, ((Pde).u & GST_PDE_PG_MASK))
162# define GST_GET_BIG_PDE_GCPHYS(pVM, Pde) PGM_A20_APPLY(pVCpu, pgmGstGet4MBPhysPage((pVM), Pde))
163# define GST_GET_PDE_SHW_FLAGS(pVCpu, Pde) ((Pde).u & (X86_PDE_P | X86_PDE_RW | X86_PDE_US | X86_PDE_A))
164# define GST_GET_BIG_PDE_SHW_FLAGS(pVCpu, Pde) \
165 ( ((Pde).u & (X86_PDE4M_P | X86_PDE4M_RW | X86_PDE4M_US | X86_PDE4M_A)) | PGM_PDFLAGS_BIG_PAGE )
166# define GST_GET_BIG_PDE_SHW_FLAGS_4_PTE(pVCpu, Pde) \
167 ((Pde).u & (X86_PDE4M_P | X86_PDE4M_RW | X86_PDE4M_US | X86_PDE4M_A | X86_PDE4M_D | X86_PDE4M_G))
168# define GST_PD_SHIFT X86_PD_SHIFT
169# define GST_PD_MASK X86_PD_MASK
170# define GST_PTE_PG_MASK X86_PTE_PG_MASK
171# define GST_GET_PTE_SHW_FLAGS(pVCpu, Pte) ((Pte).u & (X86_PTE_P | X86_PTE_RW | X86_PTE_US | X86_PTE_A | X86_PTE_D | X86_PTE_G))
172# define GST_PT_SHIFT X86_PT_SHIFT
173# define GST_PT_MASK X86_PT_MASK
174# define GST_CR3_PAGE_MASK X86_CR3_PAGE_MASK
175# define GST_IS_PTE_VALID(pVCpu, Pte) (true)
176# define GST_IS_PDE_VALID(pVCpu, Pde) (true)
177# define GST_IS_BIG_PDE_VALID(pVCpu, Pde) (!( (Pde).u & (pVCpu)->pgm.s.fGst32BitMbzBigPdeMask ))
178//# define GST_IS_PDPE_VALID(pVCpu, Pdpe) (false)
179//# define GST_IS_BIG_PDPE_VALID(pVCpu, Pdpe) (false)
180//# define GST_IS_PML4E_VALID(pVCpu, Pml4e) (false)
181# define GST_IS_PGENTRY_PRESENT(pVCpu, Pge) ((Pge.u) & X86_PTE_P)
182# define GST_IS_PSE_ACTIVE(pVCpu) pgmGst32BitIsPageSizeExtActive(pVCpu)
183# define GST_IS_NX_ACTIVE(pVCpu) (false)
184# define BTH_IS_NP_ACTIVE(pVM) (false)
185
186#elif PGM_GST_TYPE == PGM_TYPE_PAE \
187 || PGM_GST_TYPE == PGM_TYPE_AMD64
188# define GST_ATOMIC_OR(a_pu, a_fFlags) ASMAtomicOrU64((a_pu), (a_fFlags))
189# define GSTPT X86PTPAE
190# define PGSTPT PX86PTPAE
191# define GSTPTE X86PTEPAE
192# define PGSTPTE PX86PTEPAE
193# define GSTPD X86PDPAE
194# define PGSTPD PX86PDPAE
195# define GSTPDE X86PDEPAE
196# define PGSTPDE PX86PDEPAE
197# define GST_BIG_PAGE_SIZE X86_PAGE_2M_SIZE
198# define GST_BIG_PAGE_OFFSET_MASK X86_PAGE_2M_OFFSET_MASK
199# define GST_PDE_PG_MASK X86_PDE_PAE_PG_MASK
200# define GST_PDE_BIG_PG_MASK X86_PDE2M_PAE_PG_MASK
201# define GST_GET_PTE_GCPHYS(Pte) PGM_A20_APPLY(pVCpu, ((Pte).u & GST_PTE_PG_MASK))
202# define GST_GET_PDE_GCPHYS(Pde) PGM_A20_APPLY(pVCpu, ((Pde).u & GST_PDE_PG_MASK))
203# define GST_GET_BIG_PDE_GCPHYS(pVM, Pde) PGM_A20_APPLY(pVCpu, ((Pde).u & GST_PDE_BIG_PG_MASK))
204# define GST_GET_PTE_SHW_FLAGS(pVCpu, Pte) ((Pte).u & (pVCpu)->pgm.s.fGst64ShadowedPteMask )
205# define GST_GET_PDE_SHW_FLAGS(pVCpu, Pde) ((Pde).u & (pVCpu)->pgm.s.fGst64ShadowedPdeMask )
206# define GST_GET_BIG_PDE_SHW_FLAGS(pVCpu, Pde) ( ((Pde).u & (pVCpu)->pgm.s.fGst64ShadowedBigPdeMask ) | PGM_PDFLAGS_BIG_PAGE)
207# define GST_GET_BIG_PDE_SHW_FLAGS_4_PTE(pVCpu, Pde) ((Pde).u & (pVCpu)->pgm.s.fGst64ShadowedBigPde4PteMask )
208
209# define GST_PD_SHIFT X86_PD_PAE_SHIFT
210# define GST_PD_MASK X86_PD_PAE_MASK
211# if PGM_GST_TYPE == PGM_TYPE_PAE
212# define GSTPTWALK PGMPTWALKGSTPAE
213# define PGSTPTWALK PPGMPTWALKGSTPAE
214# define PCGSTPTWALK PCPGMPTWALKGSTPAE
215# define GST_PDPE_ENTRIES X86_PG_PAE_PDPE_ENTRIES
216# define GST_PDPE_PG_MASK X86_PDPE_PG_MASK
217# define GST_PDPT_SHIFT X86_PDPT_SHIFT
218# define GST_PDPT_MASK X86_PDPT_MASK_PAE
219# define GST_PTE_PG_MASK X86_PTE_PAE_PG_MASK
220# define GST_CR3_PAGE_MASK X86_CR3_PAE_PAGE_MASK
221# define GST_IS_PTE_VALID(pVCpu, Pte) (!( (Pte).u & (pVCpu)->pgm.s.fGstPaeMbzPteMask ))
222# define GST_IS_PDE_VALID(pVCpu, Pde) (!( (Pde).u & (pVCpu)->pgm.s.fGstPaeMbzPdeMask ))
223# define GST_IS_BIG_PDE_VALID(pVCpu, Pde) (!( (Pde).u & (pVCpu)->pgm.s.fGstPaeMbzBigPdeMask ))
224# define GST_IS_PDPE_VALID(pVCpu, Pdpe) (!( (Pdpe).u & (pVCpu)->pgm.s.fGstPaeMbzPdpeMask ))
225//# define GST_IS_BIG_PDPE_VALID(pVCpu, Pdpe) (false)
226//# define GST_IS_PML4E_VALID(pVCpu, Pml4e) (false)
227# else
228# define GSTPTWALK PGMPTWALKGSTAMD64
229# define PGSTPTWALK PPGMPTWALKGSTAMD64
230# define PCGSTPTWALK PCPGMPTWALKGSTAMD64
231# define GST_PDPE_ENTRIES X86_PG_AMD64_PDPE_ENTRIES
232# define GST_PDPT_SHIFT X86_PDPT_SHIFT
233# define GST_PDPE_PG_MASK X86_PDPE_PG_MASK
234# define GST_PDPT_MASK X86_PDPT_MASK_AMD64
235# define GST_PTE_PG_MASK X86_PTE_PAE_PG_MASK
236# define GST_CR3_PAGE_MASK X86_CR3_AMD64_PAGE_MASK
237# define GST_IS_PTE_VALID(pVCpu, Pte) (!( (Pte).u & (pVCpu)->pgm.s.fGstAmd64MbzPteMask ))
238# define GST_IS_PDE_VALID(pVCpu, Pde) (!( (Pde).u & (pVCpu)->pgm.s.fGstAmd64MbzPdeMask ))
239# define GST_IS_BIG_PDE_VALID(pVCpu, Pde) (!( (Pde).u & (pVCpu)->pgm.s.fGstAmd64MbzBigPdeMask ))
240# define GST_IS_PDPE_VALID(pVCpu, Pdpe) (!( (Pdpe).u & (pVCpu)->pgm.s.fGstAmd64MbzPdpeMask ))
241# define GST_IS_BIG_PDPE_VALID(pVCpu, Pdpe) (!( (Pdpe).u & (pVCpu)->pgm.s.fGstAmd64MbzBigPdpeMask ))
242# define GST_IS_PML4E_VALID(pVCpu, Pml4e) (!( (Pml4e).u & (pVCpu)->pgm.s.fGstAmd64MbzPml4eMask ))
243# endif
244# define GST_IS_PGENTRY_PRESENT(pVCpu, Pge) ((Pge.u) & X86_PTE_P)
245# define GST_PT_SHIFT X86_PT_PAE_SHIFT
246# define GST_PT_MASK X86_PT_PAE_MASK
247# define GST_IS_PSE_ACTIVE(pVCpu) (true)
248# define GST_IS_NX_ACTIVE(pVCpu) (pgmGstIsNoExecuteActive(pVCpu))
249# define BTH_IS_NP_ACTIVE(pVM) (false)
250
251#else
252# error "Unknown PGM_GST_TYPE."
253#endif
254
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use