VirtualBox

Changeset 21094 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Jun 30, 2009 6:53:15 PM (16 years ago)
Author:
vboxsync
Message:

VMM: Added MMR3HyperAllocOnceNoRelEx so that we can force the ring-0 logger instances to always have a valid ring-0 mapping. Fixes crashes on FC8 when hitting a breakpoint (debug build w/ ring-0 logging enabled).

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/MMHyper.cpp

    r20874 r21094  
    875875VMMR3DECL(int) MMR3HyperAllocOnceNoRel(PVM pVM, size_t cb, unsigned uAlignment, MMTAG enmTag, void **ppv)
    876876{
     877    return MMR3HyperAllocOnceNoRelEx(pVM, cb, uAlignment, enmTag, 0/*fFlags*/, ppv);
     878}
     879
     880
     881/**
     882 * Allocates memory in the Hypervisor (GC VMM) area which never will
     883 * be freed and doesn't have any offset based relation to other heap blocks.
     884 *
     885 * The latter means that two blocks allocated by this API will not have the
     886 * same relative position to each other in GC and HC. In short, never use
     887 * this API for allocating nodes for an offset based AVL tree!
     888 *
     889 * The returned memory is of course zeroed.
     890 *
     891 * @returns VBox status code.
     892 * @param   pVM         The VM to operate on.
     893 * @param   cb          Number of bytes to allocate.
     894 * @param   uAlignment  Required memory alignment in bytes.
     895 *                      Values are 0,8,16,32 and PAGE_SIZE.
     896 *                      0 -> default alignment, i.e. 8 bytes.
     897 * @param   enmTag      The statistics tag.
     898 * @param   fFlags      Flags, see MMHYPER_AONR_FLAGS_KERNEL_MAPPING.
     899 * @param   ppv         Where to store the address to the allocated memory.
     900 * @remark  This is assumed not to be used at times when serialization is required.
     901 */
     902VMMR3DECL(int) MMR3HyperAllocOnceNoRelEx(PVM pVM, size_t cb, unsigned uAlignment, MMTAG enmTag, uint32_t fFlags, void **ppv)
     903{
    877904    AssertMsg(cb >= 8, ("Hey! Do you really mean to allocate less than 8 bytes?! cb=%d\n", cb));
     905    Assert(!(fFlags & ~(MMHYPER_AONR_FLAGS_KERNEL_MAPPING)));
    878906
    879907    /*
     
    884912    if (   (   cb < _64K
    885913            && (   uAlignment != PAGE_SIZE
    886                || cb < 48*_1K))
    887         ||  VMR3GetState(pVM) != VMSTATE_CREATING)
    888     {
     914                || cb < 48*_1K)
     915            && !(fFlags & MMHYPER_AONR_FLAGS_KERNEL_MAPPING)
     916           )
     917        ||  VMR3GetState(pVM) != VMSTATE_CREATING
     918       )
     919    {
     920        Assert(!(fFlags & MMHYPER_AONR_FLAGS_KERNEL_MAPPING));
    889921        int rc = MMHyperAlloc(pVM, cb, uAlignment, enmTag, ppv);
    890922        if (    rc != VERR_MM_HYPER_NO_MEMORY
     
    896928        }
    897929    }
     930
     931#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
     932    /*
     933     * Set MMHYPER_AONR_FLAGS_KERNEL_MAPPING if we're in going to execute in ring-0.
     934     */
     935    if (VMMIsHwVirtExtForced(pVM))
     936        fFlags |= MMHYPER_AONR_FLAGS_KERNEL_MAPPING;
     937#endif
    898938
    899939    /*
     
    927967                              0 /*fFlags*/,
    928968                              &pvPages,
    929 #ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
    930                               VMMIsHwVirtExtForced(pVM) ? &pvR0 : NULL,
    931 #else
    932                               NULL,
    933 #endif
     969                              fFlags & MMHYPER_AONR_FLAGS_KERNEL_MAPPING ? &pvR0 : NULL,
    934970                              paPages);
    935971    if (RT_SUCCESS(rc))
    936972    {
     973        if (!(fFlags & MMHYPER_AONR_FLAGS_KERNEL_MAPPING))
    937974#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
    938         if (!VMMIsHwVirtExtForced(pVM))
    939975            pvR0 = NIL_RTR0PTR;
    940976#else
    941         pvR0 = (uintptr_t)pvPages;
     977            pvR0 = (RTR0PTR)pvPages;
    942978#endif
     979
    943980        memset(pvPages, 0, cbAligned);
    944981
  • trunk/src/VBox/VMM/VMM.cpp

    r20875 r21094  
    299299
    300300# ifdef VBOX_WITH_R0_LOGGING
    301         for (unsigned i = 0; i < pVM->cCPUs; i++)
     301        for (VMCPUID i = 0; i < pVM->cCPUs; i++)
    302302        {
    303303            PVMCPU pVCpu = &pVM->aCpus[i];
    304304
    305             rc = MMR3HyperAllocOnceNoRel(pVM, RT_OFFSETOF(VMMR0LOGGER, Logger.afGroups[pLogger->cGroups]),
    306                                          0, MM_TAG_VMM, (void **)&pVCpu->vmm.s.pR0LoggerR3);
     305            rc = MMR3HyperAllocOnceNoRelEx(pVM, RT_OFFSETOF(VMMR0LOGGER, Logger.afGroups[pLogger->cGroups]),
     306                                           0, MM_TAG_VMM, MMHYPER_AONR_FLAGS_KERNEL_MAPPING,
     307                                           (void **)&pVCpu->vmm.s.pR0LoggerR3);
    307308            if (RT_FAILURE(rc))
    308309                return rc;
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