1 | /* $Id: tstVMStructSize.cpp 93656 2022-02-08 13:58:21Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * tstVMStructSize - testcase for check structure sizes/alignment
|
---|
4 | * and to verify that HC and GC uses the same
|
---|
5 | * representation of the structures.
|
---|
6 | */
|
---|
7 |
|
---|
8 | /*
|
---|
9 | * Copyright (C) 2006-2022 Oracle Corporation
|
---|
10 | *
|
---|
11 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
12 | * available from http://www.virtualbox.org. This file is free software;
|
---|
13 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
14 | * General Public License (GPL) as published by the Free Software
|
---|
15 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
16 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
17 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
18 | */
|
---|
19 |
|
---|
20 |
|
---|
21 | /*********************************************************************************************************************************
|
---|
22 | * Header Files *
|
---|
23 | *********************************************************************************************************************************/
|
---|
24 | #define IN_TSTVMSTRUCT 1
|
---|
25 | #include <VBox/vmm/cfgm.h>
|
---|
26 | #include <VBox/vmm/cpum.h>
|
---|
27 | #include <VBox/vmm/mm.h>
|
---|
28 | #include <VBox/vmm/pgm.h>
|
---|
29 | #include <VBox/vmm/selm.h>
|
---|
30 | #include <VBox/vmm/trpm.h>
|
---|
31 | #include <VBox/vmm/vmm.h>
|
---|
32 | #include <VBox/vmm/stam.h>
|
---|
33 | #include "PDMInternal.h"
|
---|
34 | #include <VBox/vmm/pdm.h>
|
---|
35 | #include "CFGMInternal.h"
|
---|
36 | #include "CPUMInternal.h"
|
---|
37 | #include "MMInternal.h"
|
---|
38 | #include "PGMInternal.h"
|
---|
39 | #include "SELMInternal.h"
|
---|
40 | #include "TRPMInternal.h"
|
---|
41 | #include "TMInternal.h"
|
---|
42 | #include "IOMInternal.h"
|
---|
43 | #include "SSMInternal.h"
|
---|
44 | #include "HMInternal.h"
|
---|
45 | #include "VMMInternal.h"
|
---|
46 | #include "DBGFInternal.h"
|
---|
47 | #include "GIMInternal.h"
|
---|
48 | #include "APICInternal.h"
|
---|
49 | #include "STAMInternal.h"
|
---|
50 | #include "VMInternal.h"
|
---|
51 | #include "EMInternal.h"
|
---|
52 | #include "IEMInternal.h"
|
---|
53 | #include "NEMInternal.h"
|
---|
54 | #include "../VMMR0/GMMR0Internal.h"
|
---|
55 | #include "../VMMR0/GVMMR0Internal.h"
|
---|
56 | #include <VBox/vmm/vm.h>
|
---|
57 | #include <VBox/vmm/uvm.h>
|
---|
58 | #include <VBox/vmm/gvm.h>
|
---|
59 | #include <VBox/param.h>
|
---|
60 | #include <VBox/dis.h>
|
---|
61 | #include <iprt/x86.h>
|
---|
62 |
|
---|
63 | #include "tstHelp.h"
|
---|
64 | #include <stdio.h>
|
---|
65 |
|
---|
66 |
|
---|
67 |
|
---|
68 | int main()
|
---|
69 | {
|
---|
70 | int rc = 0;
|
---|
71 | printf("tstVMStructSize: TESTING\n");
|
---|
72 |
|
---|
73 | printf("info: struct VM: %d bytes\n", (int)sizeof(VM));
|
---|
74 |
|
---|
75 | #define CHECK_PADDING_VM(align, member) \
|
---|
76 | do \
|
---|
77 | { \
|
---|
78 | CHECK_PADDING(VM, member, align); \
|
---|
79 | CHECK_MEMBER_ALIGNMENT(VM, member, align); \
|
---|
80 | VM *p = NULL; NOREF(p); \
|
---|
81 | if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
|
---|
82 | printf("warning: VM::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \
|
---|
83 | #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
|
---|
84 | (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
|
---|
85 | (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
|
---|
86 | } while (0)
|
---|
87 |
|
---|
88 |
|
---|
89 | #define CHECK_PADDING_VMCPU(align, member) \
|
---|
90 | do \
|
---|
91 | { \
|
---|
92 | CHECK_PADDING(VMCPU, member, align); \
|
---|
93 | CHECK_MEMBER_ALIGNMENT(VMCPU, member, align); \
|
---|
94 | VMCPU *p = NULL; NOREF(p); \
|
---|
95 | if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
|
---|
96 | printf("warning: VMCPU::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \
|
---|
97 | #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
|
---|
98 | (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
|
---|
99 | (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
|
---|
100 | } while (0)
|
---|
101 |
|
---|
102 | #define CHECK_CPUMCTXCORE(member) \
|
---|
103 | do { \
|
---|
104 | unsigned off1 = RT_OFFSETOF(CPUMCTX, member) - RT_OFFSETOF(CPUMCTX, rax); \
|
---|
105 | unsigned off2 = RT_OFFSETOF(CPUMCTXCORE, member); \
|
---|
106 | if (off1 != off2) \
|
---|
107 | { \
|
---|
108 | printf("error! CPUMCTX/CORE:: %s! (%#x vs %#x (ctx))\n", #member, off1, off2); \
|
---|
109 | rc++; \
|
---|
110 | } \
|
---|
111 | } while (0)
|
---|
112 |
|
---|
113 | #define CHECK_PADDING_UVM(align, member) \
|
---|
114 | do \
|
---|
115 | { \
|
---|
116 | CHECK_PADDING(UVM, member, align); \
|
---|
117 | CHECK_MEMBER_ALIGNMENT(UVM, member, align); \
|
---|
118 | UVM *p = NULL; NOREF(p); \
|
---|
119 | if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
|
---|
120 | printf("warning: UVM::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \
|
---|
121 | #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
|
---|
122 | (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
|
---|
123 | (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
|
---|
124 | } while (0)
|
---|
125 |
|
---|
126 | #define CHECK_PADDING_UVMCPU(align, member) \
|
---|
127 | do \
|
---|
128 | { \
|
---|
129 | CHECK_PADDING(UVMCPU, member, align); \
|
---|
130 | CHECK_MEMBER_ALIGNMENT(UVMCPU, member, align); \
|
---|
131 | UVMCPU *p = NULL; NOREF(p); \
|
---|
132 | if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
|
---|
133 | printf("warning: UVMCPU::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \
|
---|
134 | #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
|
---|
135 | (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
|
---|
136 | (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
|
---|
137 | } while (0)
|
---|
138 |
|
---|
139 | #define CHECK_PADDING_GVM(align, member) \
|
---|
140 | do \
|
---|
141 | { \
|
---|
142 | CHECK_PADDING(GVM, member, align); \
|
---|
143 | CHECK_MEMBER_ALIGNMENT(GVM, member, align); \
|
---|
144 | GVM *p = NULL; NOREF(p); \
|
---|
145 | if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
|
---|
146 | printf("warning: GVM::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \
|
---|
147 | #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
|
---|
148 | (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
|
---|
149 | (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
|
---|
150 | } while (0)
|
---|
151 |
|
---|
152 | #define CHECK_PADDING_GVMCPU(align, member) \
|
---|
153 | do \
|
---|
154 | { \
|
---|
155 | CHECK_PADDING(GVMCPU, member, align); \
|
---|
156 | CHECK_MEMBER_ALIGNMENT(GVMCPU, member, align); \
|
---|
157 | GVMCPU *p = NULL; NOREF(p); \
|
---|
158 | if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
|
---|
159 | printf("warning: GVMCPU::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \
|
---|
160 | #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
|
---|
161 | (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
|
---|
162 | (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
|
---|
163 | } while (0)
|
---|
164 |
|
---|
165 | #define PRINT_OFFSET(strct, member) \
|
---|
166 | do \
|
---|
167 | { \
|
---|
168 | printf("info: %10s::%-24s offset %#6x (%6d) sizeof %4d\n", #strct, #member, (int)RT_OFFSETOF(strct, member), (int)RT_OFFSETOF(strct, member), (int)RT_SIZEOFMEMB(strct, member)); \
|
---|
169 | } while (0)
|
---|
170 |
|
---|
171 |
|
---|
172 | CHECK_SIZE(uint128_t, 128/8);
|
---|
173 | CHECK_SIZE(int128_t, 128/8);
|
---|
174 | CHECK_SIZE(uint64_t, 64/8);
|
---|
175 | CHECK_SIZE(int64_t, 64/8);
|
---|
176 | CHECK_SIZE(uint32_t, 32/8);
|
---|
177 | CHECK_SIZE(int32_t, 32/8);
|
---|
178 | CHECK_SIZE(uint16_t, 16/8);
|
---|
179 | CHECK_SIZE(int16_t, 16/8);
|
---|
180 | CHECK_SIZE(uint8_t, 8/8);
|
---|
181 | CHECK_SIZE(int8_t, 8/8);
|
---|
182 |
|
---|
183 | CHECK_SIZE(X86DESC, 8);
|
---|
184 | CHECK_SIZE(X86DESC64, 16);
|
---|
185 | CHECK_SIZE(VBOXIDTE, 8);
|
---|
186 | CHECK_SIZE(VBOXIDTR, 10);
|
---|
187 | CHECK_SIZE(VBOXGDTR, 10);
|
---|
188 | CHECK_SIZE(VBOXTSS, 136);
|
---|
189 | CHECK_SIZE(X86FXSTATE, 512);
|
---|
190 | CHECK_SIZE(RTUUID, 16);
|
---|
191 | CHECK_SIZE(X86PTE, 4);
|
---|
192 | CHECK_SIZE(X86PD, PAGE_SIZE);
|
---|
193 | CHECK_SIZE(X86PDE, 4);
|
---|
194 | CHECK_SIZE(X86PT, PAGE_SIZE);
|
---|
195 | CHECK_SIZE(X86PTEPAE, 8);
|
---|
196 | CHECK_SIZE(X86PTPAE, PAGE_SIZE);
|
---|
197 | CHECK_SIZE(X86PDEPAE, 8);
|
---|
198 | CHECK_SIZE(X86PDPAE, PAGE_SIZE);
|
---|
199 | CHECK_SIZE(X86PDPE, 8);
|
---|
200 | CHECK_SIZE(X86PDPT, PAGE_SIZE);
|
---|
201 | CHECK_SIZE(X86PML4E, 8);
|
---|
202 | CHECK_SIZE(X86PML4, PAGE_SIZE);
|
---|
203 |
|
---|
204 | PRINT_OFFSET(VM, cpum);
|
---|
205 | CHECK_PADDING_VM(64, cpum);
|
---|
206 | CHECK_PADDING_VM(64, vmm);
|
---|
207 | PRINT_OFFSET(VM, pgm);
|
---|
208 | PRINT_OFFSET(VM, pgm.s.CritSectX);
|
---|
209 | CHECK_PADDING_VM(64, pgm);
|
---|
210 | PRINT_OFFSET(VM, hm);
|
---|
211 | CHECK_PADDING_VM(64, hm);
|
---|
212 | CHECK_PADDING_VM(64, trpm);
|
---|
213 | CHECK_PADDING_VM(64, selm);
|
---|
214 | CHECK_PADDING_VM(64, mm);
|
---|
215 | CHECK_PADDING_VM(64, pdm);
|
---|
216 | PRINT_OFFSET(VM, pdm.s.CritSect);
|
---|
217 | CHECK_PADDING_VM(64, iom);
|
---|
218 | CHECK_PADDING_VM(64, em);
|
---|
219 | /*CHECK_PADDING_VM(64, iem);*/
|
---|
220 | CHECK_PADDING_VM(64, nem);
|
---|
221 | CHECK_PADDING_VM(64, tm);
|
---|
222 | PRINT_OFFSET(VM, tm.s.VirtualSyncLock);
|
---|
223 | CHECK_PADDING_VM(64, dbgf);
|
---|
224 | CHECK_PADDING_VM(64, gim);
|
---|
225 | CHECK_PADDING_VM(64, ssm);
|
---|
226 | CHECK_PADDING_VM(8, vm);
|
---|
227 | CHECK_PADDING_VM(8, cfgm);
|
---|
228 | CHECK_PADDING_VM(8, apic);
|
---|
229 | CHECK_PADDING_VM(8, iem);
|
---|
230 | PRINT_OFFSET(VM, cfgm);
|
---|
231 | PRINT_OFFSET(VM, apCpusR3);
|
---|
232 |
|
---|
233 | PRINT_OFFSET(VMCPU, cpum);
|
---|
234 | CHECK_PADDING_VMCPU(64, iem);
|
---|
235 | CHECK_PADDING_VMCPU(64, hm);
|
---|
236 | CHECK_PADDING_VMCPU(64, em);
|
---|
237 | CHECK_PADDING_VMCPU(64, nem);
|
---|
238 | CHECK_PADDING_VMCPU(64, trpm);
|
---|
239 | CHECK_PADDING_VMCPU(64, tm);
|
---|
240 | CHECK_PADDING_VMCPU(64, vmm);
|
---|
241 | CHECK_PADDING_VMCPU(64, pdm);
|
---|
242 | CHECK_PADDING_VMCPU(64, iom);
|
---|
243 | CHECK_PADDING_VMCPU(64, dbgf);
|
---|
244 | CHECK_PADDING_VMCPU(64, gim);
|
---|
245 | CHECK_PADDING_VMCPU(64, apic);
|
---|
246 |
|
---|
247 | PRINT_OFFSET(VMCPU, pgm);
|
---|
248 | CHECK_PADDING_VMCPU(4096, pgm);
|
---|
249 | CHECK_PADDING_VMCPU(4096, cpum);
|
---|
250 | CHECK_PADDING_VMCPU(4096, cpum);
|
---|
251 | CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt, 4096);
|
---|
252 | CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt.svm.Vmcb, 4096);
|
---|
253 | CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt.svm.abMsrBitmap, 4096);
|
---|
254 | CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt.svm.abIoBitmap, 4096);
|
---|
255 | CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt.vmx.Vmcs, 4096);
|
---|
256 | CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt.vmx.ShadowVmcs, 4096);
|
---|
257 | CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt.vmx.abVmreadBitmap, 4096);
|
---|
258 | CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt.vmx.abVmwriteBitmap, 4096);
|
---|
259 | CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt.vmx.aEntryMsrLoadArea, 4096);
|
---|
260 | CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt.vmx.aExitMsrStoreArea, 4096);
|
---|
261 | CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt.vmx.aExitMsrLoadArea, 4096);
|
---|
262 | CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt.vmx.abMsrBitmap, 4096);
|
---|
263 | CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt.vmx.abIoBitmap, 4096);
|
---|
264 | CHECK_MEMBER_ALIGNMENT(VMCPU, cpum.s.Guest.hwvirt.vmx.abVirtApicPage, 4096);
|
---|
265 |
|
---|
266 | PVM pVM = NULL; NOREF(pVM);
|
---|
267 |
|
---|
268 | /* the VMCPUs are page aligned TLB hit reasons. */
|
---|
269 | CHECK_SIZE_ALIGNMENT(VMCPU, 4096);
|
---|
270 |
|
---|
271 | /* cpumctx */
|
---|
272 | CHECK_MEMBER_ALIGNMENT(CPUMCTX, rax, 32);
|
---|
273 | CHECK_MEMBER_ALIGNMENT(CPUMCTX, idtr.pIdt, 8);
|
---|
274 | CHECK_MEMBER_ALIGNMENT(CPUMCTX, gdtr.pGdt, 8);
|
---|
275 | CHECK_MEMBER_ALIGNMENT(CPUMCTX, SysEnter, 8);
|
---|
276 | CHECK_MEMBER_ALIGNMENT(CPUMCTX, hwvirt, 8);
|
---|
277 | CHECK_CPUMCTXCORE(rax);
|
---|
278 | CHECK_CPUMCTXCORE(rcx);
|
---|
279 | CHECK_CPUMCTXCORE(rdx);
|
---|
280 | CHECK_CPUMCTXCORE(rbx);
|
---|
281 | CHECK_CPUMCTXCORE(rsp);
|
---|
282 | CHECK_CPUMCTXCORE(rbp);
|
---|
283 | CHECK_CPUMCTXCORE(rsi);
|
---|
284 | CHECK_CPUMCTXCORE(rdi);
|
---|
285 | CHECK_CPUMCTXCORE(r8);
|
---|
286 | CHECK_CPUMCTXCORE(r9);
|
---|
287 | CHECK_CPUMCTXCORE(r10);
|
---|
288 | CHECK_CPUMCTXCORE(r11);
|
---|
289 | CHECK_CPUMCTXCORE(r12);
|
---|
290 | CHECK_CPUMCTXCORE(r13);
|
---|
291 | CHECK_CPUMCTXCORE(r14);
|
---|
292 | CHECK_CPUMCTXCORE(r15);
|
---|
293 | CHECK_CPUMCTXCORE(es);
|
---|
294 | CHECK_CPUMCTXCORE(ss);
|
---|
295 | CHECK_CPUMCTXCORE(cs);
|
---|
296 | CHECK_CPUMCTXCORE(ds);
|
---|
297 | CHECK_CPUMCTXCORE(fs);
|
---|
298 | CHECK_CPUMCTXCORE(gs);
|
---|
299 | CHECK_CPUMCTXCORE(rip);
|
---|
300 | CHECK_CPUMCTXCORE(rflags);
|
---|
301 |
|
---|
302 | #if HC_ARCH_BITS == 32
|
---|
303 | /* CPUMHOSTCTX - lss pair */
|
---|
304 | if (RT_UOFFSETOF(CPUMHOSTCTX, esp) + 4 != RT_UOFFSETOF(CPUMHOSTCTX, ss))
|
---|
305 | {
|
---|
306 | printf("error! CPUMHOSTCTX lss has been split up!\n");
|
---|
307 | rc++;
|
---|
308 | }
|
---|
309 | #endif
|
---|
310 | CHECK_SIZE_ALIGNMENT(CPUMCTX, 64);
|
---|
311 | CHECK_SIZE_ALIGNMENT(CPUMHOSTCTX, 64);
|
---|
312 | CHECK_SIZE_ALIGNMENT(CPUMCTXMSRS, 64);
|
---|
313 |
|
---|
314 | /* pdm */
|
---|
315 | PRINT_OFFSET(PDMDEVINSR3, Internal);
|
---|
316 | PRINT_OFFSET(PDMDEVINSR3, achInstanceData);
|
---|
317 | CHECK_MEMBER_ALIGNMENT(PDMDEVINSR3, achInstanceData, 64);
|
---|
318 | CHECK_PADDING(PDMDEVINSR3, Internal, 1);
|
---|
319 |
|
---|
320 | PRINT_OFFSET(PDMDEVINSR0, Internal);
|
---|
321 | PRINT_OFFSET(PDMDEVINSR0, achInstanceData);
|
---|
322 | CHECK_MEMBER_ALIGNMENT(PDMDEVINSR0, achInstanceData, 64);
|
---|
323 | CHECK_PADDING(PDMDEVINSR0, Internal, 1);
|
---|
324 |
|
---|
325 | PRINT_OFFSET(PDMDEVINSRC, Internal);
|
---|
326 | PRINT_OFFSET(PDMDEVINSRC, achInstanceData);
|
---|
327 | CHECK_MEMBER_ALIGNMENT(PDMDEVINSRC, achInstanceData, 64);
|
---|
328 | CHECK_PADDING(PDMDEVINSRC, Internal, 1);
|
---|
329 |
|
---|
330 | PRINT_OFFSET(PDMUSBINS, Internal);
|
---|
331 | PRINT_OFFSET(PDMUSBINS, achInstanceData);
|
---|
332 | CHECK_MEMBER_ALIGNMENT(PDMUSBINS, achInstanceData, 32);
|
---|
333 | CHECK_PADDING(PDMUSBINS, Internal, 1);
|
---|
334 |
|
---|
335 | PRINT_OFFSET(PDMDRVINS, Internal);
|
---|
336 | PRINT_OFFSET(PDMDRVINS, achInstanceData);
|
---|
337 | CHECK_MEMBER_ALIGNMENT(PDMDRVINS, achInstanceData, 32);
|
---|
338 | CHECK_PADDING(PDMDRVINS, Internal, 1);
|
---|
339 |
|
---|
340 | CHECK_PADDING2(PDMCRITSECT);
|
---|
341 | CHECK_PADDING2(PDMCRITSECTRW);
|
---|
342 |
|
---|
343 | /* pgm */
|
---|
344 | CHECK_MEMBER_ALIGNMENT(PGMCPU, GCPhysCR3, sizeof(RTGCPHYS));
|
---|
345 | CHECK_MEMBER_ALIGNMENT(PGMCPU, aGCPhysGstPaePDs, sizeof(RTGCPHYS));
|
---|
346 | CHECK_MEMBER_ALIGNMENT(PGMCPU, DisState, 8);
|
---|
347 | CHECK_MEMBER_ALIGNMENT(PGMCPU, cPoolAccessHandler, 8);
|
---|
348 | CHECK_MEMBER_ALIGNMENT(PGMPOOLPAGE, idx, sizeof(uint16_t));
|
---|
349 | CHECK_MEMBER_ALIGNMENT(PGMPOOLPAGE, pvPageR3, sizeof(RTHCPTR));
|
---|
350 | CHECK_MEMBER_ALIGNMENT(PGMPOOLPAGE, GCPhys, sizeof(RTGCPHYS));
|
---|
351 | CHECK_SIZE(PGMPAGE, 16);
|
---|
352 | CHECK_MEMBER_ALIGNMENT(PGMRAMRANGE, aPages, 16);
|
---|
353 | CHECK_MEMBER_ALIGNMENT(PGMREGMMIO2RANGE, RamRange, 16);
|
---|
354 |
|
---|
355 | /* TM */
|
---|
356 | CHECK_MEMBER_ALIGNMENT(TM, aTimerQueues, 64);
|
---|
357 | CHECK_MEMBER_ALIGNMENT(TM, VirtualSyncLock, sizeof(uintptr_t));
|
---|
358 |
|
---|
359 | /* misc */
|
---|
360 | CHECK_PADDING3(EMCPU, u.FatalLongJump, u.achPaddingFatalLongJump);
|
---|
361 | CHECK_SIZE_ALIGNMENT(VMMR0JMPBUF, 8);
|
---|
362 | #if 0
|
---|
363 | PRINT_OFFSET(VM, fForcedActions);
|
---|
364 | PRINT_OFFSET(VM, StatQemuToGC);
|
---|
365 | PRINT_OFFSET(VM, StatGCToQemu);
|
---|
366 | #endif
|
---|
367 |
|
---|
368 | CHECK_MEMBER_ALIGNMENT(IOM, CritSect, sizeof(uintptr_t));
|
---|
369 | CHECK_MEMBER_ALIGNMENT(EMCPU, u.achPaddingFatalLongJump, 32);
|
---|
370 | CHECK_MEMBER_ALIGNMENT(EMCPU, aExitRecords, sizeof(EMEXITREC));
|
---|
371 | CHECK_MEMBER_ALIGNMENT(PGM, CritSectX, sizeof(uintptr_t));
|
---|
372 | CHECK_MEMBER_ALIGNMENT(PDM, CritSect, sizeof(uintptr_t));
|
---|
373 | CHECK_MEMBER_ALIGNMENT(MMHYPERHEAP, Lock, sizeof(uintptr_t));
|
---|
374 |
|
---|
375 | /* hm - 32-bit gcc won't align uint64_t naturally, so check. */
|
---|
376 | CHECK_MEMBER_ALIGNMENT(HM, vmx, 8);
|
---|
377 | CHECK_MEMBER_ALIGNMENT(HM, svm, 8);
|
---|
378 | CHECK_MEMBER_ALIGNMENT(HM, ForR3.uMaxAsid, 8);
|
---|
379 | CHECK_MEMBER_ALIGNMENT(HM, ForR3.vmx, 8);
|
---|
380 | CHECK_MEMBER_ALIGNMENT(HM, PatchTree, 8);
|
---|
381 | CHECK_MEMBER_ALIGNMENT(HM, aPatches, 8);
|
---|
382 | CHECK_MEMBER_ALIGNMENT(HMCPU, vmx, 8);
|
---|
383 | CHECK_MEMBER_ALIGNMENT(HMR0PERVCPU, vmx.pfnStartVm, 8);
|
---|
384 | CHECK_MEMBER_ALIGNMENT(HMCPU, vmx.VmcsInfo, 8);
|
---|
385 | CHECK_MEMBER_ALIGNMENT(HMCPU, vmx.VmcsInfoNstGst, 8);
|
---|
386 | CHECK_MEMBER_ALIGNMENT(HMR0PERVCPU, vmx.RestoreHost, 8);
|
---|
387 | CHECK_MEMBER_ALIGNMENT(HMCPU, vmx.LastError, 8);
|
---|
388 | CHECK_MEMBER_ALIGNMENT(HMCPU, svm, 8);
|
---|
389 | CHECK_MEMBER_ALIGNMENT(HMR0PERVCPU, svm.pfnVMRun, 8);
|
---|
390 | CHECK_MEMBER_ALIGNMENT(HMCPU, Event, 8);
|
---|
391 | CHECK_MEMBER_ALIGNMENT(HMCPU, Event.u64IntInfo, 8);
|
---|
392 | CHECK_MEMBER_ALIGNMENT(HMR0PERVCPU, svm.DisState, 8);
|
---|
393 | CHECK_MEMBER_ALIGNMENT(HMCPU, StatEntry, 8);
|
---|
394 |
|
---|
395 | /* Make sure the set is large enough and has the correct size. */
|
---|
396 | CHECK_SIZE(VMCPUSET, 32);
|
---|
397 | if (sizeof(VMCPUSET) * 8 < VMM_MAX_CPU_COUNT)
|
---|
398 | {
|
---|
399 | printf("error! VMCPUSET is too small for VMM_MAX_CPU_COUNT=%u!\n", VMM_MAX_CPU_COUNT);
|
---|
400 | rc++;
|
---|
401 | }
|
---|
402 |
|
---|
403 | printf("info: struct UVM: %d bytes\n", (int)sizeof(UVM));
|
---|
404 |
|
---|
405 | CHECK_PADDING_UVM(32, vm);
|
---|
406 | CHECK_PADDING_UVM(32, mm);
|
---|
407 | CHECK_PADDING_UVM(32, pdm);
|
---|
408 | CHECK_PADDING_UVM(32, stam);
|
---|
409 |
|
---|
410 | printf("info: struct UVMCPU: %d bytes\n", (int)sizeof(UVMCPU));
|
---|
411 | CHECK_PADDING_UVMCPU(32, vm);
|
---|
412 |
|
---|
413 | CHECK_PADDING_GVM(4, gvmm);
|
---|
414 | CHECK_PADDING_GVM(4, gmm);
|
---|
415 | CHECK_PADDING_GVMCPU(4, gvmm);
|
---|
416 |
|
---|
417 | /*
|
---|
418 | * Check that the optimized access macros for PGMPAGE works correctly (kind of
|
---|
419 | * obsolete after dropping raw-mode).
|
---|
420 | */
|
---|
421 | PGMPAGE Page;
|
---|
422 | PGM_PAGE_CLEAR(&Page);
|
---|
423 |
|
---|
424 | CHECK_EXPR(PGM_PAGE_GET_HNDL_PHYS_STATE(&Page) == PGM_PAGE_HNDL_PHYS_STATE_NONE);
|
---|
425 | CHECK_EXPR(PGM_PAGE_HAS_ANY_HANDLERS(&Page) == false);
|
---|
426 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_HANDLERS(&Page) == false);
|
---|
427 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_ALL_HANDLERS(&Page) == false);
|
---|
428 |
|
---|
429 | PGM_PAGE_SET_HNDL_PHYS_STATE(&Page, PGM_PAGE_HNDL_PHYS_STATE_ALL);
|
---|
430 | CHECK_EXPR(PGM_PAGE_GET_HNDL_PHYS_STATE(&Page) == PGM_PAGE_HNDL_PHYS_STATE_ALL);
|
---|
431 | CHECK_EXPR(PGM_PAGE_HAS_ANY_HANDLERS(&Page) == true);
|
---|
432 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_HANDLERS(&Page) == true);
|
---|
433 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_ALL_HANDLERS(&Page) == true);
|
---|
434 |
|
---|
435 | PGM_PAGE_SET_HNDL_PHYS_STATE(&Page, PGM_PAGE_HNDL_PHYS_STATE_WRITE);
|
---|
436 | CHECK_EXPR(PGM_PAGE_GET_HNDL_PHYS_STATE(&Page) == PGM_PAGE_HNDL_PHYS_STATE_WRITE);
|
---|
437 | CHECK_EXPR(PGM_PAGE_HAS_ANY_HANDLERS(&Page) == true);
|
---|
438 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_HANDLERS(&Page) == true);
|
---|
439 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_ALL_HANDLERS(&Page) == false);
|
---|
440 |
|
---|
441 | #undef AssertFatal
|
---|
442 | #define AssertFatal(expr) do { } while (0)
|
---|
443 | #undef Assert
|
---|
444 | #define Assert(expr) do { } while (0)
|
---|
445 |
|
---|
446 | PGM_PAGE_CLEAR(&Page);
|
---|
447 | CHECK_EXPR(PGM_PAGE_GET_HCPHYS_NA(&Page) == 0);
|
---|
448 | PGM_PAGE_SET_HCPHYS(NULL, &Page, UINT64_C(0x0000fffeff1ff000));
|
---|
449 | CHECK_EXPR(PGM_PAGE_GET_HCPHYS_NA(&Page) == UINT64_C(0x0000fffeff1ff000));
|
---|
450 | PGM_PAGE_SET_HCPHYS(NULL, &Page, UINT64_C(0x0000000000001000));
|
---|
451 | CHECK_EXPR(PGM_PAGE_GET_HCPHYS_NA(&Page) == UINT64_C(0x0000000000001000));
|
---|
452 |
|
---|
453 | PGM_PAGE_INIT(&Page, UINT64_C(0x0000feedfacef000), UINT32_C(0x12345678), PGMPAGETYPE_RAM, PGM_PAGE_STATE_ALLOCATED);
|
---|
454 | CHECK_EXPR(PGM_PAGE_GET_HCPHYS_NA(&Page) == UINT64_C(0x0000feedfacef000));
|
---|
455 | CHECK_EXPR(PGM_PAGE_GET_PAGEID(&Page) == UINT32_C(0x12345678));
|
---|
456 | CHECK_EXPR(PGM_PAGE_GET_TYPE_NA(&Page) == PGMPAGETYPE_RAM);
|
---|
457 | CHECK_EXPR(PGM_PAGE_GET_STATE_NA(&Page) == PGM_PAGE_STATE_ALLOCATED);
|
---|
458 |
|
---|
459 |
|
---|
460 | /*
|
---|
461 | * Report result.
|
---|
462 | */
|
---|
463 | if (rc)
|
---|
464 | printf("tstVMStructSize: FAILURE - %d errors\n", rc);
|
---|
465 | else
|
---|
466 | printf("tstVMStructSize: SUCCESS\n");
|
---|
467 | return rc;
|
---|
468 | }
|
---|
469 |
|
---|