1 | /* $Id: PGMSlatDefs.h 106061 2024-09-16 14:03:52Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * VBox - Page Manager, SLAT Paging Template - All context code.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2022-2024 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 |
|
---|
33 | #undef SLAT_IS_PGENTRY_PRESENT
|
---|
34 | #undef SLAT_IS_PML4E_VALID
|
---|
35 | #undef SLAT_IS_PDPE_VALID
|
---|
36 | #undef SLAT_IS_BIG_PDPE_VALID
|
---|
37 | #undef SLAT_IS_PDE_VALID
|
---|
38 | #undef SLAT_IS_BIG_PDE_VALID
|
---|
39 | #undef SLAT_IS_PTE_VALID
|
---|
40 | #undef SLAT_GET_PDPE1G_GCPHYS
|
---|
41 | #undef SLAT_GET_PDE2M_GCPHYS
|
---|
42 | #undef SLAT_GET_PTE_GCPHYS
|
---|
43 | #undef SLAT_PAGE_1G_OFFSET_MASK
|
---|
44 | #undef SLAT_PAGE_2M_OFFSET_MASK
|
---|
45 | #undef SLAT_PML4_SHIFT
|
---|
46 | #undef SLAT_PML4_MASK
|
---|
47 | #undef SLAT_PDPT_SHIFT
|
---|
48 | #undef SLAT_PDPT_MASK
|
---|
49 | #undef SLAT_PD_SHIFT
|
---|
50 | #undef SLAT_PD_MASK
|
---|
51 | #undef SLAT_PT_SHIFT
|
---|
52 | #undef SLAT_PT_MASK
|
---|
53 | #undef SLATPDE
|
---|
54 | #undef PSLATPDE
|
---|
55 | #undef SLATPTE
|
---|
56 | #undef PSLATPTE
|
---|
57 | #undef PSLATPTWALK
|
---|
58 |
|
---|
59 | #define SLAT_IS_PGENTRY_PRESENT(a_pVCpu, a_Pge) ((a_Pge.u) & (a_pVCpu)->pgm.s.fGstEptPresentMask)
|
---|
60 | #define SLAT_IS_PML4E_VALID(a_pVCpu, a_Pml4e) (!( (a_Pml4e).u & (a_pVCpu)->pgm.s.fGstEptMbzPml4eMask ))
|
---|
61 | #define SLAT_IS_PDPE_VALID(a_pVCpu, a_Pdpte) (!( (a_Pdpte).u & (a_pVCpu)->pgm.s.fGstEptMbzPdpteMask ))
|
---|
62 | #define SLAT_IS_BIG_PDPE_VALID(a_pVCpu, a_Pdpe) (!( (a_Pdpe).u & (a_pVCpu)->pgm.s.fGstEptMbzBigPdpteMask ))
|
---|
63 | #define SLAT_IS_PDE_VALID(a_pVCpu, a_Pde) (!( (a_Pde).u & (a_pVCpu)->pgm.s.fGstEptMbzPdeMask ))
|
---|
64 | #define SLAT_IS_BIG_PDE_VALID(a_pVCpu, a_Pde) (!( (a_Pde).u & (a_pVCpu)->pgm.s.fGstEptMbzBigPdeMask ))
|
---|
65 | #define SLAT_IS_PTE_VALID(a_pVCpu, a_Pte) (!( (a_Pte).u & (a_pVCpu)->pgm.s.fGstEptMbzPteMask ))
|
---|
66 | #define SLAT_GET_PDPE1G_GCPHYS(a_pVCpu, a_Pdpte) PGM_A20_APPLY(a_pVCpu, ((a_Pdpte).u & EPT_PDPTE1G_PG_MASK))
|
---|
67 | #define SLAT_GET_PDE2M_GCPHYS(a_pVCpu, a_Pde) PGM_A20_APPLY(a_pVCpu, ((a_Pde).u & EPT_PDE2M_PG_MASK))
|
---|
68 | #define SLAT_GET_PTE_GCPHYS(a_pVCpu, a_Pte) PGM_A20_APPLY(a_pVCpu, ((a_Pte).u & EPT_E_PG_MASK))
|
---|
69 | #define SLAT_PAGE_1G_OFFSET_MASK X86_PAGE_1G_OFFSET_MASK
|
---|
70 | #define SLAT_PAGE_2M_OFFSET_MASK X86_PAGE_2M_OFFSET_MASK
|
---|
71 | #define SLAT_PML4_SHIFT EPT_PML4_SHIFT
|
---|
72 | #define SLAT_PML4_MASK EPT_PML4_MASK
|
---|
73 | #define SLAT_PDPT_SHIFT EPT_PDPT_SHIFT
|
---|
74 | #define SLAT_PDPT_MASK EPT_PDPT_MASK
|
---|
75 | #define SLAT_PD_SHIFT EPT_PD_SHIFT
|
---|
76 | #define SLAT_PD_MASK EPT_PD_MASK
|
---|
77 | #define SLAT_PT_SHIFT EPT_PT_SHIFT
|
---|
78 | #define SLAT_PT_MASK EPT_PT_MASK
|
---|
79 | #define SLATPDE EPTPDE
|
---|
80 | #define PSLATPDE PEPTPDE
|
---|
81 | #define SLATPTE EPTPTE
|
---|
82 | #define PSLATPTE PEPTPTE
|
---|
83 | #define PSLATPTWALK PPGMPTWALKGSTEPT
|
---|
84 |
|
---|
85 | #if 0
|
---|
86 | # if PGM_SHW_TYPE != PGM_TYPE_EPT
|
---|
87 | # error "Only SLAT type of EPT is supported "
|
---|
88 | # endif
|
---|
89 | # if PGM_GST_TYPE != PGM_TYPE_EPT
|
---|
90 | # error "Guest type for SLAT EPT "
|
---|
91 | # endif
|
---|
92 |
|
---|
93 | # define GST_ATOMIC_OR(a_pu, a_fFlags) ASMAtomicOrU64((a_pu), (a_fFlags))
|
---|
94 | # define GSTPT EPTPT
|
---|
95 | # define PGSTPT PEPTPT
|
---|
96 | # define GSTPTE EPTPTE
|
---|
97 | # define PGSTPTE PEPTPTE
|
---|
98 | # define GSTPD EPTPD
|
---|
99 | # define PGSTPD PEPTPD
|
---|
100 | # define GSTPDE EPTPDE
|
---|
101 | # define PGSTPDE PEPTPDE
|
---|
102 | # define GST_GIGANT_PAGE_SIZE X86_PAGE_1G_SIZE
|
---|
103 | # define GST_GIGANT_PAGE_OFFSET_MASK X86_PAGE_1G_OFFSET_MASK
|
---|
104 | # define GST_PDPE_BIG_PG_MASK X86_PDPE1G_PG_MASK
|
---|
105 | # define GST_BIG_PAGE_SIZE X86_PAGE_2M_SIZE
|
---|
106 | # define GST_BIG_PAGE_OFFSET_MASK X86_PAGE_2M_OFFSET_MASK
|
---|
107 | # define GST_PDE_PG_MASK EPT_PDE_PG_MASK
|
---|
108 | # define GST_PDE_BIG_PG_MASK EPT_PDE2M_PG_MASK
|
---|
109 | # define GST_PD_SHIFT EPT_PD_SHIFT
|
---|
110 | # define GST_PD_MASK EPT_PD_MASK
|
---|
111 | # define GSTPTWALK PGMPTWALKGSTEPT
|
---|
112 | # define PGSTPTWALK PPGMPTWALKGSTEPT
|
---|
113 | # define PCGSTPTWALK PCPGMPTWALKGSTEPT
|
---|
114 | # define GST_PDPE_ENTRIES EPT_PG_ENTRIES
|
---|
115 | # define GST_PDPT_SHIFT EPT_PDPT_SHIFT
|
---|
116 | # define GST_PDPE_PG_MASK EPT_PDPTE_PG_MASK
|
---|
117 | # define GST_PDPT_MASK EPT_PDPT_MASK
|
---|
118 | # define GST_PTE_PG_MASK EPT_E_PG_MASK
|
---|
119 | # define GST_CR3_PAGE_MASK X86_CR3_EPT_PAGE_MASK
|
---|
120 | # define GST_PT_SHIFT EPT_PT_SHIFT
|
---|
121 | # define GST_PT_MASK EPT_PT_MASK
|
---|
122 | # define GST_GET_PTE_GCPHYS(Pte) PGM_A20_APPLY(a_pVCpu, ((Pte).u & GST_PTE_PG_MASK))
|
---|
123 | # define GST_GET_PDE_GCPHYS(Pde) PGM_A20_APPLY(a_pVCpu, ((Pde).u & GST_PDE_PG_MASK))
|
---|
124 | # define GST_GET_BIG_PDE_GCPHYS(pVM, Pde) PGM_A20_APPLY(a_pVCpu, ((Pde).u & GST_PDE_BIG_PG_MASK))
|
---|
125 | # define GST_GET_BIG_PDPE_GCPHYS(pVM, Pde) PGM_A20_APPLY(a_pVCpu, ((Pde).u & GST_PDPE_BIG_PG_MASK))
|
---|
126 | # define GST_GET_PTE_SHW_FLAGS(a_pVCpu, Pte) (true && This_should_perhaps_not_be_used_in_this_context)
|
---|
127 | # define GST_GET_PDE_SHW_FLAGS(a_pVCpu, Pde) (true && This_should_perhaps_not_be_used_in_this_context)
|
---|
128 | # define GST_GET_BIG_PDE_SHW_FLAGS(a_pVCpu, Pde) (true && This_should_perhaps_not_be_used_in_this_context)
|
---|
129 | # define GST_GET_BIG_PDE_SHW_FLAGS_4_PTE(a_pVCpu, Pde) (true && This_should_perhaps_not_be_used_in_this_context)
|
---|
130 | # define GST_IS_PTE_VALID(a_pVCpu, Pte) (!( (Pte).u & (a_pVCpu)->pgm.s.fGstEptMbzPteMask ))
|
---|
131 | # define GST_IS_PDE_VALID(a_pVCpu, Pde) (!( (Pde).u & (a_pVCpu)->pgm.s.fGstEptMbzPdeMask ))
|
---|
132 | # define GST_IS_BIG_PDE_VALID(a_pVCpu, Pde) (!( (Pde).u & (a_pVCpu)->pgm.s.fGstEptMbzBigPdeMask ))
|
---|
133 | # define GST_IS_PDPE_VALID(a_pVCpu, Pdpe) (!( (Pdpe).u & (a_pVCpu)->pgm.s.fGstEptMbzPdpteMask ))
|
---|
134 | # define GST_IS_BIG_PDPE_VALID(a_pVCpu, Pdpe) (!( (Pdpe).u & (a_pVCpu)->pgm.s.fGstEptMbzBigPdpteMask ))
|
---|
135 | # define GST_IS_PML4E_VALID(a_pVCpu, Pml4e) (!( (Pml4e).u & (a_pVCpu)->pgm.s.fGstEptMbzPml4eMask ))
|
---|
136 | # define GST_IS_PGENTRY_PRESENT(a_pVCpu, Pge) ((Pge).u & EPT_PRESENT_MASK)
|
---|
137 | # define GST_IS_PSE_ACTIVE(a_pVCpu) (!((a_pVCpu)->pgm.s.fGstEptMbzBigPdeMask & EPT_E_BIT_LEAF))
|
---|
138 | # define GST_IS_NX_ACTIVE(a_pVCpu) (pgmGstIsNoExecuteActive(a_pVCpu))
|
---|
139 | # define BTH_IS_NP_ACTIVE(pVM) (false)
|
---|
140 | #endif
|
---|
141 |
|
---|