VirtualBox

Changeset 161 in vbox


Ignore:
Timestamp:
Jan 18, 2007 6:25:45 PM (18 years ago)
Author:
vboxsync
Message:

64-bit: structure alignment.

Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/pdm.h

    r1 r161  
    54045404     * call PDMR3QueryDevice(). */
    54055405    PDMIBASE                    IBase;
     5406#if HC_ARCH_BITS == 32
    54065407    /* padding to make achInstanceData aligned at 16 byte boundrary. */
    5407     uint32_t                    au32Padding[HC_ARCH_BITS == 32 ? 2 : 1];
     5408    uint32_t                    au32Padding[HC_ARCH_BITS == 32 ? 2 : 0];
     5409#endif
    54085410    /** Device instance data. The size of this area is defined
    54095411     * in the PDMDEVREG::cbInstanceData field. */
  • trunk/include/VBox/vm.h

    r119 r161  
    317317
    318318
     319    /* padding to make gnuc put the StatQemuToGC where msc does. */
    319320#if HC_ARCH_BITS == 32
    320     /* padding to make gnuc put the StatQemuToGC where msc does. */
    321321    uint32_t            padding0;
    322322#endif
     
    347347
    348348    /* padding - the unions must be aligned on 32 bytes boundraries. */
    349 #if HC_ARCH_BITS == 32
    350     char                padding[16];
    351 #endif
     349    uint32_t            padding[HC_ARCH_BITS == 32 ? 4 : 6];
    352350
    353351    /** CPUM part. */
     
    357355        struct CPUM s;
    358356#endif
    359         char        padding[3424];      /* multiple of 32 */
     357        char        padding[HC_ARCH_BITS == 32 ? 3424 : 3552];      /* multiple of 32 */
    360358    } cpum;
    361359
     
    483481        struct DBGF s;
    484482#endif
    485         char        padding[1888];      /* multiple of 32 */
     483        char        padding[HC_ARCH_BITS == 32 ? 1888 : 1920];      /* multiple of 32 */
    486484    } dbgf;
    487485
  • trunk/src/VBox/VMM/EMInternal.h

    r49 r161  
    255255        /** Padding used in the other rings.
    256256         * This must be larger than jmp_buf on any supported platform. */
    257         char                achPaddingFatalLongJump[176];
     257        char                achPaddingFatalLongJump[HC_ARCH_BITS == 32 ? 176 : 208];
    258258#ifdef IN_RING3
    259259        /** Long buffer jump for fatal VM errors.
  • trunk/src/VBox/VMM/MMInternal.h

    r23 r161  
    589589    /** Set if PGM has been initialized and we can safely call PGMR3Map(). */
    590590    bool                        fPGMInitialized;
    591 #if GC_ARCH_BITS == 64
     591#if GC_ARCH_BITS == 64 || HC_ARCH_BITS == 64
    592592    uint32_t                    u32Padding1; /**< alignment padding. */
    593593#endif
  • trunk/src/VBox/VMM/PDMInternal.h

    r23 r161  
    254254    /** @copydoc PDMPICREG::pfnGetInterruptHC */
    255255    DECLGCCALLBACKMEMBER(int, pfnGetInterruptGC,(PPDMDEVINS pDevIns));
     256#if GC_ARCH_BITS == 32
     257    RTGCPTR                         GCPtrPadding; /**< Alignment padding. */
     258#endif
    256259} PDMPIC;
    257260
  • trunk/src/VBox/VMM/PGMInternal.h

    r28 r161  
    449449#endif
    450450    /** Array of cached physical addresses for the monitored ranged.  */
    451     PGMPHYS2VIRTHANDLER                aPhysToVirt[1];
     451    PGMPHYS2VIRTHANDLER                 aPhysToVirt[HC_ARCH_BITS == 32 ? 1 : 2];
    452452} PGMVIRTHANDLER;
    453453/** Pointer to a virtual page access handler structure. */
     
    12431243    DECLGCCALLBACKMEMBER(int,  pfnGCShwSetPDEByIndex,(PVM pVM, uint32_t iPD, X86PDEPAE Pde));
    12441244    DECLGCCALLBACKMEMBER(int,  pfnGCShwModifyPDEByIndex,(PVM pVM, uint32_t iPD, uint64_t fFlags, uint64_t fMask));
     1245#if GC_ARCH_BITS == 32 && HC_ARCH_BITS == 64
     1246    RTGCPTR                    alignment0; /**< structure size alignment. */
     1247#endif
    12451248
    12461249    DECLR0CALLBACKMEMBER(int,  pfnR0ShwGetPage,(PVM pVM, RTGCUINTPTR GCPtr, uint64_t *pfFlags, PRTHCPHYS pHCPhys));
     
    13131316    DECLGCCALLBACKMEMBER(int,       pfnGCBthVerifyAccessSyncPage,(PVM pVM, RTGCUINTPTR GCPtrPage, unsigned fFlags, unsigned uError));
    13141317    DECLGCCALLBACKMEMBER(unsigned,  pfnGCBthAssertCR3,(PVM pVM, uint32_t cr3, uint32_t cr4, RTGCUINTPTR GCPtr, RTGCUINTPTR cb));
     1318#if GC_ARCH_BITS == 32 && HC_ARCH_BITS == 64
     1319    RTGCPTR                         alignment2; /**< structure size alignment. */
     1320#endif
    13151321    /** @} */
    13161322
  • trunk/src/VBox/VMM/REMInternal.h

    r119 r161  
    116116{
    117117    RTHCUINTPTR pChunk1;
     118    RTHCUINTPTR pChunk2;
    118119    RTGCPHYS    GCPhys1;
    119     RTHCUINTPTR pChunk2;
    120120    RTGCPHYS    GCPhys2;
    121121} REMCHUNKINFO, *PREMCHUNKINFO;
     
    129129typedef struct REMPHYSREGISTRATION
    130130{
     131    RTHCUINTPTR     HCVirt;
    131132    RTGCPHYS        GCPhys;
    132     RTHCUINTPTR     HCVirt;
    133133    RTUINT          cb;
    134134} REMPHYSREGISTRATION, *PREMPHYSREGISTRATION;
     
    177177     * These instructions are replayed when entering REM. */
    178178    RTGCPTR                 aGCPtrInvalidatedPages[48];
    179 
    180179    /** The number of recorded handler notifications. */
    181180    RTUINT volatile         cHandlerNotifications;
     181    RTUINT                  padding0; /**< Padding. */
    182182    /** Array of recorded handler noticications.
    183183     * These are replayed when entering REM. */
     
    185185
    186186    /** Pointer to an array of hc virt to gc phys records. */
    187     PREMCHUNKINFO          paHCVirtToGCPhys;
     187    HCPTRTYPE(PREMCHUNKINFO) paHCVirtToGCPhys;
    188188    /** Pointer to a GC Phys to HC Virt lookup table. */
    189     RTHCUINTPTR            *paGCPhysToHCVirt;
    190 
    191     /** Number of external RAM and ROM registrations (excluding guest RAM) */
     189    HCPTRTYPE(PRTHCUINTPTR) paGCPhysToHCVirt;
     190
     191    /** Array of external RAM and ROM registrations (excluding guest RAM). */
     192    REMPHYSREGISTRATION     aPhysReg[REM_MAX_PHYS_REGISTRATIONS];
     193    /** Number of external RAM and ROM registrations (excluding guest RAM). */
    192194    RTUINT                  cPhysRegistrations;
    193     REMPHYSREGISTRATION     aPhysReg[REM_MAX_PHYS_REGISTRATIONS];
    194195
    195196    /** MMIO memory type.
     
    213214
    214215    /** Padding for MS / GC alignment difference. */
    215     //uint32_t                u32Padding;
     216    uint32_t                u32Padding;
    216217    /** Time spent in QEMU. */
    217218    STAMPROFILEADV          StatsInQEMU;
     
    223224    STAMPROFILE             StatsStateBack;
    224225
     226#if HC_ARCH_BITS != 32
    225227    /** Padding the CPUX86State structure to 32 byte. */
    226     uint8_t                 abPadding[8];
     228    uint32_t                abPadding[HC_ARCH_BITS == 32 ? 0 : 6];
     229#endif
    227230
    228231#define REM_ENV_SIZE        (HC_ARCH_BITS == 32 ? 0x6440 : 0xb4a0)
  • trunk/src/VBox/VMM/SELMInternal.h

    r98 r161  
    131131    /** Indicates whether the TSS stack selector & base address need to be refreshed.  */
    132132    bool                    fSyncTSSRing0Stack;
     133    /** alignment . */
     134    RTUINT                  uPadding2;
    133135
    134136    /** SELMR3UpdateFromCPUM() profiling. */
  • trunk/src/VBox/VMM/TMInternal.h

    r23 r161  
    183183    /** Pointer to the VM the timer belongs to - GC Ptr. */
    184184    PVMGC                   pVMGC;
     185#if HC_ARCH_BITS == 64 && GC_ARCH_BITS == 32
     186    RTGCPTR                 padding0; /**< pad structure to multiple of 8 bytes. */
     187#endif
    185188} TMTIMER;
    186189
  • trunk/src/VBox/VMM/VMM.cpp

    r23 r161  
    388388        {
    389389            /* Set HC and GC stack pointers to top of stack. */
    390             pVM->vmm.s.CallHostR0JmpBuf.pvSavedStack = pVM->vmm.s.pbHCStack;
     390            pVM->vmm.s.CallHostR0JmpBuf.pvSavedStack = (RTR0PTR)pVM->vmm.s.pbHCStack;
    391391            pVM->vmm.s.pbGCStack = MMHyperHC2GC(pVM, pVM->vmm.s.pbHCStack);
    392392            pVM->vmm.s.pbGCStackBottom = pVM->vmm.s.pbGCStack + VMM_STACK_SIZE;
  • trunk/src/VBox/VMM/VMMInternal.h

    r140 r161  
    109109    uint32_t    esp;
    110110    uint32_t    eip;
     111    uint32_t    u32Padding;
    111112#endif
    112113#if HC_ARCH_BITS == 64
     
    132133    /** Pointer to the buffer used to save the stack.
    133134     * This is assumed to be 8KB. */
    134     void       *pvSavedStack;
     135    RTR0PTR     pvSavedStack;
    135136    /** Esp we we match against esp on resume to make sure the stack wasn't relocated. */
    136137    RTHCUINTREG SpCheck;
     
    234235    /** The EMT yield timer interval (milliseconds). */
    235236    uint32_t                    cYieldEveryMillies;
     237#if HC_ARCH_BITS == 32
     238    uint32_t                    u32Padding0; /**< Alignment padding. */
     239#endif
    236240
    237241    /** @name CallHost
     
    247251    /** @} */
    248252
    249     /* on VC these members are qword aligned! */
    250     //uint32_t                    u32Padding[1];
    251253    /** Number of VMMR0_DO_RUN_GC calls. */
    252254    STAMCOUNTER                 StatRunGC;
  • trunk/src/VBox/VMM/VMMInternal.mac

    r140 r161  
    3131    .esp            resd 1
    3232    .eip            resd 1
     33    .u32Padding     resd 1
    3334
    3435    ; additional state and stack info.
  • trunk/src/VBox/VMM/testcase/Makefile

    r1 r161  
    4646#
    4747ifeq ($(BUILD_TARGET),$(BUILD_PLATFORM))
    48  ifeq ($(filter-out x86.amd64 x86.x86, $(BUILD_TARGET_ARCH).$(BUILD_PLATFORM_ARCH)),)
     48 ifeq ($(filter-out x86.x86 x86.amd64, $(BUILD_TARGET_ARCH).$(BUILD_PLATFORM_ARCH)),)
    4949  OTHERS          += \
    5050        $(PATH_TARGET)/tstAsmStructs.run \
  • trunk/src/VBox/VMM/testcase/tstHelp.h

    r23 r161  
    120120    } while (0)
    121121
     122/**
     123 * Checks that a internal struct padding is big enough.
     124 */
     125#define CHECK_PADDING3(strct, member, pad_member) \
     126    do \
     127    { \
     128        strct *p; \
     129        if (sizeof(p->member) > sizeof(p->pad_member)) \
     130        { \
     131            printf("padding of %s::%s is too small, padding=%d struct=%d\n", #strct, #member, \
     132                   (int)sizeof(p->pad_member), (int)sizeof(p->member)); \
     133            rc++; \
     134        } \
     135    } while (0)
     136
     137
    122138#endif
  • trunk/src/VBox/VMM/testcase/tstVMMR0CallHost-1.cpp

    r23 r161  
    9494    RTR3Init(false);
    9595    RTPrintf("tstVMMR0CallHost-1: Testing...\n");
    96     g_Jmp.pvSavedStack = &g_Stack[0];
     96    g_Jmp.pvSavedStack = (RTR0PTR)&g_Stack[0];
    9797
    9898    /*
  • trunk/src/VBox/VMM/testcase/tstVMStructGC.cpp

    r23 r161  
    357357
    358358    GEN_CHECK_SIZE(REM);
     359    GEN_CHECK_OFF(REM, pCtx);
     360    GEN_CHECK_OFF(REM, cCanExecuteRaw);
     361    GEN_CHECK_OFF(REM, aGCPtrInvalidatedPages);
     362    GEN_CHECK_OFF(REM, cHandlerNotifications);
     363    GEN_CHECK_OFF(REM, aHandlerNotifications);
     364    GEN_CHECK_OFF(REM, paHCVirtToGCPhys);
     365    GEN_CHECK_OFF(REM, cPhysRegistrations);
     366    GEN_CHECK_OFF(REM, aPhysReg);
     367    GEN_CHECK_OFF(REM, rc);
     368    GEN_CHECK_OFF(REM, StatsInQEMU);
     369    GEN_CHECK_OFF(REM, Env);
    359370
    360371    GEN_CHECK_SIZE(SELM);
     
    469480    GEN_CHECK_OFF(VMM, cYieldResumeMillies);
    470481    GEN_CHECK_OFF(VMM, cYieldEveryMillies);
     482    GEN_CHECK_OFF(VMM, enmCallHostOperation);
     483    GEN_CHECK_OFF(VMM, rcCallHost);
     484    GEN_CHECK_OFF(VMM, u64CallHostArg);
     485    GEN_CHECK_OFF(VMM, CallHostR0JmpBuf);
     486    GEN_CHECK_OFF(VMM, CallHostR0JmpBuf.SpCheck);
     487    GEN_CHECK_OFF(VMM, CallHostR0JmpBuf.SpResume);
    471488    GEN_CHECK_OFF(VMM, StatRunGC);
     489    GEN_CHECK_OFF(VMM, StatGCRetPGMLock);
    472490
    473491    GEN_CHECK_SIZE(RTPINGPONG);
  • trunk/src/VBox/VMM/testcase/tstVMStructSize.cpp

    r23 r161  
    8888    do \
    8989    { \
    90         printf("%s::%s offset %d\n",  #strct, #member, RT_OFFSETOF(strct, member)); \
     90        printf("%s::%s offset %d sizeof %d\n",  #strct, #member, (int)RT_OFFSETOF(strct, member), (int)RT_SIZEOFMEMB(strct, member)); \
    9191    } while (0)
    9292
     
    151151    CHECK_MEMBER_ALIGNMENT(VM, cpum.s.Hyper, 32);
    152152    CHECK_MEMBER_ALIGNMENT(VM, vmm.s.CritSectVMLock, 8);
     153    CHECK_MEMBER_ALIGNMENT(VM, vmm.s.CallHostR0JmpBuf, 8);
    153154    CHECK_MEMBER_ALIGNMENT(VM, vmm.s.StatRunGC, 8);
    154155    CHECK_MEMBER_ALIGNMENT(VM, StatTotalQemuToGC, 8);
     
    189190    CHECK_MEMBER_ALIGNMENT(PGMPOOLPAGE, GCPhys, sizeof(RTGCPHYS));
    190191
     192    /* misc */
     193    CHECK_PADDING3(EM, u.FatalLongJump, u.achPaddingFatalLongJump);
     194    CHECK_PADDING3(REMHANDLERNOTIFICATION, u.PhysicalRegister, u.padding);
     195    CHECK_PADDING3(REMHANDLERNOTIFICATION, u.PhysicalDeregister, u.padding);
     196    CHECK_PADDING3(REMHANDLERNOTIFICATION, u.PhysicalModify, u.padding);
     197    CHECK_SIZE_ALIGNMENT(VMMR0JMPBUF, 8);
    191198#if 0
    192199    PRINT_OFFSET(VM, fForcedActions);
     
    194201    PRINT_OFFSET(VM, StatGCToQemu);
    195202#endif
     203
    196204
    197205    /*
Note: See TracChangeset for help on using the changeset viewer.

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