Changeset 43375 in vbox
- Timestamp:
- Sep 20, 2012 5:15:53 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r0drv/darwin/memobj-r0drv-darwin.cpp
r43355 r43375 452 452 * 453 453 * 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 */ 460 457 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 468 485 if (pMemDesc) 469 486 { … … 481 498 for (IOByteCount off = 0; off < cb; off += PAGE_SIZE) 482 499 { 483 #ifdef __LP64__ /* Grumble! */484 addr64_t Addr = pMemDesc->getPhysicalSegment(off, NULL );500 #ifdef __LP64__ 501 addr64_t Addr = pMemDesc->getPhysicalSegment(off, NULL, kIOMemoryMapperNone); 485 502 #else 486 503 addr64_t Addr = pMemDesc->getPhysicalSegment64(off, NULL); … … 497 514 pMemDesc->release(); 498 515 if (PhysMask) 499 Log Always(("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)); 501 518 return VERR_ADDRESS_TOO_BIG; 502 519 } … … 522 539 if (fContiguous) 523 540 { 524 #ifdef __LP64__ /* Grumble! */525 addr64_t PhysBase64 = pMemDesc->getPhysicalSegment(0, NULL );541 #ifdef __LP64__ 542 addr64_t PhysBase64 = pMemDesc->getPhysicalSegment(0, NULL, kIOMemoryMapperNone); 526 543 #else 527 544 addr64_t PhysBase64 = pMemDesc->getPhysicalSegment64(0, NULL); … … 691 708 if (pMemDesc) 692 709 { 693 #ifdef __LP64__ /* Grumble! */694 Assert(Phys == pMemDesc->getPhysicalSegment(0, 0));710 #ifdef __LP64__ 711 Assert(Phys == pMemDesc->getPhysicalSegment(0, NULL, kIOMemoryMapperNone)); 695 712 #else 696 Assert(Phys == pMemDesc->getPhysicalSegment64(0, 0));713 Assert(Phys == pMemDesc->getPhysicalSegment64(0, NULL)); 697 714 #endif 698 715 … … 1151 1168 * If we've got a memory descriptor, use getPhysicalSegment64(). 1152 1169 */ 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); 1155 1172 #else 1156 1173 addr64_t Addr = pMemDesc->getPhysicalSegment64(iPage * PAGE_SIZE, NULL);
Note:
See TracChangeset
for help on using the changeset viewer.