VirtualBox

Changeset 22924 in vbox


Ignore:
Timestamp:
Sep 10, 2009 10:00:36 PM (16 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
52189
Message:

VMM: Made STAM assert on missaligned statistics. Fixed a bunch of mislignments on 32-bit darwin. (burns are expected)

Location:
trunk/src/VBox/VMM
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/IOMInternal.h

    r22493 r22924  
    3030#include <VBox/pdmcritsect.h>
    3131#include <VBox/param.h>
     32#include <iprt/assert.h>
    3233#include <iprt/avl.h>
    3334
     
    130131    STAMCOUNTER                 WriteRZToR3;
    131132} IOMMMIOSTATS;
     133AssertCompileMemberAlignment(IOMMMIOSTATS, ReadR3, 8);
    132134/** Pointer to I/O port statistics. */
    133135typedef IOMMMIOSTATS *PIOMMMIOSTATS;
     
    241243    /** Avl node core with the port as Key. */
    242244    AVLOIOPORTNODECORE          Core;
    243 #if HC_ARCH_BITS == 64 && !defined(RT_OS_WINDOWS)
     245#if HC_ARCH_BITS != 64 || !defined(RT_OS_WINDOWS)
    244246    uint32_t                    u32Alignment; /**< The sizeof(Core) differs. */
    245247#endif
     
    267269    STAMCOUNTER                 OutRZToR3;
    268270} IOMIOPORTSTATS;
     271AssertCompileMemberAlignment(IOMIOPORTSTATS, InR3, 8);
    269272/** Pointer to I/O port statistics. */
    270273typedef IOMIOPORTSTATS *PIOMIOPORTSTATS;
  • trunk/src/VBox/VMM/MMInternal.h

    r20866 r22924  
    2828#include <VBox/stam.h>
    2929#include <VBox/pdmcritsect.h>
     30#include <iprt/assert.h>
    3031#include <iprt/avl.h>
    3132#include <iprt/critsect.h>
     
    6768    struct MMHEAP          *pHeap;
    6869#ifdef MMR3HEAP_WITH_STATISTICS
     70# if HC_ARCH_BITS == 32
     71    /** Aligning the statistics on an 8 byte boundrary (for uint64_t and STAM). */
     72    void                   *pvAlignment;
     73# endif
    6974    /** Number of allocation. */
    7075    uint64_t                cAllocations;
     
    8388#endif
    8489} MMHEAPSTAT;
     90#ifdef MMR3HEAP_WITH_STATISTICS
     91AssertCompileMemberAlignment(MMHEAPSTAT, cAllocations, 8);
     92#endif
    8593/** Pointer to heap statistics record. */
    8694typedef MMHEAPSTAT *PMMHEAPSTAT;
     95
    8796
    8897
     
    169178    size_t                  cbCurAllocated;
    170179} MMUKHEAPSTAT;
     180AssertCompileMemberAlignment(MMUKHEAPSTAT, cAllocations, 8);
    171181/** Pointer to heap statistics record. */
    172182typedef MMUKHEAPSTAT *PMMUKHEAPSTAT;
     
    203213    /** The VM handle. */
    204214    PUVM                    pUVM;
     215#if HC_ARCH_BITS == 32
     216    /** Aligning the statistics on an 8 byte boundrary (for uint64_t and STAM). */
     217    void                   *pvAlignment;
     218#endif
    205219    /** Heap global statistics. */
    206220    MMUKHEAPSTAT            Stat;
    207221} MMUKHEAP;
     222AssertCompileMemberAlignment(MMUKHEAP, Stat, 8);
    208223/** Pointer to MM Heap structure. */
    209224typedef MMUKHEAP *PMMUKHEAP;
     
    277292    uint32_t                cbMaxAllocated;
    278293} MMHYPERSTAT;
     294AssertCompileMemberAlignment(MMHYPERSTAT, cAllocations, 8);
    279295/** Pointer to hypervisor heap statistics record. */
    280296typedef MMHYPERSTAT *PMMHYPERSTAT;
     
    536552    /** Number of free pages in pool. */
    537553    uint32_t                            cFreePages;
     554# if HC_ARCH_BITS == 32
     555    /** Aligning the statistics on an 8 byte boundrary. */
     556    uint32_t                            u32Alignment;
     557# endif
    538558    /** Number of alloc calls. */
    539559    STAMCOUNTER                         cAllocCalls;
     
    548568#endif
    549569} MMPAGEPOOL;
     570AssertCompileMemberAlignment(MMPAGEPOOL, cSubPools, 4);
     571#ifdef VBOX_WITH_STATISTICS
     572AssertCompileMemberAlignment(MMPAGEPOOL, cAllocCalls, 8);
     573#endif
    550574/** Pointer to page pool. */
    551575typedef MMPAGEPOOL *PMMPAGEPOOL;
  • trunk/src/VBox/VMM/PDMInternal.h

    r21367 r22924  
    3030#include <VBox/vusb.h>
    3131#include <VBox/pdmasynccompletion.h>
     32#include <iprt/assert.h>
    3233#include <iprt/critsect.h>
    3334#ifdef IN_RING3
     
    215216    /** Pointer to the VM - GCPtr. */
    216217    PVMRC                           pVMRC;
    217 #if HC_ARCH_BITS == 64
    218218    /** Alignment padding. */
    219219    uint32_t                        padding;
    220 #endif
    221220    /** Event semaphore that is scheduled to be signaled upon leaving the
    222221     * critical section. This is Ring-3 only of course. */
     
    233232    STAMPROFILEADV                  StatLocked;
    234233} PDMCRITSECTINT;
     234AssertCompileMemberAlignment(PDMCRITSECTINT, StatContentionRZLock, 8);
     235/** Pointer to private critical section data. */
    235236typedef PDMCRITSECTINT *PPDMCRITSECTINT;
    236237
     
    912913    /** Queue in which devhlp tasks are queued for R3 execution - RC Ptr. */
    913914    RCPTRTYPE(PPDMQUEUE)            pDevHlpQueueRC;
    914 
    915     RTUINT                          uPadding1; /**< Alignment padding. */
     915    RTRCPTR                         uPadding1; /**< Alignment padding. */
    916916
    917917    /** Linked list of timer driven PDM queues. */
     
    946946    /** Pointer to the heap base (MMIO2 ring-3 mapping). NULL if not registered. */
    947947    RTR3PTR                         pvVMMDevHeap;
     948#if HC_ARCH_BITS == 32
     949    /** Alignment padding. */
     950    uint32_t                        u32Padding2;
     951#endif
    948952    /** The heap size. */
    949953    RTUINT                          cbVMMDevHeap;
     
    967971    STAMCOUNTER                     StatQueuedCritSectLeaves;
    968972} PDM;
     973AssertCompileMemberAlignment(PDM, GCPhysVMMDevHeap, sizeof(RTGCPHYS));
     974AssertCompileMemberAlignment(PDM, CritSect, 8);
     975AssertCompileMemberAlignment(PDM, StatQueuedCritSectLeaves, 8);
    969976/** Pointer to PDM VM instance data. */
    970977typedef PDM *PPDM;
  • trunk/src/VBox/VMM/PGMInternal.h

    r22919 r22924  
    3737#include <VBox/gmm.h>
    3838#include <VBox/hwaccm.h>
    39 #include <iprt/avl.h>
    4039#include <iprt/asm.h>
    4140#include <iprt/assert.h>
     41#include <iprt/avl.h>
    4242#include <iprt/critsect.h>
    4343
     
    17481748    /** Set if the cache is enabled. */
    17491749    bool                        fCacheEnabled;
     1750    /** Alignment padding. */
     1751    bool                        afPadding1[3];
    17501752#endif /* PGMPOOL_WITH_CACHE */
    17511753#ifdef PGMPOOL_WITH_MONITORING
     
    17601762    /** Access handler, R3. */
    17611763    R3PTRTYPE(PFNPGMR3PHYSHANDLER)  pfnAccessHandlerR3;
    1762     /** The access handler description (HC ptr). */
     1764    /** The access handler description (R3 ptr). */
    17631765    R3PTRTYPE(const char *)         pszAccessHandler;
     1766# if HC_ARCH_BITS == 32
     1767    /** Alignment padding. */
     1768    uint32_t                    u32Padding2;
     1769# endif
    17641770    /* Next available slot. */
    17651771    uint32_t                    idxFreeDirtyPage;
     
    18961902    PGMPOOLPAGE                 aPages[PGMPOOL_IDX_FIRST];
    18971903} PGMPOOL, *PPGMPOOL, **PPPGMPOOL;
     1904#ifdef PGMPOOL_WITH_MONITORING
     1905AssertCompileMemberAlignment(PGMPOOL, iModifiedHead, 8);
     1906AssertCompileMemberAlignment(PGMPOOL, aDirtyPages, 8);
     1907#endif
     1908#ifdef VBOX_WITH_STATISTICS
     1909AssertCompileMemberAlignment(PGMPOOL, StatAlloc, 8);
     1910#endif
     1911AssertCompileMemberAlignment(PGMPOOL, aPages, 8);
    18981912
    18991913
     
    22672281    bool                            fRamPreAlloc;
    22682282    /** Alignment padding. */
    2269     bool                            afAlignment0[11];
     2283    bool                            afAlignment0[7];
    22702284
    22712285    /*
     
    23372351    RTGCPTR                         GCPtrCR3Mapping;
    23382352#if HC_ARCH_BITS == 64 && GC_ARCH_BITS == 32
    2339     uint32_t                        u32Alignment;
     2353    uint32_t                        u32Alignment1;
    23402354#endif
    23412355
     
    23942408    /** The address of the ring-0 mapping cache if we're making use of it.  */
    23952409    RTR0PTR                         pvR0DynMapUsed;
     2410#if HC_ARCH_BITS == 32
     2411    /** Alignment padding that makes the next member start on a 8 byte boundrary. */
     2412    uint32_t                        u32Alignment2;
     2413#endif
    23962414
    23972415    /** PGM critical section.
     
    24152433     * (Only used in strict builds.) */
    24162434    bool                            fNoMorePhysWrites;
     2435    /** Alignment padding that makes the next member start on a 8 byte boundrary. */
     2436    bool                            afAlignment3[HC_ARCH_BITS == 32 ? 7: 3];
    24172437
    24182438    /**
     
    24272447        R3R0PTRTYPE(PAVLU32NODECORE) pTree;
    24282448#endif
     2449        /** The chunk age tree, ordered by ageing sequence number. */
     2450        R3PTRTYPE(PAVLLU32NODECORE) pAgeTree;
    24292451        /** The chunk mapping TLB. */
    24302452        PGMCHUNKR3MAPTLB            Tlb;
     
    24342456         * @cfgm    PGM/MaxRing3Chunks */
    24352457        uint32_t                    cMax;
    2436         /** The chunk age tree, ordered by ageing sequence number. */
    2437         R3PTRTYPE(PAVLLU32NODECORE) pAgeTree;
    24382458        /** The current time. */
    24392459        uint32_t                    iNow;
     
    25662586#endif
    25672587} PGM;
     2588AssertCompileMemberAlignment(PGM, paDynPageMap32BitPTEsGC, 8);
     2589AssertCompileMemberAlignment(PGM, HCPhysInterPD, 8);
     2590AssertCompileMemberAlignment(PGM, aHCPhysDynPageMapCache, 8);
     2591AssertCompileMemberAlignment(PGM, CritSect, 8);
     2592AssertCompileMemberAlignment(PGM, ChunkR3Map, 8);
     2593AssertCompileMemberAlignment(PGM, PhysTlbHC, 8);
     2594AssertCompileMemberAlignment(PGM, HCPhysZeroPg, 8);
     2595AssertCompileMemberAlignment(PGM, aHandyPages, 8);
     2596AssertCompileMemberAlignment(PGM, cRelocations, 8);
    25682597/** Pointer to the PGM instance data. */
    25692598typedef PGM *PPGM;
  • trunk/src/VBox/VMM/STAM.cpp

    r20864 r22924  
    597597        Assert(stamR3SlashCompare(pCur->pszName, pszName) > 0);
    598598
     599#ifdef VBOX_STRICT
     600    /*
     601     * Check alignment requirements.
     602     */
     603    switch (enmType)
     604    {
     605            /* 8 byte / 64-bit */
     606        case STAMTYPE_U64:
     607        case STAMTYPE_U64_RESET:
     608        case STAMTYPE_X64:
     609        case STAMTYPE_X64_RESET:
     610        case STAMTYPE_COUNTER:
     611        case STAMTYPE_PROFILE:
     612        case STAMTYPE_PROFILE_ADV:
     613            AssertMsg(!((uintptr_t)pvSample & 7), ("%p - %s\n", pvSample, pszName));
     614            break;
     615
     616            /* 4 byte / 32-bit */
     617        case STAMTYPE_RATIO_U32:
     618        case STAMTYPE_RATIO_U32_RESET:
     619        case STAMTYPE_U32:
     620        case STAMTYPE_U32_RESET:
     621        case STAMTYPE_X32:
     622        case STAMTYPE_X32_RESET:
     623            AssertMsg(!((uintptr_t)pvSample & 3), ("%p - %s\n", pvSample, pszName));
     624            break;
     625
     626            /* 2 byte / 32-bit */
     627        case STAMTYPE_U16:
     628        case STAMTYPE_U16_RESET:
     629        case STAMTYPE_X16:
     630        case STAMTYPE_X16_RESET:
     631            AssertMsg(!((uintptr_t)pvSample & 1), ("%p - %s\n", pvSample, pszName));
     632            break;
     633
     634            /* 1 byte / 8-bit / unaligned */
     635        case STAMTYPE_U8:
     636        case STAMTYPE_U8_RESET:
     637        case STAMTYPE_X8:
     638        case STAMTYPE_X8_RESET:
     639        case STAMTYPE_CALLBACK:
     640            break;
     641
     642        default:
     643            AssertMsgFailed(("%d\n", enmType));
     644            break;
     645    }
     646#endif /* VBOX_STRICT */
     647
    599648    /*
    600649     * Create a new node and insert it at the current location.
  • trunk/src/VBox/VMM/VMInternal.h

    r22915 r22924  
    2525#include <VBox/cdefs.h>
    2626#include <VBox/vmapi.h>
     27#include <iprt/assert.h>
    2728#include <setjmp.h>
    2829
     
    361362     * If clear the VMR3Destroy() caller does so. */
    362363    bool                            fEMTDoesTheCleanup;
     364    /** Align the next bit. */
     365    bool                            afAlignment[5];
    363366
    364367    /** @name Generic Halt data
     
    393396            /** How many times we've blocked while cBlockedNS and cBlockedTooLongNS has been accumulating. */
    394397            uint32_t                cBlocks;
     398            /** Align the next member. */
     399            uint32_t                u32Alignment;
    395400            /** Avg. time spend oversleeping when blocking. (Re-calculated every so often.) */
    396401            uint64_t                cNSBlockedTooLongAvg;
     
    450455    /** @} */
    451456} VMINTUSERPERVMCPU;
     457AssertCompileMemberAlignment(VMINTUSERPERVMCPU, u64HaltsStartTS, 8);
     458AssertCompileMemberAlignment(VMINTUSERPERVMCPU, Halt.Method12.cNSBlockedTooLongAvg, 8);
     459AssertCompileMemberAlignment(VMINTUSERPERVMCPU, StatHaltYield, 8);
    452460
    453461/** Pointer to the VM internal data kept in the UVM. */
Note: See TracChangeset for help on using the changeset viewer.

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