VirtualBox

Changeset 53675 in vbox for trunk


Ignore:
Timestamp:
Jan 2, 2015 12:34:34 PM (10 years ago)
Author:
vboxsync
Message:

VBoxDTrace: vmem fix (r53)

Location:
trunk/src/VBox/ExtPacks/VBoxDTrace
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ExtPacks/VBoxDTrace/VBoxDTraceR0/VBoxDTraceR0.cpp

    r53672 r53675  
    886886    /** The configured resource base. */
    887887    uint32_t            uBase;
    888     /** The configured resource end (base included). */
    889     uint32_t            uEnd;
     888    /** The configured max number of items. */
     889    uint32_t            cMaxItems;
    890890    /** The size of the apChunks array. */
    891891    uint32_t            cMaxChunks;
     
    910910     */
    911911    AssertMsgReturn((uintptr_t)pvBase <= UINT32_MAX, ("%p\n", pvBase), NULL);
     912    AssertMsgReturn(cb <= UINT32_MAX, ("%zu\n", cb), NULL);
    912913    AssertMsgReturn((uintptr_t)pvBase + cb - 1 <= UINT32_MAX, ("%p %zu\n", pvBase, cb), NULL);
    913914    AssertMsgReturn(cbUnit == 1, ("%zu\n", cbUnit), NULL);
     
    922923     * Allocate the instance.
    923924     */
    924     uint32_t cChunks = (uint32_t)(cb - (uintptr_t)pvBase);
    925     cChunks += VBOXDTVMEMCHUNK_BITS - 1;
    926     cChunks /= VBOXDTVMEMCHUNK_BITS;
     925    uint32_t cChunks = cb / VBOXDTVMEMCHUNK_BITS;
     926    if (cb % VBOXDTVMEMCHUNK_BITS)
     927        cChunks++;
    927928    PVBOXDTVMEM pThis = (PVBOXDTVMEM)RTMemAllocZ(RT_OFFSETOF(VBOXDTVMEM, apChunks[cChunks]));
    928929    if (!pThis)
     
    938939    pThis->cCurChunks   = 0;
    939940    pThis->uBase        = (uint32_t)(uintptr_t)pvBase;
    940     pThis->uEnd         = (uint32_t)cb;
     941    pThis->cMaxItems    = (uint32_t)cb;
    941942    pThis->cMaxChunks   = cChunks;
    942943
     
    10241025        /* Out of resources? */
    10251026        if (cChunks >= pThis->cMaxChunks)
    1026         {
    1027 SUPR0Printf("cChunks=%u cMaxChunks=%u!!\n", cChunks, pThis->cMaxChunks);
    10281027            break;
    1029         }
    10301028
    10311029        /*
     
    10341032        uint32_t const  iFirstBit = cChunks > 0 ? pThis->apChunks[cChunks - 1]->iFirst + VBOXDTVMEMCHUNK_BITS : 0;
    10351033        uint32_t const  cFreeBits = cChunks + 1 == pThis->cMaxChunks
    1036                                   ? pThis->uEnd - pThis->uBase - iFirstBit
     1034                                  ? pThis->cMaxItems - (iFirstBit - pThis->uBase)
    10371035                                  : VBOXDTVMEMCHUNK_BITS;
    10381036        Assert(cFreeBits <= VBOXDTVMEMCHUNK_BITS);
     
    10421040        pChunk = (PVBOXDTVMEMCHUNK)RTMemAllocZ(sizeof(*pChunk));
    10431041        if (!pChunk)
    1044         {
    1045 SUPR0Printf("returning NULL!!\n");
    10461042            return NULL;
    1047         }
    10481043
    10491044SUPR0Printf("Adding chunk %p at bit %u, covering %u bits\n", pChunk, iFirstBit, cFreeBits);
     
    10991094    uint32_t uMem = (uint32_t)(uintptr_t)pvMem;
    11001095    AssertReturnVoid(uMem >= pThis->uBase);
    1101     AssertReturnVoid(uMem < pThis->uEnd);
    1102 
    11031096    uMem -= pThis->uBase;
     1097    AssertReturnVoid(uMem < pThis->cMaxItems);
     1098
    11041099
    11051100    /*
  • trunk/src/VBox/ExtPacks/VBoxDTrace/onnv/uts/common/dtrace/dtrace.c

    r53674 r53675  
    1256512565        (void) snprintf(c, sizeof (c), "dtrace_aggid_%p", state);
    1256612566#endif
     12567#ifndef VBOX /* Avoid idProbe = UINT32_MAX as it is used as invalid value by VTG. */
    1256712568        state->dts_aggid_arena = vmem_create(c, (void *)1, UINT32_MAX, 1,
    1256812569            NULL, NULL, NULL, 0, VM_SLEEP | VMC_IDENTIFIER);
     12570#else
     12571        state->dts_aggid_arena = vmem_create(c, (void *)1, _1G, 1,
     12572            NULL, NULL, NULL, 0, VM_SLEEP | VMC_IDENTIFIER);
     12573#endif
    1256912574
    1257012575#ifndef VBOX
     
    1486814873        ASSERT(MUTEX_HELD(&cpu_lock));
    1486914874
     14875#ifndef VBOX /* Reduce the area a bit just to be sure our vmem fake doesn't blow up. */
    1487014876        dtrace_arena = vmem_create("dtrace", (void *)1, UINT32_MAX, 1,
    1487114877            NULL, NULL, NULL, 0, VM_SLEEP | VMC_IDENTIFIER);
     14878#else
     14879        dtrace_arena = vmem_create("dtrace", (void *)1, UINT32_MAX - 16, 1,
     14880            NULL, NULL, NULL, 0, VM_SLEEP | VMC_IDENTIFIER);
     14881#endif
    1487214882#ifndef VBOX
    1487314883        dtrace_minor = vmem_create("dtrace_minor", (void *)DTRACEMNRN_CLONE,
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