VirtualBox

source: vbox/trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp@ 49258

Last change on this file since 49258 was 49000, checked in by vboxsync, 11 years ago

VMM: IntrInfo to IntInfo renaming.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette