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