VirtualBox

Changeset 43375 in vbox


Ignore:
Timestamp:
Sep 20, 2012 5:15:53 PM (12 years ago)
Author:
vboxsync
Message:

memobj-r0drv-darwin.cpp: 10.8.2 fixes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp

    r43355 r43375  
    452452     *
    453453     * The kIOMemoryKernelUserShared flag just forces the result to be page aligned.
    454      */
    455 #if 1 /** @todo Figure out why this is broken. Is it only on snow leopard? Seen allocating memory for the VM structure, last page corrupted or inaccessible. */
    456     size_t const cbFudged = cb + PAGE_SIZE;
    457 #else
    458     size_t const cbFudged = cb;
    459 #endif
     454     *
     455     * The kIOMemoryMapperNone flag is required since 10.8.2 (IOMMU changes?).
     456     */
    460457    int rc;
    461     IOBufferMemoryDescriptor *pMemDesc =
    462         IOBufferMemoryDescriptor::inTaskWithPhysicalMask(kernel_task,
    463                                                            kIOMemoryKernelUserShared
    464                                                          | kIODirectionInOut
    465                                                          | (fContiguous ? kIOMemoryPhysicallyContiguous : 0),
    466                                                          cbFudged,
    467                                                          PhysMask);
     458    size_t cbFudged = cb;
     459    if (1) /** @todo Figure out why this is broken. Is it only on snow leopard? Seen allocating memory for the VM structure, last page corrupted or inaccessible. */
     460         cbFudged += PAGE_SIZE;
     461#if 1
     462    IOOptionBits fOptions = kIOMemoryKernelUserShared | kIODirectionInOut;
     463    if (fContiguous)
     464        fOptions |= kIOMemoryPhysicallyContiguous;
     465    if (version_major >= 12 /* 12 = 10.8.x = Mountain Kitten */)
     466        fOptions |= kIOMemoryMapperNone;
     467    IOBufferMemoryDescriptor *pMemDesc = IOBufferMemoryDescriptor::inTaskWithPhysicalMask(kernel_task, fOptions,
     468                                                                                          cbFudged, PhysMask);
     469#else /* Requires 10.7 SDK, but allows alignment to be specified: */
     470    uint64_t     uAlignment = PAGE_SIZE;
     471    IOOptionBits fOptions   = kIODirectionInOut | kIOMemoryMapperNone;
     472    if (fContiguous || MaxPhysAddr < UINT64_MAX)
     473    {
     474        fOptions  |= kIOMemoryPhysicallyContiguous;
     475        uAlignment = 1;                 /* PhysMask isn't respected if higher. */
     476    }
     477
     478    IOBufferMemoryDescriptor *pMemDesc = new IOBufferMemoryDescriptor;
     479    if (pMemDesc && !pMemDesc->initWithPhysicalMask(kernel_task, fOptions, cbFudged, uAlignment, PhysMask))
     480    {
     481        pMemDesc->release();
     482        pMemDesc = NULL;
     483    }
     484#endif
    468485    if (pMemDesc)
    469486    {
     
    481498                for (IOByteCount off = 0; off < cb; off += PAGE_SIZE)
    482499                {
    483 #ifdef __LP64__ /* Grumble! */
    484                     addr64_t Addr = pMemDesc->getPhysicalSegment(off, NULL);
     500#ifdef __LP64__
     501                    addr64_t Addr = pMemDesc->getPhysicalSegment(off, NULL, kIOMemoryMapperNone);
    485502#else
    486503                    addr64_t Addr = pMemDesc->getPhysicalSegment64(off, NULL);
     
    497514                        pMemDesc->release();
    498515                        if (PhysMask)
    499                             LogAlways(("rtR0MemObjNativeAllocWorker: off=%x Addr=%llx AddrPrev=%llx MaxPhysAddr=%llx PhysMas=%llx - buggy API!\n",
    500                                        off, Addr, AddrPrev, MaxPhysAddr, PhysMask));
     516                            LogRel(("rtR0MemObjNativeAllocWorker: off=%x Addr=%llx AddrPrev=%llx MaxPhysAddr=%llx PhysMas=%llx fContiguous=%RTbool fOptions=%#x - buggy API!\n",
     517                                    off, Addr, AddrPrev, MaxPhysAddr, PhysMask, fContiguous, fOptions));
    501518                        return VERR_ADDRESS_TOO_BIG;
    502519                    }
     
    522539                    if (fContiguous)
    523540                    {
    524 #ifdef __LP64__ /* Grumble! */
    525                         addr64_t PhysBase64 = pMemDesc->getPhysicalSegment(0, NULL);
     541#ifdef __LP64__
     542                        addr64_t PhysBase64 = pMemDesc->getPhysicalSegment(0, NULL, kIOMemoryMapperNone);
    526543#else
    527544                        addr64_t PhysBase64 = pMemDesc->getPhysicalSegment64(0, NULL);
     
    691708        if (pMemDesc)
    692709        {
    693 #ifdef __LP64__ /* Grumble! */
    694             Assert(Phys == pMemDesc->getPhysicalSegment(0, 0));
     710#ifdef __LP64__
     711            Assert(Phys == pMemDesc->getPhysicalSegment(0, NULL, kIOMemoryMapperNone));
    695712#else
    696             Assert(Phys == pMemDesc->getPhysicalSegment64(0, 0));
     713            Assert(Phys == pMemDesc->getPhysicalSegment64(0, NULL));
    697714#endif
    698715
     
    11511168         * If we've got a memory descriptor, use getPhysicalSegment64().
    11521169         */
    1153 #ifdef __LP64__ /* Grumble! */
    1154         addr64_t Addr = pMemDesc->getPhysicalSegment(iPage * PAGE_SIZE, NULL);
     1170#ifdef __LP64__
     1171        addr64_t Addr = pMemDesc->getPhysicalSegment(iPage * PAGE_SIZE, NULL, kIOMemoryMapperNone);
    11551172#else
    11561173        addr64_t Addr = pMemDesc->getPhysicalSegment64(iPage * PAGE_SIZE, NULL);
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