1 | /* $Id: tstVMStructSize.cpp 80018 2019-07-26 18:21:50Z 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-2019 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 "REMInternal.h"
|
---|
44 | #include "SSMInternal.h"
|
---|
45 | #include "HMInternal.h"
|
---|
46 | #include "VMMInternal.h"
|
---|
47 | #include "DBGFInternal.h"
|
---|
48 | #include "GIMInternal.h"
|
---|
49 | #include "APICInternal.h"
|
---|
50 | #include "STAMInternal.h"
|
---|
51 | #include "VMInternal.h"
|
---|
52 | #include "EMInternal.h"
|
---|
53 | #include "IEMInternal.h"
|
---|
54 | #include "REMInternal.h"
|
---|
55 | #include "NEMInternal.h"
|
---|
56 | #include "../VMMR0/GMMR0Internal.h"
|
---|
57 | #include "../VMMR0/GVMMR0Internal.h"
|
---|
58 | #include <VBox/vmm/vm.h>
|
---|
59 | #include <VBox/vmm/uvm.h>
|
---|
60 | #include <VBox/vmm/gvm.h>
|
---|
61 | #include <VBox/param.h>
|
---|
62 | #include <VBox/dis.h>
|
---|
63 | #include <iprt/x86.h>
|
---|
64 |
|
---|
65 | #include "tstHelp.h"
|
---|
66 | #include <stdio.h>
|
---|
67 |
|
---|
68 |
|
---|
69 |
|
---|
70 | int main()
|
---|
71 | {
|
---|
72 | int rc = 0;
|
---|
73 | printf("tstVMStructSize: TESTING\n");
|
---|
74 |
|
---|
75 | printf("info: struct VM: %d bytes\n", (int)sizeof(VM));
|
---|
76 |
|
---|
77 | #define CHECK_PADDING_VM(align, member) \
|
---|
78 | do \
|
---|
79 | { \
|
---|
80 | CHECK_PADDING(VM, member, align); \
|
---|
81 | CHECK_MEMBER_ALIGNMENT(VM, member, align); \
|
---|
82 | VM *p = NULL; NOREF(p); \
|
---|
83 | if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
|
---|
84 | printf("warning: VM::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \
|
---|
85 | #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
|
---|
86 | (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
|
---|
87 | (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
|
---|
88 | } while (0)
|
---|
89 |
|
---|
90 |
|
---|
91 | #define CHECK_PADDING_VMCPU(align, member) \
|
---|
92 | do \
|
---|
93 | { \
|
---|
94 | CHECK_PADDING(VMCPU, member, align); \
|
---|
95 | CHECK_MEMBER_ALIGNMENT(VMCPU, member, align); \
|
---|
96 | VMCPU *p = NULL; NOREF(p); \
|
---|
97 | if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
|
---|
98 | printf("warning: VMCPU::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \
|
---|
99 | #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
|
---|
100 | (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
|
---|
101 | (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
|
---|
102 | } while (0)
|
---|
103 |
|
---|
104 | #define CHECK_CPUMCTXCORE(member) \
|
---|
105 | do { \
|
---|
106 | unsigned off1 = RT_OFFSETOF(CPUMCTX, member) - RT_OFFSETOF(CPUMCTX, rax); \
|
---|
107 | unsigned off2 = RT_OFFSETOF(CPUMCTXCORE, member); \
|
---|
108 | if (off1 != off2) \
|
---|
109 | { \
|
---|
110 | printf("error! CPUMCTX/CORE:: %s! (%#x vs %#x (ctx))\n", #member, off1, off2); \
|
---|
111 | rc++; \
|
---|
112 | } \
|
---|
113 | } while (0)
|
---|
114 |
|
---|
115 | #define CHECK_PADDING_UVM(align, member) \
|
---|
116 | do \
|
---|
117 | { \
|
---|
118 | CHECK_PADDING(UVM, member, align); \
|
---|
119 | CHECK_MEMBER_ALIGNMENT(UVM, member, align); \
|
---|
120 | UVM *p = NULL; NOREF(p); \
|
---|
121 | if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
|
---|
122 | printf("warning: UVM::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \
|
---|
123 | #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
|
---|
124 | (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
|
---|
125 | (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
|
---|
126 | } while (0)
|
---|
127 |
|
---|
128 | #define CHECK_PADDING_UVMCPU(align, member) \
|
---|
129 | do \
|
---|
130 | { \
|
---|
131 | CHECK_PADDING(UVMCPU, member, align); \
|
---|
132 | CHECK_MEMBER_ALIGNMENT(UVMCPU, member, align); \
|
---|
133 | UVMCPU *p = NULL; NOREF(p); \
|
---|
134 | if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
|
---|
135 | printf("warning: UVMCPU::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \
|
---|
136 | #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
|
---|
137 | (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
|
---|
138 | (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
|
---|
139 | } while (0)
|
---|
140 |
|
---|
141 | #define CHECK_PADDING_GVM(align, member) \
|
---|
142 | do \
|
---|
143 | { \
|
---|
144 | CHECK_PADDING(GVM, member, align); \
|
---|
145 | CHECK_MEMBER_ALIGNMENT(GVM, member, align); \
|
---|
146 | GVM *p = NULL; NOREF(p); \
|
---|
147 | if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
|
---|
148 | printf("warning: GVM::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \
|
---|
149 | #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
|
---|
150 | (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
|
---|
151 | (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
|
---|
152 | } while (0)
|
---|
153 |
|
---|
154 | #define CHECK_PADDING_GVMCPU(align, member) \
|
---|
155 | do \
|
---|
156 | { \
|
---|
157 | CHECK_PADDING(GVMCPU, member, align); \
|
---|
158 | CHECK_MEMBER_ALIGNMENT(GVMCPU, member, align); \
|
---|
159 | GVMCPU *p = NULL; NOREF(p); \
|
---|
160 | if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
|
---|
161 | printf("warning: GVMCPU::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \
|
---|
162 | #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
|
---|
163 | (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
|
---|
164 | (int)RT_ALIGN_Z(sizeof(p->member.s), (align))); \
|
---|
165 | } while (0)
|
---|
166 |
|
---|
167 | #define PRINT_OFFSET(strct, member) \
|
---|
168 | do \
|
---|
169 | { \
|
---|
170 | 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)); \
|
---|
171 | } while (0)
|
---|
172 |
|
---|
173 |
|
---|
174 | CHECK_SIZE(uint128_t, 128/8);
|
---|
175 | CHECK_SIZE(int128_t, 128/8);
|
---|
176 | CHECK_SIZE(uint64_t, 64/8);
|
---|
177 | CHECK_SIZE(int64_t, 64/8);
|
---|
178 | CHECK_SIZE(uint32_t, 32/8);
|
---|
179 | CHECK_SIZE(int32_t, 32/8);
|
---|
180 | CHECK_SIZE(uint16_t, 16/8);
|
---|
181 | CHECK_SIZE(int16_t, 16/8);
|
---|
182 | CHECK_SIZE(uint8_t, 8/8);
|
---|
183 | CHECK_SIZE(int8_t, 8/8);
|
---|
184 |
|
---|
185 | CHECK_SIZE(X86DESC, 8);
|
---|
186 | CHECK_SIZE(X86DESC64, 16);
|
---|
187 | CHECK_SIZE(VBOXIDTE, 8);
|
---|
188 | CHECK_SIZE(VBOXIDTR, 10);
|
---|
189 | CHECK_SIZE(VBOXGDTR, 10);
|
---|
190 | CHECK_SIZE(VBOXTSS, 136);
|
---|
191 | CHECK_SIZE(X86FXSTATE, 512);
|
---|
192 | CHECK_SIZE(RTUUID, 16);
|
---|
193 | CHECK_SIZE(X86PTE, 4);
|
---|
194 | CHECK_SIZE(X86PD, PAGE_SIZE);
|
---|
195 | CHECK_SIZE(X86PDE, 4);
|
---|
196 | CHECK_SIZE(X86PT, PAGE_SIZE);
|
---|
197 | CHECK_SIZE(X86PTEPAE, 8);
|
---|
198 | CHECK_SIZE(X86PTPAE, PAGE_SIZE);
|
---|
199 | CHECK_SIZE(X86PDEPAE, 8);
|
---|
200 | CHECK_SIZE(X86PDPAE, PAGE_SIZE);
|
---|
201 | CHECK_SIZE(X86PDPE, 8);
|
---|
202 | CHECK_SIZE(X86PDPT, PAGE_SIZE);
|
---|
203 | CHECK_SIZE(X86PML4E, 8);
|
---|
204 | CHECK_SIZE(X86PML4, PAGE_SIZE);
|
---|
205 |
|
---|
206 | PRINT_OFFSET(VM, cpum);
|
---|
207 | CHECK_PADDING_VM(64, cpum);
|
---|
208 | CHECK_PADDING_VM(64, vmm);
|
---|
209 | PRINT_OFFSET(VM, pgm);
|
---|
210 | PRINT_OFFSET(VM, pgm.s.CritSectX);
|
---|
211 | CHECK_PADDING_VM(64, pgm);
|
---|
212 | PRINT_OFFSET(VM, hm);
|
---|
213 | CHECK_PADDING_VM(64, hm);
|
---|
214 | CHECK_PADDING_VM(64, trpm);
|
---|
215 | CHECK_PADDING_VM(64, selm);
|
---|
216 | CHECK_PADDING_VM(64, mm);
|
---|
217 | CHECK_PADDING_VM(64, pdm);
|
---|
218 | PRINT_OFFSET(VM, pdm.s.CritSect);
|
---|
219 | CHECK_PADDING_VM(64, iom);
|
---|
220 | CHECK_PADDING_VM(64, em);
|
---|
221 | /*CHECK_PADDING_VM(64, iem);*/
|
---|
222 | CHECK_PADDING_VM(64, nem);
|
---|
223 | CHECK_PADDING_VM(64, tm);
|
---|
224 | PRINT_OFFSET(VM, tm.s.VirtualSyncLock);
|
---|
225 | CHECK_PADDING_VM(64, dbgf);
|
---|
226 | CHECK_PADDING_VM(64, gim);
|
---|
227 | CHECK_PADDING_VM(64, ssm);
|
---|
228 | #ifdef VBOX_WITH_REM
|
---|
229 | CHECK_PADDING_VM(64, rem);
|
---|
230 | #endif
|
---|
231 | CHECK_PADDING_VM(8, vm);
|
---|
232 | CHECK_PADDING_VM(8, cfgm);
|
---|
233 | CHECK_PADDING_VM(8, apic);
|
---|
234 |
|
---|
235 | PRINT_OFFSET(VMCPU, cpum);
|
---|
236 | CHECK_PADDING_VMCPU(64, iem);
|
---|
237 | CHECK_PADDING_VMCPU(64, hm);
|
---|
238 | CHECK_PADDING_VMCPU(64, em);
|
---|
239 | CHECK_PADDING_VMCPU(64, nem);
|
---|
240 | CHECK_PADDING_VMCPU(64, trpm);
|
---|
241 | CHECK_PADDING_VMCPU(64, tm);
|
---|
242 | CHECK_PADDING_VMCPU(64, vmm);
|
---|
243 | CHECK_PADDING_VMCPU(64, pdm);
|
---|
244 | CHECK_PADDING_VMCPU(64, iom);
|
---|
245 | CHECK_PADDING_VMCPU(64, dbgf);
|
---|
246 | CHECK_PADDING_VMCPU(64, gim);
|
---|
247 | CHECK_PADDING_VMCPU(64, apic);
|
---|
248 |
|
---|
249 | PRINT_OFFSET(VMCPU, pgm);
|
---|
250 | CHECK_PADDING_VMCPU(4096, pgm);
|
---|
251 | CHECK_PADDING_VMCPU(4096, cpum);
|
---|
252 | #ifdef VBOX_WITH_STATISTICS
|
---|
253 | PRINT_OFFSET(VMCPU, pgm.s.pStatTrap0eAttributionRC);
|
---|
254 | #endif
|
---|
255 |
|
---|
256 | PVM pVM = NULL; NOREF(pVM);
|
---|
257 | CHECK_MEMBER_ALIGNMENT(VM, aCpus[0], PAGE_SIZE);
|
---|
258 | CHECK_MEMBER_ALIGNMENT(VM, aCpus[1], PAGE_SIZE);
|
---|
259 | CHECK_MEMBER_ALIGNMENT(VM, aCpus[0].cpum.s.Host, 64);
|
---|
260 | CHECK_MEMBER_ALIGNMENT(VM, aCpus[0].cpum.s.Guest, 64);
|
---|
261 | CHECK_MEMBER_ALIGNMENT(VM, aCpus[1].cpum.s.Host, 64);
|
---|
262 | CHECK_MEMBER_ALIGNMENT(VM, aCpus[1].cpum.s.Guest, 64);
|
---|
263 | CHECK_MEMBER_ALIGNMENT(VM, aCpus[0].cpum.s.Hyper, 64);
|
---|
264 | CHECK_MEMBER_ALIGNMENT(VM, aCpus[1].cpum.s.Hyper, 64);
|
---|
265 | #ifdef VBOX_WITH_VMMR0_DISABLE_LAPIC_NMI
|
---|
266 | CHECK_MEMBER_ALIGNMENT(VM, aCpus[0].cpum.s.pvApicBase, 8);
|
---|
267 | #endif
|
---|
268 |
|
---|
269 | CHECK_MEMBER_ALIGNMENT(VM, aCpus[0].iem.s.DataTlb, 64);
|
---|
270 | CHECK_MEMBER_ALIGNMENT(VM, aCpus[0].iem.s.CodeTlb, 64);
|
---|
271 |
|
---|
272 | CHECK_MEMBER_ALIGNMENT(VMCPU, vmm.s.u64CallRing3Arg, 8);
|
---|
273 | #if defined(RT_OS_WINDOWS) && defined(RT_ARCH_AMD64)
|
---|
274 | CHECK_MEMBER_ALIGNMENT(VMCPU, vmm.s.CallRing3JmpBufR0, 16);
|
---|
275 | CHECK_MEMBER_ALIGNMENT(VMCPU, vmm.s.CallRing3JmpBufR0.xmm6, 16);
|
---|
276 | #endif
|
---|
277 | CHECK_MEMBER_ALIGNMENT(VM, vmm.s.u64LastYield, 8);
|
---|
278 | #ifdef VBOX_WITH_REM
|
---|
279 | CHECK_MEMBER_ALIGNMENT(VM, rem.s.uPendingExcptCR2, 8);
|
---|
280 | CHECK_MEMBER_ALIGNMENT(VM, rem.s.StatsInQEMU, 8);
|
---|
281 | CHECK_MEMBER_ALIGNMENT(VM, rem.s.Env, 64);
|
---|
282 | #endif
|
---|
283 |
|
---|
284 | /* the VMCPUs are page aligned TLB hit reasons. */
|
---|
285 | CHECK_MEMBER_ALIGNMENT(VM, aCpus, 4096);
|
---|
286 | CHECK_SIZE_ALIGNMENT(VMCPU, 4096);
|
---|
287 |
|
---|
288 | /* cpumctx */
|
---|
289 | CHECK_MEMBER_ALIGNMENT(CPUMCTX, rax, 32);
|
---|
290 | CHECK_MEMBER_ALIGNMENT(CPUMCTX, idtr.pIdt, 8);
|
---|
291 | CHECK_MEMBER_ALIGNMENT(CPUMCTX, gdtr.pGdt, 8);
|
---|
292 | CHECK_MEMBER_ALIGNMENT(CPUMCTX, SysEnter, 8);
|
---|
293 | CHECK_MEMBER_ALIGNMENT(CPUMCTX, hwvirt, 8);
|
---|
294 | CHECK_CPUMCTXCORE(rax);
|
---|
295 | CHECK_CPUMCTXCORE(rcx);
|
---|
296 | CHECK_CPUMCTXCORE(rdx);
|
---|
297 | CHECK_CPUMCTXCORE(rbx);
|
---|
298 | CHECK_CPUMCTXCORE(rsp);
|
---|
299 | CHECK_CPUMCTXCORE(rbp);
|
---|
300 | CHECK_CPUMCTXCORE(rsi);
|
---|
301 | CHECK_CPUMCTXCORE(rdi);
|
---|
302 | CHECK_CPUMCTXCORE(r8);
|
---|
303 | CHECK_CPUMCTXCORE(r9);
|
---|
304 | CHECK_CPUMCTXCORE(r10);
|
---|
305 | CHECK_CPUMCTXCORE(r11);
|
---|
306 | CHECK_CPUMCTXCORE(r12);
|
---|
307 | CHECK_CPUMCTXCORE(r13);
|
---|
308 | CHECK_CPUMCTXCORE(r14);
|
---|
309 | CHECK_CPUMCTXCORE(r15);
|
---|
310 | CHECK_CPUMCTXCORE(es);
|
---|
311 | CHECK_CPUMCTXCORE(ss);
|
---|
312 | CHECK_CPUMCTXCORE(cs);
|
---|
313 | CHECK_CPUMCTXCORE(ds);
|
---|
314 | CHECK_CPUMCTXCORE(fs);
|
---|
315 | CHECK_CPUMCTXCORE(gs);
|
---|
316 | CHECK_CPUMCTXCORE(rip);
|
---|
317 | CHECK_CPUMCTXCORE(rflags);
|
---|
318 |
|
---|
319 | #if HC_ARCH_BITS == 32
|
---|
320 | /* CPUMHOSTCTX - lss pair */
|
---|
321 | if (RT_UOFFSETOF(CPUMHOSTCTX, esp) + 4 != RT_UOFFSETOF(CPUMHOSTCTX, ss))
|
---|
322 | {
|
---|
323 | printf("error! CPUMHOSTCTX lss has been split up!\n");
|
---|
324 | rc++;
|
---|
325 | }
|
---|
326 | #endif
|
---|
327 | CHECK_SIZE_ALIGNMENT(CPUMCTX, 64);
|
---|
328 | CHECK_SIZE_ALIGNMENT(CPUMHOSTCTX, 64);
|
---|
329 | CHECK_SIZE_ALIGNMENT(CPUMCTXMSRS, 64);
|
---|
330 |
|
---|
331 | /* pdm */
|
---|
332 | PRINT_OFFSET(PDMDEVINS, Internal);
|
---|
333 | PRINT_OFFSET(PDMDEVINS, achInstanceData);
|
---|
334 | CHECK_MEMBER_ALIGNMENT(PDMDEVINS, achInstanceData, 64);
|
---|
335 | CHECK_PADDING(PDMDEVINS, Internal, 1);
|
---|
336 |
|
---|
337 | PRINT_OFFSET(PDMUSBINS, Internal);
|
---|
338 | PRINT_OFFSET(PDMUSBINS, achInstanceData);
|
---|
339 | CHECK_MEMBER_ALIGNMENT(PDMUSBINS, achInstanceData, 32);
|
---|
340 | CHECK_PADDING(PDMUSBINS, Internal, 1);
|
---|
341 |
|
---|
342 | PRINT_OFFSET(PDMDRVINS, Internal);
|
---|
343 | PRINT_OFFSET(PDMDRVINS, achInstanceData);
|
---|
344 | CHECK_MEMBER_ALIGNMENT(PDMDRVINS, achInstanceData, 32);
|
---|
345 | CHECK_PADDING(PDMDRVINS, Internal, 1);
|
---|
346 |
|
---|
347 | CHECK_PADDING2(PDMCRITSECT);
|
---|
348 | CHECK_PADDING2(PDMCRITSECTRW);
|
---|
349 |
|
---|
350 | /* pgm */
|
---|
351 | #if defined(VBOX_WITH_2X_4GB_ADDR_SPACE)
|
---|
352 | CHECK_MEMBER_ALIGNMENT(PGMCPU, AutoSet, 8);
|
---|
353 | #endif
|
---|
354 | CHECK_MEMBER_ALIGNMENT(PGMCPU, GCPhysCR3, sizeof(RTGCPHYS));
|
---|
355 | CHECK_MEMBER_ALIGNMENT(PGMCPU, aGCPhysGstPaePDs, sizeof(RTGCPHYS));
|
---|
356 | CHECK_MEMBER_ALIGNMENT(PGMCPU, DisState, 8);
|
---|
357 | CHECK_MEMBER_ALIGNMENT(PGMCPU, cPoolAccessHandler, 8);
|
---|
358 | CHECK_MEMBER_ALIGNMENT(PGMPOOLPAGE, idx, sizeof(uint16_t));
|
---|
359 | CHECK_MEMBER_ALIGNMENT(PGMPOOLPAGE, pvPageR3, sizeof(RTHCPTR));
|
---|
360 | CHECK_MEMBER_ALIGNMENT(PGMPOOLPAGE, GCPhys, sizeof(RTGCPHYS));
|
---|
361 | CHECK_SIZE(PGMPAGE, 16);
|
---|
362 | CHECK_MEMBER_ALIGNMENT(PGMRAMRANGE, aPages, 16);
|
---|
363 | CHECK_MEMBER_ALIGNMENT(PGMREGMMIORANGE, RamRange, 16);
|
---|
364 |
|
---|
365 | /* rem */
|
---|
366 | CHECK_MEMBER_ALIGNMENT(REM, aGCPtrInvalidatedPages, 8);
|
---|
367 | CHECK_PADDING3(REMHANDLERNOTIFICATION, u.PhysicalRegister, u.padding);
|
---|
368 | CHECK_PADDING3(REMHANDLERNOTIFICATION, u.PhysicalDeregister, u.padding);
|
---|
369 | CHECK_PADDING3(REMHANDLERNOTIFICATION, u.PhysicalModify, u.padding);
|
---|
370 | CHECK_SIZE_ALIGNMENT(REMHANDLERNOTIFICATION, 8);
|
---|
371 | CHECK_MEMBER_ALIGNMENT(REMHANDLERNOTIFICATION, u.PhysicalDeregister.GCPhys, 8);
|
---|
372 |
|
---|
373 | /* TM */
|
---|
374 | CHECK_MEMBER_ALIGNMENT(TM, TimerCritSect, sizeof(uintptr_t));
|
---|
375 | CHECK_MEMBER_ALIGNMENT(TM, VirtualSyncLock, sizeof(uintptr_t));
|
---|
376 |
|
---|
377 | /* misc */
|
---|
378 | CHECK_PADDING3(EMCPU, u.FatalLongJump, u.achPaddingFatalLongJump);
|
---|
379 | CHECK_SIZE_ALIGNMENT(VMMR0JMPBUF, 8);
|
---|
380 | #if 0
|
---|
381 | PRINT_OFFSET(VM, fForcedActions);
|
---|
382 | PRINT_OFFSET(VM, StatQemuToGC);
|
---|
383 | PRINT_OFFSET(VM, StatGCToQemu);
|
---|
384 | #endif
|
---|
385 |
|
---|
386 | CHECK_MEMBER_ALIGNMENT(IOM, CritSect, sizeof(uintptr_t));
|
---|
387 | #ifdef VBOX_WITH_REM
|
---|
388 | CHECK_MEMBER_ALIGNMENT(EM, CritSectREM, sizeof(uintptr_t));
|
---|
389 | #endif
|
---|
390 | CHECK_MEMBER_ALIGNMENT(EMCPU, u.achPaddingFatalLongJump, 32);
|
---|
391 | CHECK_MEMBER_ALIGNMENT(EMCPU, aExitRecords, sizeof(EMEXITREC));
|
---|
392 | CHECK_MEMBER_ALIGNMENT(PGM, CritSectX, sizeof(uintptr_t));
|
---|
393 | CHECK_MEMBER_ALIGNMENT(PDM, CritSect, sizeof(uintptr_t));
|
---|
394 | CHECK_MEMBER_ALIGNMENT(MMHYPERHEAP, Lock, sizeof(uintptr_t));
|
---|
395 |
|
---|
396 | /* hm - 32-bit gcc won't align uint64_t naturally, so check. */
|
---|
397 | CHECK_MEMBER_ALIGNMENT(HM, uMaxAsid, 8);
|
---|
398 | CHECK_MEMBER_ALIGNMENT(HM, vmx, 8);
|
---|
399 | CHECK_MEMBER_ALIGNMENT(HM, vmx.Msrs, 8);
|
---|
400 | CHECK_MEMBER_ALIGNMENT(HM, svm, 8);
|
---|
401 | CHECK_MEMBER_ALIGNMENT(HM, PatchTree, 8);
|
---|
402 | CHECK_MEMBER_ALIGNMENT(HM, aPatches, 8);
|
---|
403 | CHECK_MEMBER_ALIGNMENT(HMCPU, vmx, 8);
|
---|
404 | CHECK_MEMBER_ALIGNMENT(HMCPU, vmx.VmcsInfo, 8);
|
---|
405 | CHECK_MEMBER_ALIGNMENT(HMCPU, vmx.VmcsInfo.pfnStartVM, 8);
|
---|
406 | CHECK_MEMBER_ALIGNMENT(HMCPU, vmx.VmcsInfoNstGst, 8);
|
---|
407 | CHECK_MEMBER_ALIGNMENT(HMCPU, vmx.VmcsInfoNstGst.pfnStartVM, 8);
|
---|
408 | CHECK_MEMBER_ALIGNMENT(HMCPU, vmx.RestoreHost, 8);
|
---|
409 | CHECK_MEMBER_ALIGNMENT(HMCPU, vmx.LastError, 8);
|
---|
410 | CHECK_MEMBER_ALIGNMENT(HMCPU, svm, 8);
|
---|
411 | CHECK_MEMBER_ALIGNMENT(HMCPU, svm.pfnVMRun, 8);
|
---|
412 | CHECK_MEMBER_ALIGNMENT(HMCPU, Event, 8);
|
---|
413 | CHECK_MEMBER_ALIGNMENT(HMCPU, Event.u64IntInfo, 8);
|
---|
414 | CHECK_MEMBER_ALIGNMENT(HMCPU, DisState, 8);
|
---|
415 | CHECK_MEMBER_ALIGNMENT(HMCPU, StatEntry, 8);
|
---|
416 |
|
---|
417 | /* Make sure the set is large enough and has the correct size. */
|
---|
418 | CHECK_SIZE(VMCPUSET, 32);
|
---|
419 | if (sizeof(VMCPUSET) * 8 < VMM_MAX_CPU_COUNT)
|
---|
420 | {
|
---|
421 | printf("error! VMCPUSET is too small for VMM_MAX_CPU_COUNT=%u!\n", VMM_MAX_CPU_COUNT);
|
---|
422 | rc++;
|
---|
423 | }
|
---|
424 |
|
---|
425 | printf("info: struct UVM: %d bytes\n", (int)sizeof(UVM));
|
---|
426 |
|
---|
427 | CHECK_PADDING_UVM(32, vm);
|
---|
428 | CHECK_PADDING_UVM(32, mm);
|
---|
429 | CHECK_PADDING_UVM(32, pdm);
|
---|
430 | CHECK_PADDING_UVM(32, stam);
|
---|
431 |
|
---|
432 | printf("info: struct UVMCPU: %d bytes\n", (int)sizeof(UVMCPU));
|
---|
433 | CHECK_PADDING_UVMCPU(32, vm);
|
---|
434 |
|
---|
435 | CHECK_PADDING_GVM(4, gvmm);
|
---|
436 | CHECK_PADDING_GVM(4, gmm);
|
---|
437 | CHECK_PADDING_GVMCPU(4, gvmm);
|
---|
438 |
|
---|
439 | /*
|
---|
440 | * Check that the optimized access macros for PGMPAGE works correctly.
|
---|
441 | */
|
---|
442 | PGMPAGE Page;
|
---|
443 | PGM_PAGE_CLEAR(&Page);
|
---|
444 |
|
---|
445 | CHECK_EXPR(PGM_PAGE_GET_HNDL_PHYS_STATE(&Page) == PGM_PAGE_HNDL_PHYS_STATE_NONE);
|
---|
446 | CHECK_EXPR(PGM_PAGE_HAS_ANY_HANDLERS(&Page) == false);
|
---|
447 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_HANDLERS(&Page) == false);
|
---|
448 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_ALL_HANDLERS(&Page) == false);
|
---|
449 |
|
---|
450 | PGM_PAGE_SET_HNDL_PHYS_STATE(&Page, PGM_PAGE_HNDL_PHYS_STATE_ALL);
|
---|
451 | CHECK_EXPR(PGM_PAGE_GET_HNDL_PHYS_STATE(&Page) == PGM_PAGE_HNDL_PHYS_STATE_ALL);
|
---|
452 | CHECK_EXPR(PGM_PAGE_HAS_ANY_HANDLERS(&Page) == true);
|
---|
453 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_HANDLERS(&Page) == true);
|
---|
454 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_ALL_HANDLERS(&Page) == true);
|
---|
455 |
|
---|
456 | PGM_PAGE_SET_HNDL_PHYS_STATE(&Page, PGM_PAGE_HNDL_PHYS_STATE_WRITE);
|
---|
457 | CHECK_EXPR(PGM_PAGE_GET_HNDL_PHYS_STATE(&Page) == PGM_PAGE_HNDL_PHYS_STATE_WRITE);
|
---|
458 | CHECK_EXPR(PGM_PAGE_HAS_ANY_HANDLERS(&Page) == true);
|
---|
459 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_HANDLERS(&Page) == true);
|
---|
460 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_ALL_HANDLERS(&Page) == false);
|
---|
461 |
|
---|
462 | PGM_PAGE_CLEAR(&Page);
|
---|
463 | PGM_PAGE_SET_HNDL_VIRT_STATE(&Page, PGM_PAGE_HNDL_VIRT_STATE_ALL);
|
---|
464 | CHECK_EXPR(PGM_PAGE_GET_HNDL_VIRT_STATE(&Page) == PGM_PAGE_HNDL_VIRT_STATE_ALL);
|
---|
465 | CHECK_EXPR(PGM_PAGE_HAS_ANY_HANDLERS(&Page) == true);
|
---|
466 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_HANDLERS(&Page) == true);
|
---|
467 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_ALL_HANDLERS(&Page) == true);
|
---|
468 |
|
---|
469 | PGM_PAGE_SET_HNDL_VIRT_STATE(&Page, PGM_PAGE_HNDL_VIRT_STATE_WRITE);
|
---|
470 | CHECK_EXPR(PGM_PAGE_GET_HNDL_VIRT_STATE(&Page) == PGM_PAGE_HNDL_VIRT_STATE_WRITE);
|
---|
471 | CHECK_EXPR(PGM_PAGE_HAS_ANY_HANDLERS(&Page) == true);
|
---|
472 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_HANDLERS(&Page) == true);
|
---|
473 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_ALL_HANDLERS(&Page) == false);
|
---|
474 |
|
---|
475 |
|
---|
476 | PGM_PAGE_CLEAR(&Page);
|
---|
477 | PGM_PAGE_SET_HNDL_PHYS_STATE(&Page, PGM_PAGE_HNDL_PHYS_STATE_ALL);
|
---|
478 | PGM_PAGE_SET_HNDL_VIRT_STATE(&Page, PGM_PAGE_HNDL_VIRT_STATE_WRITE);
|
---|
479 | CHECK_EXPR(PGM_PAGE_GET_HNDL_PHYS_STATE(&Page) == PGM_PAGE_HNDL_PHYS_STATE_ALL);
|
---|
480 | CHECK_EXPR(PGM_PAGE_GET_HNDL_VIRT_STATE(&Page) == PGM_PAGE_HNDL_VIRT_STATE_WRITE);
|
---|
481 | CHECK_EXPR(PGM_PAGE_HAS_ANY_HANDLERS(&Page) == true);
|
---|
482 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_HANDLERS(&Page) == true);
|
---|
483 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_ALL_HANDLERS(&Page) == true);
|
---|
484 |
|
---|
485 | PGM_PAGE_SET_HNDL_PHYS_STATE(&Page, PGM_PAGE_HNDL_PHYS_STATE_WRITE);
|
---|
486 | PGM_PAGE_SET_HNDL_VIRT_STATE(&Page, PGM_PAGE_HNDL_VIRT_STATE_ALL);
|
---|
487 | CHECK_EXPR(PGM_PAGE_GET_HNDL_PHYS_STATE(&Page) == PGM_PAGE_HNDL_PHYS_STATE_WRITE);
|
---|
488 | CHECK_EXPR(PGM_PAGE_GET_HNDL_VIRT_STATE(&Page) == PGM_PAGE_HNDL_VIRT_STATE_ALL);
|
---|
489 | CHECK_EXPR(PGM_PAGE_HAS_ANY_HANDLERS(&Page) == true);
|
---|
490 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_HANDLERS(&Page) == true);
|
---|
491 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_ALL_HANDLERS(&Page) == true);
|
---|
492 |
|
---|
493 | PGM_PAGE_SET_HNDL_PHYS_STATE(&Page, PGM_PAGE_HNDL_PHYS_STATE_WRITE);
|
---|
494 | PGM_PAGE_SET_HNDL_VIRT_STATE(&Page, PGM_PAGE_HNDL_VIRT_STATE_WRITE);
|
---|
495 | CHECK_EXPR(PGM_PAGE_GET_HNDL_PHYS_STATE(&Page) == PGM_PAGE_HNDL_PHYS_STATE_WRITE);
|
---|
496 | CHECK_EXPR(PGM_PAGE_GET_HNDL_VIRT_STATE(&Page) == PGM_PAGE_HNDL_VIRT_STATE_WRITE);
|
---|
497 | CHECK_EXPR(PGM_PAGE_HAS_ANY_HANDLERS(&Page) == true);
|
---|
498 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_HANDLERS(&Page) == true);
|
---|
499 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_ALL_HANDLERS(&Page) == false);
|
---|
500 |
|
---|
501 | PGM_PAGE_SET_HNDL_VIRT_STATE(&Page, PGM_PAGE_HNDL_VIRT_STATE_NONE);
|
---|
502 | CHECK_EXPR(PGM_PAGE_GET_HNDL_PHYS_STATE(&Page) == PGM_PAGE_HNDL_PHYS_STATE_WRITE);
|
---|
503 | CHECK_EXPR(PGM_PAGE_GET_HNDL_VIRT_STATE(&Page) == PGM_PAGE_HNDL_VIRT_STATE_NONE);
|
---|
504 | CHECK_EXPR(PGM_PAGE_HAS_ANY_HANDLERS(&Page) == true);
|
---|
505 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_HANDLERS(&Page) == true);
|
---|
506 | CHECK_EXPR(PGM_PAGE_HAS_ACTIVE_ALL_HANDLERS(&Page) == false);
|
---|
507 |
|
---|
508 | #undef AssertFatal
|
---|
509 | #define AssertFatal(expr) do { } while (0)
|
---|
510 | #undef Assert
|
---|
511 | #define Assert(expr) do { } while (0)
|
---|
512 |
|
---|
513 | PGM_PAGE_CLEAR(&Page);
|
---|
514 | CHECK_EXPR(PGM_PAGE_GET_HCPHYS_NA(&Page) == 0);
|
---|
515 | PGM_PAGE_SET_HCPHYS(NULL, &Page, UINT64_C(0x0000fffeff1ff000));
|
---|
516 | CHECK_EXPR(PGM_PAGE_GET_HCPHYS_NA(&Page) == UINT64_C(0x0000fffeff1ff000));
|
---|
517 | PGM_PAGE_SET_HCPHYS(NULL, &Page, UINT64_C(0x0000000000001000));
|
---|
518 | CHECK_EXPR(PGM_PAGE_GET_HCPHYS_NA(&Page) == UINT64_C(0x0000000000001000));
|
---|
519 |
|
---|
520 | PGM_PAGE_INIT(&Page, UINT64_C(0x0000feedfacef000), UINT32_C(0x12345678), PGMPAGETYPE_RAM, PGM_PAGE_STATE_ALLOCATED);
|
---|
521 | CHECK_EXPR(PGM_PAGE_GET_HCPHYS_NA(&Page) == UINT64_C(0x0000feedfacef000));
|
---|
522 | CHECK_EXPR(PGM_PAGE_GET_PAGEID(&Page) == UINT32_C(0x12345678));
|
---|
523 | CHECK_EXPR(PGM_PAGE_GET_TYPE_NA(&Page) == PGMPAGETYPE_RAM);
|
---|
524 | CHECK_EXPR(PGM_PAGE_GET_STATE_NA(&Page) == PGM_PAGE_STATE_ALLOCATED);
|
---|
525 |
|
---|
526 |
|
---|
527 | /*
|
---|
528 | * Report result.
|
---|
529 | */
|
---|
530 | if (rc)
|
---|
531 | printf("tstVMStructSize: FAILURE - %d errors\n", rc);
|
---|
532 | else
|
---|
533 | printf("tstVMStructSize: SUCCESS\n");
|
---|
534 | return rc;
|
---|
535 | }
|
---|
536 |
|
---|