VirtualBox

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

Last change on this file since 97154 was 97150, checked in by vboxsync, 2 years ago

VMM/CPUM: Nested VMX: bugref:10092 We access the virtual-APIC page directly from guest's memory. Removed it from CPUMCTX.

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