tstVMStructSize.cpp revision 389da1638f530ddb14b3cc1c05f7af0badc3f0d5
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync * tstVMStructSize - testcase for check structure sizes/alignment
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync * and to verify that HC and GC uses the same
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync * representation of the structures.
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync * Copyright (C) 2006-2007 Oracle Corporation
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync * available from http://www.virtualbox.org. This file is free software;
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync * you can redistribute it and/or modify it under the terms of the GNU
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync * General Public License (GPL) as published by the Free Software
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync/*******************************************************************************
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync* Header Files *
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync*******************************************************************************/
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync printf("info: struct VM: %d bytes\n", (int)sizeof(VM));
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync printf("warning: VM::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync } while (0)
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync printf("warning: VMCPU::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync } while (0)
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync if (RT_OFFSETOF(CPUMCTX, member) - RT_OFFSETOF(CPUMCTX, edi) != RT_OFFSETOF(CPUMCTXCORE, member)) \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync } while (0)
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync printf("warning: UVM::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync } while (0)
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync printf("warning: UVMCPU::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync } while (0)
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync printf("warning: GVM::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync } while (0)
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync if (sizeof(p->member.padding) >= (ssize_t)sizeof(p->member.s) + 128 + sizeof(p->member.s) / 20) \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync printf("warning: GVMCPU::%-8s: padding=%-5d s=%-5d -> %-4d suggest=%-5u\n", \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync #member, (int)sizeof(p->member.padding), (int)sizeof(p->member.s), \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync (int)sizeof(p->member.padding) - (int)sizeof(p->member.s), \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync } while (0)
a0f8619bc2bbe3614578c21b5b50a88d2841e7aavboxsync printf("info: %s::%s offset %#x (%d) sizeof %d\n", #strct, #member, (int)RT_OFFSETOF(strct, member), (int)RT_OFFSETOF(strct, member), (int)RT_SIZEOFMEMB(strct, member)); \
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync } while (0)
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync /*CHECK_PADDING_VM(64, iem);*/
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync PRINT_OFFSET(VMCPU, pgm.s.pStatTrap0eAttributionRC);
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync if ((RT_OFFSETOF(VM, selm.s.Tss) & PAGE_OFFSET_MASK) > PAGE_SIZE - sizeof(pVM->selm.s.Tss))
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync if ((RT_OFFSETOF(VM, selm.s.TssTrap08) & PAGE_OFFSET_MASK) > PAGE_SIZE - sizeof(pVM->selm.s.TssTrap08))
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync printf("error! SELM:TssTrap08 is crossing a page!\n");
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync CHECK_MEMBER_ALIGNMENT(VM, aCpus[0].cpum.s.Host, 64);
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync CHECK_MEMBER_ALIGNMENT(VM, aCpus[0].cpum.s.Guest, 64);
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync CHECK_MEMBER_ALIGNMENT(VM, aCpus[1].cpum.s.Host, 64);
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync CHECK_MEMBER_ALIGNMENT(VM, aCpus[1].cpum.s.Guest, 64);
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync CHECK_MEMBER_ALIGNMENT(VM, aCpus[0].cpum.s.Hyper, 64);
632b4638bd18092c6b8edb4e1028c9be112f5076vboxsync CHECK_MEMBER_ALIGNMENT(VM, aCpus[1].cpum.s.Hyper, 64);
rc++;
rc++;
#ifdef VBOX_WITH_RAW_MODE
# include "tstVMStructRC.h"
if (rc)
return rc;