VirtualBox

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

Last change on this file since 41739 was 41692, checked in by vboxsync, 12 years ago

DIS: Reducing the DISCPUMODE even more (200 bytes now) and making it have the same layout in all contexts. This is useful since it's used several places in the VM structure. Also a bunch of other cleanups.

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